diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index c35ee74bc8..f4a72b9040 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -104,7 +104,7 @@ public enum EpmetErrorCode { RESI_EVENT_SHIFT_PROJECT(8608,"事件已立项,请勿重复操作"), PLEASE_CHOOSE_RECEIVER(8609,"请选择接收人"), - + REPLY_INFO_CONTENT_NOT_NULL(8610,"回复内容不能为空"), // 爱心互助 居民端 NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadInfoFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadInfoFormDTO.java new file mode 100644 index 0000000000..955bb0e86a --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadInfoFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 我收到的,列表有红点的,点击消息,调用此接口 + * @Author yinzuomei + * @Date 2021/8/19 4:58 下午 + */ +@Data +public class ReadInfoFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + @NotBlank(message = "infoId不能为空",groups = AddUserInternalGroup.class) + private String infoId; + + + + //以下参数从token中获取 + /** + * 当前用户id + */ + @NotBlank(message = "userId不能为空",groups = AddUserInternalGroup.class) + private String userId; + + /** + * 当前客户id + */ + @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) + private String customerId; +} + diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadReplyFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadReplyFormDTO.java new file mode 100644 index 0000000000..d374fb5e56 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadReplyFormDTO.java @@ -0,0 +1,37 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 我发出的,发布人点击详情后,阅读回复,将未读回复数置为0 + * @Author yinzuomei + * @Date 2021/8/19 5:49 下午 + */ +@Data +public class ReadReplyFormDTO implements Serializable { + private static final long serialVersionUID = 1315143292245373474L; + + public interface AddUserInternalGroup { + } + + @NotBlank(message = "infoId不能为空", groups = AddUserInternalGroup.class) + private String infoId; + + + //以下参数从token中获取 + /** + * 当前用户id + */ + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; + + /** + * 当前客户id + */ + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; +} + diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReplyInfoFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReplyInfoFormDTO.java new file mode 100644 index 0000000000..33d4c2ca7d --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReplyInfoFormDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.FileCommonDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 回复消息 + * @Author yinzuomei + * @Date 2021/8/19 5:18 下午 + */ + +@Data +public class ReplyInfoFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + @NotBlank(message = "infoId不能为空",groups = ReadInfoFormDTO.AddUserInternalGroup.class) + private String infoId; + + private String content; + /** + * 附件列表 + */ + private List attachmentList; + + //以下参数从token中获取 + /** + * 当前用户id + */ + @NotBlank(message = "userId不能为空",groups = ReadInfoFormDTO.AddUserInternalGroup.class) + private String userId; + + /** + * 当前客户id + */ + @NotBlank(message = "customerId不能为空",groups = ReadInfoFormDTO.AddUserInternalGroup.class) + private String customerId; +} + diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java index 15ff4df649..d77ad612f8 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java @@ -21,6 +21,9 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.ReadInfoFormDTO; +import com.epmet.dto.form.ReadReplyFormDTO; +import com.epmet.dto.form.ReplyInfoFormDTO; import com.epmet.dto.form.SendInfoFormDTO; import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.service.InfoService; @@ -62,6 +65,58 @@ public class InfoController { return new Result().ok(infoService.sendInfo(formDTO)); } + /** + * 【发送消息】我收到的-阅读消息 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/8/19 5:03 下午 + */ + @PostMapping("read-info") + public Result readInfo(@LoginUser TokenDto tokenDto,@RequestBody ReadInfoFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,ReadInfoFormDTO.AddUserInternalGroup.class); + infoService.readInfo(formDTO); + return new Result(); + } + + /** + * 回复消息(目前需求是发布人不可以回复) + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/8/19 5:29 下午 + */ + @PostMapping("reply-info") + public Result replyInfo(@LoginUser TokenDto tokenDto,@RequestBody ReplyInfoFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,ReplyInfoFormDTO.AddUserInternalGroup.class); + infoService.replyInfo(formDTO); + return new Result(); + } + /** + * 我发出的,发布人点击详情后,阅读回复,将未读回复数置为0 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/8/19 5:51 下午 + */ + @PostMapping("read-reply") + public Result readInfoReply(@LoginUser TokenDto tokenDto,@RequestBody ReadReplyFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,ReadReplyFormDTO.AddUserInternalGroup.class); + infoService.readInfoReply(formDTO); + return new Result(); + } } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoProfileDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoProfileDao.java index 4b26153662..4f7c61ea61 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoProfileDao.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoProfileDao.java @@ -29,5 +29,8 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface InfoProfileDao extends BaseDao { - + + int addReadTotal(String infoId); + + InfoProfileEntity selectByInfoId(String infoId); } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoReceiversDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoReceiversDao.java index 74a19d7aba..05371ca5a1 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoReceiversDao.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoReceiversDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.InfoReceiversEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 消息接收人记录表 @@ -29,5 +30,15 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface InfoReceiversDao extends BaseDao { - + + /** + * 消息的某一个接收人记录 + * + * @param infoId + * @param userId + * @return com.epmet.entity.InfoReceiversEntity + * @author yinzuomei + * @date 2021/8/19 5:11 下午 + */ + InfoReceiversEntity selectInfoReceiver(@Param("infoId")String infoId, @Param("userId")String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java index 49395bb88f..61c4766577 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java @@ -18,6 +18,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.form.ReadInfoFormDTO; +import com.epmet.dto.form.ReadReplyFormDTO; +import com.epmet.dto.form.ReplyInfoFormDTO; import com.epmet.dto.form.SendInfoFormDTO; import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.entity.InfoEntity; @@ -39,4 +42,34 @@ public interface InfoService extends BaseService { * @date 2021/8/19 10:27 上午 */ SendInfoResultDTO sendInfo(SendInfoFormDTO formDTO); + + /** + * 【发送消息】我收到的-阅读消息 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:03 下午 + */ + void readInfo(ReadInfoFormDTO formDTO); + + /** + * 回复消息(目前需求是发布人不可以回复) + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:30 下午 + */ + void replyInfo(ReplyInfoFormDTO formDTO); + + /** + * 我发出的,发布人点击详情后,阅读回复,将未读回复数置为0 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:51 下午 + */ + void readInfoReply(ReadReplyFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java index c3b60aae1c..0a7c2d3f74 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java @@ -28,10 +28,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserMessageConstans; import com.epmet.dao.*; -import com.epmet.dto.form.OrgCommonDTO; -import com.epmet.dto.form.OrgStaffFormDTO; -import com.epmet.dto.form.RoleStaffIdFormDTO; -import com.epmet.dto.form.SendInfoFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.entity.*; import com.epmet.feign.EpmetUserOpenFeignClient; @@ -182,6 +179,104 @@ public class InfoServiceImpl extends BaseServiceImpl implem return resultDTO; } + /** + * 【发送消息】我收到的-阅读消息 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:03 下午 + */ + @Override + public void readInfo(ReadInfoFormDTO formDTO) { + //已读总人数+1 + //修改为已读 + InfoReceiversEntity receiver = infoReceiversDao.selectInfoReceiver(formDTO.getInfoId(), formDTO.getUserId()); + if (!receiver.getReadFlag()) { + receiver.setReadFlag(true); + int affectRows = infoReceiversDao.updateById(receiver); + if (affectRows == 1) { + infoProfileDao.addReadTotal(formDTO.getInfoId()); + log.info("已读总人数+1"); + } + } + + } + + /** + * 回复消息(目前需求是发布人不可以回复) + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:30 下午 + */ + @Override + public void replyInfo(ReplyInfoFormDTO formDTO) { + //1、插入回复记录、回复附件 + //内容和附件 2选一 + if(StringUtils.isBlank(formDTO.getContent())&&CollectionUtils.isEmpty(formDTO.getAttachmentList())){ + throw new RenException(EpmetErrorCode.REPLY_INFO_CONTENT_NOT_NULL.getCode(), EpmetErrorCode.REPLY_INFO_CONTENT_NOT_NULL.getMsg()); + } + InfoReplyEntity infoReplyEntity=new InfoReplyEntity(); + infoReplyEntity.setInfoId(formDTO.getInfoId()); + infoReplyEntity.setCustomerId(formDTO.getCustomerId()); + infoReplyEntity.setFromUserId(formDTO.getUserId()); + infoReplyDao.insert(infoReplyEntity); + int sort=1; + if(StringUtils.isNotBlank(formDTO.getContent())){ + InfoReplyContentEntity contentEntity=new InfoReplyContentEntity(); + contentEntity.setCustomerId(formDTO.getCustomerId()); + contentEntity.setInfoReplyId(infoReplyEntity.getId()); + contentEntity.setReplyType("text"); + contentEntity.setContent(formDTO.getContent()); + contentEntity.setSort(sort); + infoReplyContentDao.insert(contentEntity); + sort++; + } + if(CollectionUtils.isNotEmpty(formDTO.getAttachmentList())){ + for(FileCommonDTO att:formDTO.getAttachmentList()) { + InfoReplyContentEntity contentEntity = new InfoReplyContentEntity(); + contentEntity.setCustomerId(formDTO.getCustomerId()); + contentEntity.setInfoReplyId(infoReplyEntity.getId()); + contentEntity.setReplyType(att.getType()); + contentEntity.setContent(att.getUrl()); + contentEntity.setAttachmentFormat(att.getFormat()); + contentEntity.setAttachmentSize(att.getSize()); + contentEntity.setDuration(att.getDuration()); + contentEntity.setAttachmentName(att.getName()); + contentEntity.setSort(sort); + infoReplyContentDao.insert(contentEntity); + sort++; + } + } + // 2、未读的回复数+1 + InfoProfileEntity infoProfileEntity=infoProfileDao.selectByInfoId(formDTO.getInfoId()); + // 3、现在是发布人不可以回复,日后如果发布人可以回复,自己发布的,不需要提示未读红点 + if(!formDTO.getUserId().equals(infoProfileEntity.getCreatedBy())){ + infoProfileEntity.setUnReadReplyNum(infoProfileEntity.getUnReadReplyNum()+1); + infoProfileDao.updateById(infoProfileEntity); + } + + } + + /** + * 我发出的,发布人点击详情后,阅读回复,将未读回复数置为0 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/8/19 5:51 下午 + */ + @Override + public void readInfoReply(ReadReplyFormDTO formDTO) { + InfoProfileEntity infoProfile = infoProfileDao.selectByInfoId(formDTO.getInfoId()); + if (null != infoProfile && infoProfile.getCreatedBy().equals(formDTO.getUserId()) && infoProfile.getUnReadReplyNum() > 0) { + infoProfile.setUnReadReplyNum(NumConstant.ZERO); + infoProfileDao.updateById(infoProfile); + } + } + /** * 查询架构里面的人 * diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml index 5b9bea1f1e..4aa4e77000 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml @@ -4,5 +4,19 @@ + + UPDATE info_profile + SET read_total = read_total + 1, + UPDATED_TIME = NOW() + WHERE + INFO_ID = #{infoId} + AND DEL_FLAG = '0' + + \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml index 88acf8d276..38c13d2489 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml @@ -3,6 +3,15 @@ - + \ No newline at end of file