package com.supersavedriving.driver.modular.system.api;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
|
import com.supersavedriving.driver.core.util.ToolUtil;
|
import com.supersavedriving.driver.modular.system.model.SystemBulletin;
|
import com.supersavedriving.driver.modular.system.model.SystemBulletinUser;
|
import com.supersavedriving.driver.modular.system.model.SystemMessage;
|
import com.supersavedriving.driver.modular.system.service.IDriverService;
|
import com.supersavedriving.driver.modular.system.service.ISystemBulletinService;
|
import com.supersavedriving.driver.modular.system.service.ISystemBulletinUserService;
|
import com.supersavedriving.driver.modular.system.service.ISystemMessageService;
|
import com.supersavedriving.driver.modular.system.util.ResultUtil;
|
import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
|
/**
|
* 系统消息
|
* @author pzb
|
* @Date 2023/2/10 15:35
|
*/
|
@RestController
|
@RequestMapping("")
|
public class SystemMessageController {
|
|
@Autowired
|
private ISystemMessageService systemMessageService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private ISystemBulletinService systemBulletinService;
|
|
@Autowired
|
private ISystemBulletinUserService systemBulletinUserService;
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/systemMessage/querySystemMessageList")
|
// @ServiceLog(name = "获取系统消息列表", url = "/api/systemMessage/querySystemMessageList")
|
@ApiOperation(value = "获取系统消息列表", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<List<SystemMessageWarpper>> querySystemMessageList(Integer pageNum, Integer size){
|
if(ToolUtil.isEmpty(pageNum)){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
|
}
|
if(ToolUtil.isEmpty(size)){
|
return ResponseWarpper.success(ResultUtil.paranErr("size"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
List<SystemMessageWarpper> systemMessageWarppers = systemMessageService.querySystemMessageList(uid, pageNum, size);
|
return ResponseWarpper.success(systemMessageWarppers);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/systemMessage/readSystems")
|
// @ServiceLog(name = "阅读系统消息", url = "/api/systemMessage/readSystems")
|
@ApiOperation(value = "阅读系统消息", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "消息id,多个逗号分隔", name = "ids", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper readSystems(String ids){
|
if(ToolUtil.isEmpty(ids)){
|
return ResponseWarpper.success(ResultUtil.paranErr("ids"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
systemMessageService.readSystems(uid, ids);
|
return ResponseWarpper.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/systemMessage/clearSystemMessage")
|
// @ServiceLog(name = "清空系统消息和公告", url = "/api/systemMessage/clearSystemMessage")
|
@ApiOperation(value = "清空系统消息和公告", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper clearSystemMessage(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
systemMessageService.clearSystemMessage(uid);
|
systemBulletinService.clearSystemBulletinUser(uid);
|
return ResponseWarpper.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/systemMessage/queryUnreadQuantity")
|
// @ServiceLog(name = "获取未读消息数量", url = "/api/systemMessage/queryUnreadQuantity")
|
@ApiOperation(value = "获取未读消息数量", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<Integer> queryUnreadQuantity(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
int count = systemMessageService.selectCount(new EntityWrapper<SystemMessage>().eq("userType", 2).eq("userId", uid).eq("isRead", 0).eq("status", 1));
|
int count1 = systemBulletinUserService.selectCount(new EntityWrapper<SystemBulletinUser>().eq("userType", 2).eq("userId", uid).eq("isRead", 0).eq("status", 1));
|
return ResponseWarpper.success(count + count1);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
}
|