|
@@ -11,15 +11,21 @@ import com.sxtvs.open.api.clue.dto.VerifyDTO;
|
|
|
import com.sxtvs.open.api.clue.entity.Clue;
|
|
|
import com.sxtvs.open.api.clue.entity.ClueInfo;
|
|
|
import com.sxtvs.open.api.clue.entity.ClueReply;
|
|
|
+import com.sxtvs.open.api.clue.entity.Info;
|
|
|
import com.sxtvs.open.api.clue.mapper.ClueMapper;
|
|
|
import com.sxtvs.open.api.clue.service.IClueService;
|
|
|
import com.sxtvs.open.core.advice.BizException;
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
+import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.apache.http.util.TextUtils;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -36,16 +42,33 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements IC
|
|
|
@Resource
|
|
|
private ClueReplyServiceImpl clueReplyService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ClueInfoServiceImpl clueInfoService;
|
|
|
+
|
|
|
public IPage<Clue> cluePage(ClueDTO clueDTO){
|
|
|
|
|
|
LambdaQueryWrapper<Clue> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
- return baseMapper.selectPage(new Page<>(clueDTO.getPage(), clueDTO.getSize()), wrapper.ge(clueDTO.getStart() != null, Clue::getAddTime, clueDTO.getStart())
|
|
|
- .le(clueDTO.getEnd() != null, Clue::getAddTime, clueDTO.getEnd())
|
|
|
+ IPage<Clue> clueIPage = baseMapper.selectPage(new Page<>(clueDTO.getPage(), clueDTO.getSize()),
|
|
|
+ wrapper.ge(clueDTO.getStart() != null, Clue::getAddTime, clueDTO.getStart())
|
|
|
+ .lt(clueDTO.getEnd() != null, Clue::getAddTime, clueDTO.getEnd().plusDays(1L))
|
|
|
.like(!TextUtils.isEmpty(clueDTO.getTitle()), Clue::getTitle, "%" + clueDTO.getTitle() + "%")
|
|
|
.eq(Clue::getValidity, (byte) 1)
|
|
|
.orderByDesc(Clue::getId)
|
|
|
);
|
|
|
+
|
|
|
+ Map<Long, Pair<String, Integer>> collect = clueInfoService.lambdaQuery().in(
|
|
|
+ ClueInfo::getRelaId, clueIPage.getRecords().stream().map(Clue::getId).collect(Collectors.toList())
|
|
|
+ ).list().stream().collect(Collectors.groupingBy(ClueInfo::getRelaId, Collectors.collectingAndThen(Collectors.toList(),
|
|
|
+ data -> new ImmutablePair<>(Strings.join(data.stream().map(ClueInfo::getType).distinct().collect(Collectors.toList()), ','), data.size())
|
|
|
+ )));
|
|
|
+
|
|
|
+ clueIPage.setRecords(clueIPage.getRecords().stream().peek(v -> {
|
|
|
+ v.setClueInfoCount(collect.containsKey(v.getId()) ? collect.get(v.getId()).getRight() : 1);
|
|
|
+ v.setClueInfoType(collect.containsKey(v.getId()) ? collect.get(v.getId()).getLeft() : "0");
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ return clueIPage;
|
|
|
}
|
|
|
|
|
|
public void store(Clue clue){
|
|
@@ -91,11 +114,12 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements IC
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public ClueInfo info(Long id){
|
|
|
+ public Info info(Long id){
|
|
|
Clue clue = getById(id);
|
|
|
- ClueInfo info = new ClueInfo();
|
|
|
+ Info info = new Info();
|
|
|
BeanUtil.copyProperties(clue, info);
|
|
|
info.setClueReplies(clueReplyService.lambdaQuery().eq(ClueReply::getClueId,clue.getId()).list());
|
|
|
+ info.setClueInfos(clueInfoService.lambdaQuery().eq(ClueInfo::getRelaId, clue.getId()).list());
|
|
|
return info;
|
|
|
}
|
|
|
|