begin new project
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.SysNotice;
|
||||
import com.peanut.modules.common.service.SysNoticeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonSysNotice")
|
||||
@RequestMapping("common/sysNotice")
|
||||
public class SysNoticeController {
|
||||
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
|
||||
//消息通知列表
|
||||
@RequestMapping("/getSysNotices")
|
||||
public R getSysNotices(){
|
||||
LambdaQueryWrapper<SysNotice> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysNotice::getUserId, ShiroUtils.getUId());
|
||||
wrapper.like(SysNotice::getReadFlag,0);
|
||||
return R.ok().put("list",sysNoticeService.list(wrapper));
|
||||
}
|
||||
|
||||
//查看消息通知
|
||||
@RequestMapping("/readSysNotice")
|
||||
public R readSysNotice(@RequestBody Map<String,Object> params){
|
||||
String[] ids = params.get("id").toString().split(",");
|
||||
for (String id : ids) {
|
||||
SysNotice sysNotice = sysNoticeService.getById(id);
|
||||
sysNotice.setReadFlag(1);
|
||||
sysNotice.setUpdateTime(new Date());
|
||||
sysNoticeService.updateById(sysNotice);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user