| package com.supersavedriving.driver.modular.system.api; | 
|   | 
| import com.supersavedriving.driver.core.common.annotion.ServiceLog; | 
| import com.supersavedriving.driver.core.util.ToolUtil; | 
| import com.supersavedriving.driver.modular.system.service.IDriverService; | 
| 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; | 
|   | 
|   | 
|   | 
|   | 
|     @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, HttpServletRequest request){ | 
|         if(ToolUtil.isEmpty(pageNum)){ | 
|             return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); | 
|         } | 
|         if(ToolUtil.isEmpty(size)){ | 
|             return ResponseWarpper.success(ResultUtil.paranErr("size")); | 
|         } | 
|         try { | 
|             Integer uid = driverService.getUserByRequset(request); | 
|             if(null == uid){ | 
|                 return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){ | 
|         if(ToolUtil.isEmpty(ids)){ | 
|             return ResponseWarpper.success(ResultUtil.paranErr("ids")); | 
|         } | 
|         try { | 
|             Integer uid = driverService.getUserByRequset(request); | 
|             if(null == uid){ | 
|                 return ResponseWarpper.success(ResultUtil.tokenErr()); | 
|             } | 
|             systemMessageService.readSystems(uid, ids); | 
|             return ResponseWarpper.success(); | 
|         }catch (Exception e){ | 
|             e.printStackTrace(); | 
|             return new ResponseWarpper(500, e.getMessage()); | 
|         } | 
|     } | 
| } |