package com.gkhy.safePlatform.safeCheck.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gkhy.safePlatform.account.rpc.apimodel.AccountUserService; import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.E; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.AusinessException; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.safeCheck.model.dto.req.*; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointPageRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRegionPageRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRegionRespDTO; import com.gkhy.safePlatform.safeCheck.service.SafeCheckBaseManagerService; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List; /** * @description 巡检点 */ @RestController @RequestMapping("/safeCheckPoint") public class SafeCheckPointController { @Autowired private SafeCheckBaseManagerService safeCheckBaseManagerService; /** * @description 新增巡检点 */ @PostMapping("/insert/savePoint") public ResultVO savePoint(Authentication authentication, @RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckBaseManagerService.savePoint(currentUser, safeCheckPointReqDTO); return new ResultVO<>("200","新增巡检点成功"); } /*** * @description 根据巡检点id删除巡检点 */ @PostMapping("/delete/deletePointById") public ResultVO deletePointById(Authentication authentication,@RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){ Long id = safeCheckPointReqDTO.getId(); ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckBaseManagerService.deletePointById(currentUser, id); ResultVO resultVO = new ResultVO<>("200","删除巡检点成功"); return resultVO; } /** * @description 根据id更新巡检点 */ @PostMapping("/update/updatePointById") public ResultVO updatePointById(Authentication authentication, @RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckBaseManagerService.updatePointById(currentUser, safeCheckPointReqDTO); ResultVO resultVO = new ResultVO<>("200","更新巡检点成功"); return resultVO; } /** * @description 查询所有数据并进行分页展示 */ @PostMapping("/select/listPointByPage") public ResultVO> listPointByPage(Authentication authentication,@RequestBody SafeCheckPointPageReqDTO safeCheckPointPageReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = safeCheckPointPageReqDTO.getPageIndex(); Integer pageSize = safeCheckPointPageReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); pageInfo = safeCheckBaseManagerService.listPointByPage(pageInfo,safeCheckPointPageReqDTO,currentUser); return new ResultVO<>(ResultCodes.OK,pageInfo); } /** * @description 根据巡检点id查询数据 */ @PostMapping("/select/getPointById") public ResultVO getPointById(@RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){ Long id = safeCheckPointReqDTO.getId(); SafeCheckPointRespDTO pointRespDTO = safeCheckBaseManagerService.getPointById(id); ResultVO resultVO = new ResultVO<>(ResultCodes.OK,pointRespDTO); return resultVO; } /** * @description 获取所有巡检点、巡检区域、巡检rfid的id值 */ @PostMapping("/select/getPointRegionRfidId") public ResultVO> getPointRegionRfidId(){ List pointRespDTOS = safeCheckBaseManagerService.getPointRegionRfidId(); ResultVO resultVO = new ResultVO<>(ResultCodes.OK,pointRespDTOS); return resultVO; } }