Browse Source

回复、接收人阅读消息、发布人查看回复

dev_shibei_match
yinzuomei 4 years ago
parent
commit
b3f207821f
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 36
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadInfoFormDTO.java
  3. 37
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReadReplyFormDTO.java
  4. 43
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ReplyInfoFormDTO.java
  5. 55
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/InfoController.java
  6. 5
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoProfileDao.java
  7. 13
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/InfoReceiversDao.java
  8. 33
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java
  9. 103
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java
  10. 14
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml
  11. 11
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml

2
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,"事件已立项,请勿重复操作"), RESI_EVENT_SHIFT_PROJECT(8608,"事件已立项,请勿重复操作"),
PLEASE_CHOOSE_RECEIVER(8609,"请选择接收人"), PLEASE_CHOOSE_RECEIVER(8609,"请选择接收人"),
REPLY_INFO_CONTENT_NOT_NULL(8610,"回复内容不能为空"),
// 爱心互助 居民端 // 爱心互助 居民端
NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"),

36
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;
}

37
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;
}

43
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<FileCommonDTO> attachmentList;
//以下参数从token中获取
/**
* 当前用户id
*/
@NotBlank(message = "userId不能为空",groups = ReadInfoFormDTO.AddUserInternalGroup.class)
private String userId;
/**
* 当前客户id
*/
@NotBlank(message = "customerId不能为空",groups = ReadInfoFormDTO.AddUserInternalGroup.class)
private String customerId;
}

55
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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; 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.form.SendInfoFormDTO;
import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.service.InfoService; import com.epmet.service.InfoService;
@ -62,6 +65,58 @@ public class InfoController {
return new Result<SendInfoResultDTO>().ok(infoService.sendInfo(formDTO)); return new Result<SendInfoResultDTO>().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();
}
} }

5
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 @Mapper
public interface InfoProfileDao extends BaseDao<InfoProfileEntity> { public interface InfoProfileDao extends BaseDao<InfoProfileEntity> {
int addReadTotal(String infoId);
InfoProfileEntity selectByInfoId(String infoId);
} }

13
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.commons.mybatis.dao.BaseDao;
import com.epmet.entity.InfoReceiversEntity; import com.epmet.entity.InfoReceiversEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 消息接收人记录表 * 消息接收人记录表
@ -29,5 +30,15 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface InfoReceiversDao extends BaseDao<InfoReceiversEntity> { public interface InfoReceiversDao extends BaseDao<InfoReceiversEntity> {
/**
* 消息的某一个接收人记录
*
* @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);
} }

33
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/InfoService.java

@ -18,6 +18,9 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; 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.form.SendInfoFormDTO;
import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.entity.InfoEntity; import com.epmet.entity.InfoEntity;
@ -39,4 +42,34 @@ public interface InfoService extends BaseService<InfoEntity> {
* @date 2021/8/19 10:27 上午 * @date 2021/8/19 10:27 上午
*/ */
SendInfoResultDTO sendInfo(SendInfoFormDTO formDTO); 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);
} }

103
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.commons.tools.utils.Result;
import com.epmet.constant.UserMessageConstans; import com.epmet.constant.UserMessageConstans;
import com.epmet.dao.*; import com.epmet.dao.*;
import com.epmet.dto.form.OrgCommonDTO; import com.epmet.dto.form.*;
import com.epmet.dto.form.OrgStaffFormDTO;
import com.epmet.dto.form.RoleStaffIdFormDTO;
import com.epmet.dto.form.SendInfoFormDTO;
import com.epmet.dto.result.SendInfoResultDTO; import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.entity.*; import com.epmet.entity.*;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
@ -182,6 +179,104 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
return resultDTO; 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);
}
}
/** /**
* 查询架构里面的人 * 查询架构里面的人
* *

14
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoProfileDao.xml

@ -4,5 +4,19 @@
<mapper namespace="com.epmet.dao.InfoProfileDao"> <mapper namespace="com.epmet.dao.InfoProfileDao">
<update id="addReadTotal" parameterType="java.lang.String">
UPDATE info_profile
SET read_total = read_total + 1,
UPDATED_TIME = NOW()
WHERE
INFO_ID = #{infoId}
AND DEL_FLAG = '0'
</update>
<select id="selectByInfoId" parameterType="java.lang.String" resultType="com.epmet.entity.InfoProfileEntity">
select ip.*
from info_profile ip
where ip.del_flag='0'
and ip.info_id=#{infoId}
</select>
</mapper> </mapper>

11
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/InfoReceiversDao.xml

@ -3,6 +3,15 @@
<mapper namespace="com.epmet.dao.InfoReceiversDao"> <mapper namespace="com.epmet.dao.InfoReceiversDao">
<select id="selectInfoReceiver" parameterType="map" resultType="com.epmet.entity.InfoReceiversEntity">
SELECT
*
FROM
info_receivers ir
WHERE
ir.INFO_ID = #{infoId}
AND ir.STAFF_ID =#{userId}
AND ir.DEL_FLAG = '0'
</select>
</mapper> </mapper>
Loading…
Cancel
Save