|
@@ -1,21 +1,26 @@
|
|
|
package com.sxtvs.open.api.clue.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sxtvs.open.api.clue.dto.ClueDTO;
|
|
|
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.mapper.ClueMapper;
|
|
|
import com.sxtvs.open.api.clue.service.IClueService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sxtvs.open.core.advice.BizException;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import org.apache.http.util.TextUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -28,6 +33,9 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements IClueService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ClueReplyServiceImpl clueReplyService;
|
|
|
+
|
|
|
public IPage<Clue> cluePage(ClueDTO clueDTO){
|
|
|
|
|
|
LambdaQueryWrapper<Clue> wrapper = Wrappers.lambdaQuery();
|
|
@@ -35,6 +43,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements IC
|
|
|
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())
|
|
|
.like(!TextUtils.isEmpty(clueDTO.getTitle()), Clue::getTitle, "%" + clueDTO.getTitle() + "%")
|
|
|
+ .eq(Clue::getValidity, (byte) 1)
|
|
|
.orderByDesc(Clue::getId)
|
|
|
);
|
|
|
}
|
|
@@ -55,4 +64,39 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements IC
|
|
|
clue.setStatus(verifyDTO.getStatus());
|
|
|
updateById(clue);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reply(ClueReply clueReply){
|
|
|
+ Clue clue = getById(clueReply.getClueId());
|
|
|
+ clue.setReplyFlag(1);
|
|
|
+ clue.setReplyTime(LocalDateTime.now());
|
|
|
+ updateById(clue);
|
|
|
+ clueReply.setId(null);
|
|
|
+ clueReply.setReplyTime(LocalDateTime.now());
|
|
|
+ clueReply.setModifyTime(LocalDateTime.now());
|
|
|
+ clueReplyService.save(clueReply);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void delete(Long id){
|
|
|
+ Clue clue = getById(id);
|
|
|
+ if(null == clue){
|
|
|
+ throw new BizException(40001, "不存在的信息");
|
|
|
+ }
|
|
|
+ clue.setValidity((byte) 0);
|
|
|
+ updateById(clue);
|
|
|
+ clueReplyService.updateBatchById(
|
|
|
+ clueReplyService.lambdaQuery().eq(ClueReply::getClueId, clue.getId()).list().stream()
|
|
|
+ .peek(data -> data.setStatus(-1)).collect(Collectors.toList())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public ClueInfo info(Long id){
|
|
|
+ Clue clue = getById(id);
|
|
|
+ ClueInfo info = new ClueInfo();
|
|
|
+ BeanUtil.copyProperties(clue, info);
|
|
|
+ info.setClueReplies(clueReplyService.lambdaQuery().eq(ClueReply::getClueId,clue.getId()).list());
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
}
|