Commit d1466e17 authored by 张辰's avatar 张辰

一些问题修正

parent 9a7e35d5
......@@ -2,6 +2,10 @@ package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
......@@ -12,5 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @since 2021-07-22
*/
public interface TopicMapper extends BaseMapper<TopicEntity> {
@Select("select * from topic where id>#{startId} and delete_tag=0 order by id asc limit #{size}")
List<TopicEntity> selectGtIdPageable(@Param("startId") Long startId, @Param("size") Integer size);
}
......@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -29,9 +30,18 @@ public class TopicService {
private UuidGenHelper uuidGenHelper;
public List<TopicEntity> queryAll() {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(TopicEntity::getCreateTime));
List<TopicEntity> retList = new ArrayList<>();
Long lastId = 0L;
while (true) {
List<TopicEntity> tmpList = topicMapper.selectGtIdPageable(lastId, 100);
if (tmpList.isEmpty()) {
break;
}
retList.addAll(tmpList);
lastId = tmpList.stream().map(TopicEntity::getId).max(Long::compareTo).get();
}
return retList;
}
public List<TopicEntity> queryByKeyword(String keyword) {
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity;
import com.tanpu.community.dao.mapper.community.VisitSummaryMapper;
......@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -26,7 +28,10 @@ public class VisitSummaryService {
if (refIds.isEmpty()) {
return refIds;
}
List<String> visited = visitSummaryMapper.selectRefIdByUserId(userId, StringUtils.joinWith(",", refIds));
List<String> visited = visitSummaryMapper.selectList(new LambdaQueryWrapper<VisitSummaryEntity>()
.eq(VisitSummaryEntity::getVisitorId, userId)
.in(VisitSummaryEntity::getRefId, refIds))
.stream().map(VisitSummaryEntity::getRefId).distinct().collect(Collectors.toList());
return ListUtils.subtract(refIds, visited);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment