REQ-1858: 解决统计未读数据和分页查询数据数据不匹配的问题(两边的查询条件没有保持一致)
This commit is contained in:
parent
63fe60b5ed
commit
52f1681fe5
@ -49,7 +49,9 @@ import cn.axzo.msg.center.domain.request.InsideCmsReadMsgReq;
|
||||
import cn.axzo.msg.center.inside.notices.event.SendMessageEvent;
|
||||
import cn.axzo.msg.center.inside.notices.service.MessageRecordService;
|
||||
import cn.axzo.msg.center.message.service.GeneralMessageMapperService;
|
||||
import cn.axzo.msg.center.service.dto.IdentifyAndReceiveType;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import cn.axzo.msg.center.utils.PersonIdentityUtil;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorLevel;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorType;
|
||||
@ -438,9 +440,12 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
@Override
|
||||
public PageResult<MessageNewRes> pageMsgInfo(CmsMsgQueryReq req, Long personId, List<IdentityDTO> identities) {
|
||||
IPage page = req.toPage();
|
||||
ArrayList<Integer> states = buildStates(req);
|
||||
List<Integer> states = CollectionUtils.isEmpty(req.getStates()) ? buildStates(req) : req.knownStateCodes();
|
||||
CmsMsgQueryReqDTO param=BeanConvertUtils.copyBean(req, CmsMsgQueryReqDTO.class);
|
||||
IPage<MessageNewResDTO> iPage = messageRecordDao.pageMsgInfo(param, page, personId, states, identities);
|
||||
List<IdentifyAndReceiveType> convertedIdentifies = identities.stream()
|
||||
.map(i -> new IdentifyAndReceiveType(i, PersonIdentityUtil.toReceiveType(i.getType())))
|
||||
.collect(Collectors.toList());
|
||||
IPage<MessageNewResDTO> iPage = messageRecordDao.pageMsgInfo(param, page, personId, states, convertedIdentifies);
|
||||
return convertPageMessageNewRes(iPage);
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +98,12 @@ public class GeneralMessageOldServiceImpl implements GeneralMessageOldService {
|
||||
if (CollectionUtils.isEmpty(request.getExcludeMsgIds())) {
|
||||
request.setExcludeMsgIds(messageSendTwiceRecordService.listByPerson(request.getPersonId()));
|
||||
}
|
||||
// 为了和统计未读的接口保持一致的逻辑
|
||||
List<Long> moduleIds = messageModuleService.listModuleIdByBizType(ModuleBizTypeEnum.CONSTRUCTION);
|
||||
List<Long> relationIds = messageRelationService.listRelationIds(moduleIds);
|
||||
request.setStates(MsgStateEnum.unreadStates());
|
||||
request.setRelationIds(relationIds);
|
||||
|
||||
PageResult<MessageNewRes> result = messageCoreService.listMsgInfo(request);
|
||||
if (CollectionUtils.isEmpty(result.getData())) {
|
||||
return PageHelperUtil.emptyPage(request.getPage(), request.getPageSize());
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import cn.axzo.basics.common.page.PageRequest;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* @author : liuchuntao
|
||||
@ -61,4 +66,23 @@ public class CmsMsgQueryReq extends PageRequest {
|
||||
* 待排除的消息id
|
||||
*/
|
||||
private List<Long> excludeMsgIds;
|
||||
/**
|
||||
* 查询的状态
|
||||
*/
|
||||
private List<MsgStateEnum> states;
|
||||
/**
|
||||
* 关系id
|
||||
*/
|
||||
private List<Long> relationIds;
|
||||
|
||||
public List<Integer> knownStateCodes() {
|
||||
if (states == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return states.stream()
|
||||
.map(MsgStateEnum::getCode)
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.msg.center.service.dto;
|
||||
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IdentifyAndReceiveType {
|
||||
private IdentityDTO identity;
|
||||
private ReceiveTypeEnum receiveType;
|
||||
}
|
||||
@ -16,7 +16,7 @@ import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import cn.axzo.msg.center.domain.request.InsideCmsReadMsgReq;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import cn.axzo.msg.center.service.dto.IdentifyAndReceiveType;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -89,7 +89,7 @@ public class MessageRecordDao extends
|
||||
|
||||
public IPage<MessageNewResDTO> pageMsgInfo(
|
||||
CmsMsgQueryReqDTO req, IPage page, Long personId,
|
||||
List<Integer> states, List<IdentityDTO> identities) {
|
||||
List<Integer> states, List<IdentifyAndReceiveType> identities) {
|
||||
return baseMapper.pageMsgInfo(req, page, personId, states, identities);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.dto.UpdateReadDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.service.dto.IdentifyAndReceiveType;
|
||||
import cn.axzo.msg.center.service.dto.IdentityDTO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -34,7 +35,7 @@ public interface MessageRecordMapper extends BaseMapper<MessageRecord>{
|
||||
IPage page,
|
||||
@Param("personId") Long personId,
|
||||
@Param("states") List<Integer> states,
|
||||
@Param("identifies") List<IdentityDTO> identities);
|
||||
@Param("identifies") List<IdentifyAndReceiveType> identities);
|
||||
|
||||
IPage<MessageNewResDTO> mixIdentityPageMsgInfo(@Param("req") CmsMsgQueryReqDTO req, IPage page,
|
||||
@Param("identityIds") List<Long> identityIds, @Param("personId") Long personId,
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
and record.is_delete = 0
|
||||
and (
|
||||
<foreach collection="identifies" item="item" separator="OR">
|
||||
(record.to_id = #{item.id} AND record.receive_type = #{item.type.code})
|
||||
(record.to_id = #{item.identity.id} AND record.receive_type = #{item.receiveType.code})
|
||||
</foreach>
|
||||
)
|
||||
<if test="states != null and states.size > 0">
|
||||
@ -65,6 +65,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="req.relationIds != null and req.relationIds.size > 0">
|
||||
and record.relation_id in
|
||||
<foreach close=")" collection="req.relationIds" index="index" item="item" open="(" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="req.excludeMsgIds != null and req.excludeMsgIds.size > 0">
|
||||
and record.id not in
|
||||
<foreach close=")" collection="req.excludeMsgIds" index="index" item="item" open="(" separator=",">
|
||||
|
||||
@ -39,4 +39,8 @@ public class CmsMsgQueryReqDTO extends PageRequest {
|
||||
* 待排除的消息id
|
||||
*/
|
||||
private List<Long> excludeMsgIds;
|
||||
/**
|
||||
* 关系id
|
||||
*/
|
||||
private List<Long> relationIds;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user