|
@@ -1,5 +1,6 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -18,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -57,7 +59,7 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
|
MsgUserMessage msgUserMessage = new MsgUserMessage();
|
|
|
msgUserMessage.setId(myMsg.getId()).setReadState(MsgReadStatus.READ.getCode().toString());
|
|
|
if (ObjectUtil.isNotEmpty(myMsg)) {
|
|
|
- Long msgId = myMsg.getMsgId();
|
|
|
+ Integer msgId = myMsg.getMsgId();
|
|
|
MsgSysMonitorNotice msgSysMonitorNotice = msgSysMonitorNoticeService.getById(msgId);
|
|
|
if (ObjectUtil.isNotEmpty(msgSysMonitorNotice)) {
|
|
|
myMsg.setContent(msgSysMonitorNotice.getContent());
|
|
@@ -76,6 +78,55 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
|
return R.ok(copy(MsgUserMessageDto.Vo.class, list));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("我的消息-弹窗提示")
|
|
|
+ @PostMapping("myMsgPopUp")
|
|
|
+ public R<List<MsgUserMessageDto.Vo>> myMsgPopUp() {
|
|
|
+ List<MsgUserMessageDto.Vo> voList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<MsgUserMessage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(MsgUserMessage::getReadState, MsgReadStatus.UN_READ.getCode());
|
|
|
+ lambdaQueryWrapper.eq(MsgUserMessage::getUserId, AuthorizeUtils.getLoginId(Long.class));
|
|
|
+ lambdaQueryWrapper.eq(MsgUserMessage::getPopUp, Boolean.TRUE);
|
|
|
+ List<MsgUserMessage> list = this.list(lambdaQueryWrapper);
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return R.ok(voList);
|
|
|
+ }
|
|
|
+ List<MsgUserMessageDto.Vo> msgList = BeanUtil.copyToList(list, MsgUserMessageDto.Vo.class);
|
|
|
+
|
|
|
+ List<Integer> msgIds = list.stream().map(MsgUserMessage::getMsgId).collect(Collectors.toList());
|
|
|
+ List<MsgSysMonitorNotice> msgSysMonitorNotices = msgSysMonitorNoticeService.listByIds(msgIds);
|
|
|
+ if (CollUtil.isNotEmpty(msgSysMonitorNotices)) {
|
|
|
+ Map<Integer, MsgSysMonitorNotice> msgSysMonitorNoticeMap = msgSysMonitorNotices.stream().collect(Collectors.toMap(MsgSysMonitorNotice::getMsgId, i -> i));
|
|
|
+ for (MsgUserMessageDto.Vo record : msgList) {
|
|
|
+ Integer msgId = record.getMsgId();
|
|
|
+ MsgSysMonitorNotice msgSysMonitorNotice = msgSysMonitorNoticeMap.get(msgId);
|
|
|
+ if (msgSysMonitorNotice != null) {
|
|
|
+ record.setContent(msgSysMonitorNotice.getContent());
|
|
|
+ record.setTitle(msgSysMonitorNotice.getTitle());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(msgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("我的消息-标记已读")
|
|
|
+ @PostMapping("readById")
|
|
|
+ public R<Boolean> readById(@RequestBody MsgUserMessageDto.ReadOver dto) {
|
|
|
+ List<Long> ids = dto.getIds();
|
|
|
+ Long loginId = AuthorizeUtils.getLoginId(Long.class);
|
|
|
+ List<MsgUserMessage> msgUserMessages = this.list(Wrappers.<MsgUserMessage>lambdaQuery()
|
|
|
+ .eq(MsgUserMessage::getUserId, loginId)
|
|
|
+ .in(MsgUserMessage::getId, ids)
|
|
|
+ .eq(MsgUserMessage::getReadState, MsgReadStatus.UN_READ.getCode()));
|
|
|
+ if (CollUtil.isNotEmpty(msgUserMessages)) {
|
|
|
+ msgUserMessages.forEach(mum -> {
|
|
|
+ mum.setReadState(String.valueOf(MsgReadStatus.READ.getCode()));
|
|
|
+ });
|
|
|
+ this.saveOrUpdateBatch(msgUserMessages);
|
|
|
+ }
|
|
|
+ return R.ok(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("我的消息-未读数量")
|
|
|
@Override
|
|
|
public R<Long> myMsgUnRead() {
|
|
@@ -112,12 +163,17 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
|
Integer riskNum = getTotalMsgNum(myMsgPage(page));
|
|
|
page.setType("2");
|
|
|
Integer tradeNum = getTotalMsgNum(myMsgPage(page));
|
|
|
+ //其他
|
|
|
page.setType("3");
|
|
|
Integer otherNum = getTotalMsgNum(myMsgPage(page));
|
|
|
+ //费用
|
|
|
+ page.setType("4");
|
|
|
+ Integer costNum = getTotalMsgNum(myMsgPage(page));
|
|
|
MsgUserMessageDto.PageCount pageCount = new MsgUserMessageDto.PageCount()
|
|
|
.setAllNum(allNum)
|
|
|
.setOtherNum(otherNum)
|
|
|
.setRiskNum(riskNum)
|
|
|
+ .setCostNum(costNum)
|
|
|
.setTradeNum(tradeNum);
|
|
|
|
|
|
return R.ok(pageCount);
|
|
@@ -142,6 +198,11 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
|
if ("2".equals(type)) {
|
|
|
msgTypes.add(MsgType.TYPE8.getCode());
|
|
|
}
|
|
|
+ //费用
|
|
|
+ if ("4".equals(type)) {
|
|
|
+ msgTypes.add(MsgType.TYPE9.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
if ("3".equals(type)) {
|
|
|
msgTypesNotIn.add(MsgType.TYPE6.getCode());
|
|
|
msgTypesNotIn.add(MsgType.TYPE8.getCode());
|
|
@@ -176,6 +237,7 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
|
return R.ok(pageVo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@ApiOperation("新增我的消息")
|
|
|
@Override
|
|
|
public R save(@RequestBody @Validated MsgUserMessageDto.Save save) {
|