需求评论通知

This commit is contained in:
wangliwen 2022-06-02 15:39:18 +08:00
parent 91b6e7ff8f
commit 2a21a57ede
1 changed files with 35 additions and 0 deletions

View File

@ -4,16 +4,25 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import io.renren.common.constant.Constant;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.demandComment.dao.TDemandCommentDao;
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
import io.renren.modules.demandComment.entity.TDemandCommentEntity;
import io.renren.modules.demandComment.service.TDemandCommentService;
import io.renren.modules.notice.dto.SysNoticeDTO;
import io.renren.modules.notice.enums.NoticeStatusEnum;
import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
@ -26,6 +35,10 @@ import java.util.stream.Collectors;
public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao, TDemandCommentEntity, TDemandCommentDTO> implements TDemandCommentService {
@Autowired
private TDemandDataService tDemandDataService;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysNoticeService sysNoticeService;
@Override
public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) {
@ -59,4 +72,26 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
public Long commentCount(Long dataId) {
return baseDao.commentCount(dataId);
}
@Override
public void save(TDemandCommentDTO tDemandCommentDTO) {
super.save(tDemandCommentDTO);
CompletableFuture.runAsync(() -> { // 发起人
Optional<TDemandDataDTO> tDemandDataDTO = Optional.ofNullable(tDemandDataService.get(tDemandCommentDTO.getTargetId()));
Optional<SysUserDTO> sysUserDTO = Optional.ofNullable(sysUserService.get(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator() : null));
String content = "【评论】" + (sysUserDTO.isPresent() ? sysUserDTO.get().getRealName() : "") + "您发起的需求 " + tDemandDataDTO.orElse(new TDemandDataDTO()).getDemandSubject() + "有新的评论,请前往查看详情";
SysNoticeDTO dto = new SysNoticeDTO();
dto.setType(2);
dto.setTitle("需求评论系统通知");
dto.setContent(content); // 通知内容
dto.setReceiverType(1);
dto.setReceiverTypeIds(tDemandDataDTO.isPresent() ? tDemandDataDTO.get().getCreator().toString() : "");
dto.setStatus(NoticeStatusEnum.SEND.value());
dto.setSenderName("流程系统");
dto.setSenderDate(new Date());
dto.setCreator(sysUserService.getByUsername("admin").getId());
dto.setCreateDate(new Date());
sysNoticeService.save(dto);
});
}
}