package com.gkhy.safePlatform.safeCheck.controller;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.annotation.RepeatedClick;
|
import com.gkhy.safePlatform.safeCheck.exception.RepeatedClickException;
|
import com.gkhy.safePlatform.safeCheck.model.dto.req.*;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRegionNameRespDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRfidNameRespDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRfidPageRepsDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRfidRespDTO;
|
import com.gkhy.safePlatform.safeCheck.service.SafeCheckBaseManagerService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.core.Authentication;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
@RestController
|
@RequestMapping("/SafeCheckRfid")
|
public class SafeCheckRfidController {
|
|
@Autowired
|
private SafeCheckBaseManagerService safeCheckBaseManagerService;
|
|
/**
|
* @description 获取所有有效的RFID名称
|
*/
|
@RepeatedClick(errorMessage = "查询频率过快了")
|
@GetMapping("/select/listRfidName")
|
public ResultVO<List<SafeCheckRfidNameRespDTO>> listRfidName(){
|
List<SafeCheckRfidNameRespDTO> safeCheckRfidNameRespDTOS = safeCheckBaseManagerService.listRfidName();
|
return new ResultVO<>(ResultCodes.OK, safeCheckRfidNameRespDTOS);
|
}
|
|
|
/**
|
* @description 新增RFID
|
*/
|
@RepeatedClick(clickTime = 5,errorMessage = "数据已提交,请勿重复提交")
|
@PostMapping("/insert/saveRfid")
|
public ResultVO<String> saveRfid(Authentication authentication, @RequestBody SafeCheckRfidReqDTO safeCheckRfidReqDTO){
|
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
|
safeCheckBaseManagerService.saveRfid(currentUser, safeCheckRfidReqDTO);
|
ResultVO resultVO = new ResultVO<>("200","新增RFID成功");
|
return resultVO;
|
}
|
|
/***
|
* @description 根据RFID的id删除RFID
|
*/
|
@RepeatedClick(clickTime = 5,errorMessage = "数据已提交,请勿重复提交")
|
@PostMapping("/delete/deleteRfidById")
|
public ResultVO<String> deleteRfidByCode(Authentication authentication, @RequestBody SafeCheckRfidReqDTO safeCheckRfidReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
int rfidId = safeCheckRfidReqDTO.getId();
|
safeCheckBaseManagerService.deleteRfidById(currentUser, rfidId);
|
ResultVO resultVO = new ResultVO<>("200","删除RFID成功");
|
return resultVO;
|
}
|
|
|
/**
|
* @description 根据RFID的id更新RFID
|
*/
|
@RepeatedClick(clickTime = 5,errorMessage = "数据已提交,请勿重复提交")
|
@PostMapping("/update/updateRfidById")
|
public ResultVO<String> updateRfidById(Authentication authentication, @RequestBody SafeCheckRfidReqDTO safeCheckRfidReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckBaseManagerService.updateRfidById(currentUser, safeCheckRfidReqDTO);
|
ResultVO resultVO = new ResultVO<>("200","更新RFID成功");
|
return resultVO;
|
}
|
|
/**
|
* @description 根据RFID的id查询RFID
|
*/
|
@RepeatedClick(errorMessage = "查询频率过快了")
|
@PostMapping("/select/getRfidById")
|
public ResultVO<String> getRfidById(@RequestBody SafeCheckRfidReqDTO safeCheckRfidReqDTO){
|
int rfidId = safeCheckRfidReqDTO.getId();
|
SafeCheckRfidRespDTO safeCheckRfid = safeCheckBaseManagerService.getRfidById(rfidId);
|
ResultVO resultVO = new ResultVO<>(ResultCodes.OK,safeCheckRfid);
|
return resultVO;
|
}
|
|
|
/**
|
* @description 条件分页查询 没有条件就是全部查询
|
*/
|
@RepeatedClick(errorMessage = "查询频率过快了")
|
@PostMapping("/select/listRfidByPage")
|
public ResultVO<Page<SafeCheckRfidPageRepsDTO>> listRfidByPage(Authentication authentication,
|
@RequestBody SafeCheckRfidPageReqDTO safeCheckRfidPageReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
Integer pageIndex = safeCheckRfidPageReqDTO.getPageIndex();
|
Integer pageSize = safeCheckRfidPageReqDTO.getPageSize();
|
if (pageIndex == 0 || pageSize == 0){
|
throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
|
}
|
Page pageInfo = new Page(pageIndex, pageSize);
|
pageInfo = safeCheckBaseManagerService.listRfidByPage(pageInfo, safeCheckRfidPageReqDTO,currentUser);
|
|
return new ResultVO<>(ResultCodes.OK,pageInfo);
|
}
|
}
|