|
@@ -1,10 +1,14 @@
|
|
package com.xy.service;
|
|
package com.xy.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xy.dto.MsgUserMessageDto;
|
|
import com.xy.dto.MsgUserMessageDto;
|
|
|
|
+import com.xy.entity.MsgSysMonitorNotice;
|
|
import com.xy.entity.MsgUserMessage;
|
|
import com.xy.entity.MsgUserMessage;
|
|
|
|
+import com.xy.enums.MsgReadStatus;
|
|
import com.xy.mapper.MsgUserMessageMapper;
|
|
import com.xy.mapper.MsgUserMessageMapper;
|
|
import com.xy.utils.*;
|
|
import com.xy.utils.*;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -14,6 +18,11 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+import static com.xy.utils.Beans.copy;
|
|
import static com.xy.utils.PlusBeans.toIPage;
|
|
import static com.xy.utils.PlusBeans.toIPage;
|
|
import static com.xy.utils.PlusBeans.toPageBean;
|
|
import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
|
|
|
@@ -31,6 +40,37 @@ import static com.xy.utils.PlusBeans.toPageBean;
|
|
@Api(tags = "用户消息")
|
|
@Api(tags = "用户消息")
|
|
public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper, MsgUserMessage> implements MsgUserMessageService {
|
|
public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper, MsgUserMessage> implements MsgUserMessageService {
|
|
|
|
|
|
|
|
+ private MsgSysMonitorNoticeServiceImpl msgSysMonitorNoticeService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation("消息详情")
|
|
|
|
+ public R<MsgUserMessageDto.Vo> obj(MsgUserMessageDto.Vo vo) {
|
|
|
|
+ MsgUserMessageDto.SelectList selectList = copy(MsgUserMessageDto.SelectList.class, vo);
|
|
|
|
+ List<MsgUserMessageDto.Vo> list = list(selectList).getData();
|
|
|
|
+ if (Emptys.check(list)) {
|
|
|
|
+ MsgUserMessageDto.Vo myMsg = list.get(0);
|
|
|
|
+ //更新已读
|
|
|
|
+ this.updateById(new MsgUserMessage().setId(myMsg.getId()).setReadState(MsgReadStatus.READ.getCode().toString()));
|
|
|
|
+ return R.ok(myMsg);
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public R<List<MsgUserMessageDto.Vo>> list(MsgUserMessageDto.SelectList selectList) {
|
|
|
|
+ LambdaQueryWrapper<MsgUserMessage> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(selectList, MsgUserMessage.class).build();
|
|
|
|
+ List<MsgUserMessage> list = list(lambdaQueryWrapper);
|
|
|
|
+ return R.ok(copy(MsgUserMessageDto.Vo.class, list));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("我的消息-未读数量")
|
|
|
|
+ @Override
|
|
|
|
+ public R<Long> myMsgUnRead() {
|
|
|
|
+ long count = this.count(Wrappers.<MsgUserMessage>lambdaQuery()
|
|
|
|
+ .eq(MsgUserMessage::getUserId, AuthorizeUtils.getLoginId(Long.class))
|
|
|
|
+ .eq(MsgUserMessage::getReadState, MsgReadStatus.UN_READ.getCode()));
|
|
|
|
+ return R.ok(count);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
@ApiOperation("我的消息")
|
|
@ApiOperation("我的消息")
|
|
@Override
|
|
@Override
|
|
@@ -40,9 +80,26 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
|
|
LambdaQueryWrapper<MsgUserMessage> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, MsgUserMessage.class)
|
|
LambdaQueryWrapper<MsgUserMessage> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, MsgUserMessage.class)
|
|
.ge(MsgUserMessage::getCreateTime, page.getBeginCreateTime())
|
|
.ge(MsgUserMessage::getCreateTime, page.getBeginCreateTime())
|
|
.le(MsgUserMessage::getCreateTime, page.getEndCreateTime())
|
|
.le(MsgUserMessage::getCreateTime, page.getEndCreateTime())
|
|
- .build();
|
|
|
|
|
|
+ .build().orderByAsc(MsgUserMessage::getPriority);
|
|
IPage<MsgUserMessage> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
IPage<MsgUserMessage> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
- return R.ok(toPageBean(MsgUserMessageDto.PageVO.class, iPage));
|
|
|
|
|
|
+ PageBean<MsgUserMessageDto.PageVO> pageVo = toPageBean(MsgUserMessageDto.PageVO.class, iPage);
|
|
|
|
+ List<MsgUserMessageDto.PageVO> records = pageVo.getRecords();
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
+ List<Integer> msgIds = records.stream().map(MsgUserMessageDto.PageVO::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.PageVO record : records) {
|
|
|
|
+ Integer msgId = record.getMsgId();
|
|
|
|
+ MsgSysMonitorNotice msgSysMonitorNotice = msgSysMonitorNoticeMap.get(msgId);
|
|
|
|
+ if (msgSysMonitorNotice != null) {
|
|
|
|
+ record.setContent(msgSysMonitorNotice.getContent());
|
|
|
|
+ record.setTitle(msgSysMonitorNotice.getTitle());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.ok(pageVo);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("新增我的消息")
|
|
@ApiOperation("新增我的消息")
|