feat(resource): 已读和一键已读
parent
2efdbfe773
commit
af0638438c
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.system;
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.resource.domain.vo.AdviceVo;
|
import com.mcwl.resource.domain.vo.AdviceVo;
|
||||||
|
@ -22,13 +22,38 @@ import java.util.List;
|
||||||
* 消息通知
|
* 消息通知
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("system/advice")
|
@RequestMapping("advice")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Api(tags = "消息通知")
|
@Api(tags = "消息通知")
|
||||||
public class SysAdviceController {
|
public class SysAdviceController {
|
||||||
|
|
||||||
private final ISysAdviceService sysAdviceService;
|
private final ISysAdviceService sysAdviceService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已读
|
||||||
|
*/
|
||||||
|
@GetMapping("read")
|
||||||
|
@ApiOperation(value = "已读")
|
||||||
|
public R<String> read(@Valid
|
||||||
|
@NotNull(message = "消息id不能为空")
|
||||||
|
@ApiParam(value = "消息id", required = true)
|
||||||
|
Long adviceId) {
|
||||||
|
sysAdviceService.read(adviceId);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一键已读
|
||||||
|
*/
|
||||||
|
@GetMapping("readAll")
|
||||||
|
@ApiOperation(value = "一键已读")
|
||||||
|
public R<String> readAll() {
|
||||||
|
sysAdviceService.readAll();
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有通知
|
* 获取所有通知
|
||||||
*/
|
*/
|
|
@ -7,6 +7,8 @@ import com.mcwl.resource.domain.vo.AttentionAdviceVo;
|
||||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||||
import com.mcwl.resource.domain.vo.LikeAdviceVo;
|
import com.mcwl.resource.domain.vo.LikeAdviceVo;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,4 +25,11 @@ public interface ISysAdviceService extends IService<SysAdvice> {
|
||||||
List<LikeAdviceVo> getLikeMsg(Integer productType);
|
List<LikeAdviceVo> getLikeMsg(Integer productType);
|
||||||
|
|
||||||
List<AttentionAdviceVo> getAttentionMsg();
|
List<AttentionAdviceVo> getAttentionMsg();
|
||||||
|
|
||||||
|
void read(Long adviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一键已读
|
||||||
|
*/
|
||||||
|
void readAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
@ -223,6 +224,35 @@ public class SysAdviceServiceImpl extends ServiceImpl<SysAdviceMapper, SysAdvice
|
||||||
return attentionAdviceVoList;
|
return attentionAdviceVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Long adviceId) {
|
||||||
|
SysAdvice sysAdvice = baseMapper.selectById(adviceId);
|
||||||
|
|
||||||
|
if (Objects.isNull(sysAdvice)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long receiverId = sysAdvice.getReceiverId();
|
||||||
|
if (!Objects.equals(SecurityUtils.getUserId(), receiverId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sysAdvice.setIsRead(1);
|
||||||
|
baseMapper.updateById(sysAdvice);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readAll() {
|
||||||
|
List<SysAdvice> sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||||
|
.eq(SysAdvice::getIsRead, 0)
|
||||||
|
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId()));
|
||||||
|
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||||
|
sysAdvice.setIsRead(1);
|
||||||
|
baseMapper.updateById(sysAdvice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void postConstruct() {
|
public void postConstruct() {
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue