Browse Source

通知已读未读列表查询

master
sunyuchao 4 years ago
parent
commit
386001d926
  1. 3
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/AddNoticeFormDTO.java
  2. 3
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/EditNoticeFormDTO.java
  3. 21
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeReadListFormDTO.java
  4. 51
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeReadListResultDTO.java
  5. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java
  6. 16
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeReafdRecordController.java
  7. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeReafdRecordDao.java
  8. 11
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeReafdRecordService.java
  9. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeService.java
  10. 66
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReafdRecordServiceImpl.java
  11. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java
  12. 10
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeReafdRecordDao.xml

3
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/AddNoticeFormDTO.java → epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/AddNoticeFormDTO.java

@ -1,5 +1,6 @@
package com.epmet.resi.group.dto.topic.form;
package com.epmet.resi.group.dto.notice.form;
import com.epmet.resi.group.dto.topic.form.FileDTO;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

3
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/EditNoticeFormDTO.java → epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/EditNoticeFormDTO.java

@ -1,5 +1,6 @@
package com.epmet.resi.group.dto.topic.form;
package com.epmet.resi.group.dto.notice.form;
import com.epmet.resi.group.dto.topic.form.FileDTO;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

21
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeReadListFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.resi.group.dto.notice.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Author sun
* @Description 通知已读未读列表查询-接口入参
*/
@Data
public class NoticeReadListFormDTO {
/**
* 通知Id
*/
@NotBlank(message = "通知Id不能为空",groups = {NoticeReadListFormDTO.List.class})
private String noticeId;
public interface List{}
}

51
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeReadListResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.resi.group.dto.notice.result;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author sun
* @Description 通知已读未读列表查询-接口返参
*/
@Data
public class NoticeReadListResultDTO implements Serializable {
private static final long serialVersionUID = 6136787210623326830L;
/**
* 已读人员数
*/
private Integer readCount;
/**
* 未读人员数
*/
private Integer unReadCount;
/**
* 已读列表
*/
private List<NoticeReafdRecord> readList = new ArrayList<>();
/**
* 未读列表
*/
private List<NoticeReafdRecord> unReadList = new ArrayList<>();
@NoArgsConstructor
@Data
public static class NoticeReafdRecord {
/**
* 用户Id
*/
private String userId;
/**
* 用户姓名(真实姓名)
*/
private String userName;
/**
* 用户头像
*/
private String userHeadPhoto;
}
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeController.java

@ -30,8 +30,8 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.modules.notice.excel.NoticeExcel;
import com.epmet.modules.notice.service.NoticeService;
import com.epmet.resi.group.dto.notice.NoticeDTO;
import com.epmet.resi.group.dto.topic.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.topic.form.EditNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.EditNoticeFormDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

16
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeReafdRecordController.java

@ -17,7 +17,9 @@
package com.epmet.modules.notice.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
@ -28,6 +30,8 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.modules.notice.excel.NoticeReafdRecordExcel;
import com.epmet.modules.notice.service.NoticeReafdRecordService;
import com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO;
import com.epmet.resi.group.dto.notice.form.NoticeReadListFormDTO;
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -91,4 +95,16 @@ public class NoticeReafdRecordController {
ExcelUtils.exportExcelToTarget(response, null, list, NoticeReafdRecordExcel.class);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 通知已读未读列表查询
**/
@PostMapping(value = "noticereadlist")
public Result<NoticeReadListResultDTO> noticeReadList(@LoginUser TokenDto tokenDto, @RequestBody NoticeReadListFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, NoticeReadListFormDTO.List.class);
return new Result<NoticeReadListResultDTO>().ok(noticeReafdRecordService.noticeReadList(tokenDto, formDTO));
}
}

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeReafdRecordDao.java

@ -19,9 +19,12 @@ package com.epmet.modules.notice.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.notice.entity.NoticeReafdRecordEntity;
import com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 小组通知组成员阅读记录表
*
@ -36,4 +39,10 @@ public interface NoticeReafdRecordDao extends BaseDao<NoticeReafdRecordEntity> {
* @Description 删除通知已读未读数据-物理删除
**/
void delByNoticeId(@Param("noticeId") String noticeId);
/**
* @Author sun
* @Description 根据通知Id查询组成员已读未读数据
**/
List<NoticeReafdRecordDTO> getByNoticeId(@Param("noticeId") String noticeId);
}

11
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeReafdRecordService.java

@ -19,8 +19,11 @@ package com.epmet.modules.notice.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.modules.notice.entity.NoticeReafdRecordEntity;
import com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO;
import com.epmet.resi.group.dto.notice.form.NoticeReadListFormDTO;
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO;
import java.util.List;
import java.util.Map;
@ -92,4 +95,12 @@ public interface NoticeReafdRecordService extends BaseService<NoticeReafdRecordE
* @date 2021-04-19
*/
void delete(String[] ids);
/**
* @param formDTO
* @return
* @Author sun
* @Description 通知已读未读列表查询
**/
NoticeReadListResultDTO noticeReadList(TokenDto tokenDto, NoticeReadListFormDTO formDTO);
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeService.java

@ -22,8 +22,8 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.modules.notice.entity.NoticeEntity;
import com.epmet.resi.group.dto.notice.NoticeDTO;
import com.epmet.resi.group.dto.topic.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.topic.form.EditNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.EditNoticeFormDTO;
import java.util.List;
import java.util.Map;

66
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeReafdRecordServiceImpl.java

@ -21,21 +21,31 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.modules.notice.dao.NoticeReafdRecordDao;
import com.epmet.modules.notice.entity.NoticeReafdRecordEntity;
import com.epmet.modules.notice.redis.NoticeReafdRecordRedis;
import com.epmet.modules.notice.service.NoticeReafdRecordService;
import com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO;
import com.epmet.resi.group.dto.notice.form.NoticeReadListFormDTO;
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* 小组通知组成员阅读记录表
@ -48,6 +58,8 @@ public class NoticeReafdRecordServiceImpl extends BaseServiceImpl<NoticeReafdRec
@Autowired
private NoticeReafdRecordRedis noticeReafdRecordRedis;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Override
public PageData<NoticeReafdRecordDTO> page(Map<String, Object> params) {
@ -101,4 +113,58 @@ public class NoticeReafdRecordServiceImpl extends BaseServiceImpl<NoticeReafdRec
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 通知已读未读列表查询
**/
@Override
public NoticeReadListResultDTO noticeReadList(TokenDto tokenDto, NoticeReadListFormDTO formDTO) {
NoticeReadListResultDTO resultDTO = new NoticeReadListResultDTO();
List<NoticeReadListResultDTO.NoticeReafdRecord> readList = new ArrayList<>();
List<NoticeReadListResultDTO.NoticeReafdRecord> unReadList = new ArrayList<>();
//1.根据通知Id查询组成员已读未读数据
List<NoticeReafdRecordDTO> list = baseDao.getByNoticeId(formDTO.getNoticeId());
//2.调用user服务,查询人员基础数据
List<String> userIdList = list.stream().map(NoticeReafdRecordDTO::getUserId).collect(Collectors.toList());
Result<List<UserBaseInfoResultDTO>> result = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList);
if (!result.success()){
throw new RenException("调用user服务,获取用户基础数据失败");
}
List<UserBaseInfoResultDTO> resultDTOList = result.getData();
//3.遍历封装数据并返回
list.forEach(l->{
StringBuffer name = new StringBuffer();
StringBuffer url = new StringBuffer();
resultDTOList.forEach(user->{
if(l.getUserId().equals(user.getUserId())){
name.append(user.getSurname()).append(user.getName());
url.append(user.getHeadImgUrl());
}
});
if("read".equals(l.getReadFlag())){
NoticeReadListResultDTO.NoticeReafdRecord read = new NoticeReadListResultDTO.NoticeReafdRecord();
read.setUserId(l.getUserId());
read.setUserName(name.toString());
read.setUserHeadPhoto(url.toString());
readList.add(read);
}else{
NoticeReadListResultDTO.NoticeReafdRecord unRead = new NoticeReadListResultDTO.NoticeReafdRecord();
unRead.setUserId(l.getUserId());
unRead.setUserName(name.toString());
unRead.setUserHeadPhoto(url.toString());
unReadList.add(unRead);
}
});
resultDTO.setReadCount(readList.size());
resultDTO.setUnReadCount(unReadList.size());
resultDTO.setReadList(readList);
resultDTO.setUnReadList(unReadList);
return resultDTO;
}
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java

@ -59,8 +59,8 @@ import com.epmet.modules.notice.service.NoticeService;
import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO;
import com.epmet.resi.group.dto.notice.NoticeDTO;
import com.epmet.resi.group.dto.topic.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.topic.form.EditNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.AddNoticeFormDTO;
import com.epmet.resi.group.dto.notice.form.EditNoticeFormDTO;
import com.epmet.resi.group.dto.topic.form.FileDTO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

10
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeReafdRecordDao.xml

@ -3,6 +3,16 @@
<mapper namespace="com.epmet.modules.notice.dao.NoticeReafdRecordDao">
<select id="getByNoticeId" resultType="com.epmet.resi.group.dto.notice.NoticeReafdRecordDTO">
SELECT
*
FROM
notice_reafd_record
WHERE
del_flag = '0'
AND notice_id = #{noticeId}
</select>
<delete id="delByNoticeId">
DELETE
FROM

Loading…
Cancel
Save