|
|
@@ -1,95 +1,93 @@
|
|
|
-package cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
-
|
|
|
-import jakarta.validation.constraints.*;
|
|
|
-import jakarta.validation.*;
|
|
|
-import jakarta.servlet.http.*;
|
|
|
-import java.util.*;
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
-
|
|
|
-import cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet.vo.*;
|
|
|
-import cn.iocoder.yudao.module.iscs.dal.dataobject.lockcabinet.LockCabinetDO;
|
|
|
-import cn.iocoder.yudao.module.iscs.service.lockcabinet.LockCabinetService;
|
|
|
-
|
|
|
-@Tag(name = "管理后台 - 锁控机柜")
|
|
|
-@RestController
|
|
|
-@RequestMapping("/iscs/lock-cabinet")
|
|
|
-@Validated
|
|
|
-public class LockCabinetController {
|
|
|
-
|
|
|
- @Resource
|
|
|
- private LockCabinetService lockCabinetService;
|
|
|
-
|
|
|
- @PostMapping("/insertLockCabinet")
|
|
|
- @Operation(summary = "创建锁控机柜")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:create')")
|
|
|
- public CommonResult<Long> insertLockCabinet(@Valid @RequestBody LockCabinetSaveReqVO createReqVO) {
|
|
|
- return success(lockCabinetService.createLockCabinet(createReqVO));
|
|
|
- }
|
|
|
-
|
|
|
- @PutMapping("/updateLockCabinet")
|
|
|
- @Operation(summary = "更新锁控机柜")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:update')")
|
|
|
- public CommonResult<Boolean> updateLockCabinet(@Valid @RequestBody LockCabinetSaveReqVO updateReqVO) {
|
|
|
- lockCabinetService.updateLockCabinet(updateReqVO);
|
|
|
- return success(true);
|
|
|
- }
|
|
|
-
|
|
|
- @DeleteMapping("/deleteLockCabinetList")
|
|
|
- @Parameter(name = "ids", description = "编号", required = true)
|
|
|
- @Operation(summary = "批量删除锁控机柜")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:delete')")
|
|
|
- public CommonResult<Boolean> deleteLockCabinetList(@RequestParam("ids") List<Long> ids) {
|
|
|
- lockCabinetService.deleteLockCabinetListByIds(ids);
|
|
|
- return success(true);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/selectLockCabinetById")
|
|
|
- @Operation(summary = "获得锁控机柜")
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:query')")
|
|
|
- public CommonResult<LockCabinetRespVO> selectLockCabinetById(@RequestParam("id") Long id) {
|
|
|
- LockCabinetDO lockCabinet = lockCabinetService.getLockCabinet(id);
|
|
|
- return success(BeanUtils.toBean(lockCabinet, LockCabinetRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/getLockCabinetPage")
|
|
|
- @Operation(summary = "获得锁控机柜分页")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:query')")
|
|
|
- public CommonResult<PageResult<LockCabinetRespVO>> getLockCabinetPage(@Valid LockCabinetPageReqVO pageReqVO) {
|
|
|
- PageResult<LockCabinetDO> pageResult = lockCabinetService.getLockCabinetPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, LockCabinetRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/exportLockCabinetExcel")
|
|
|
- @Operation(summary = "导出锁控机柜 Excel")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:export')")
|
|
|
- @ApiAccessLog(operateType = EXPORT)
|
|
|
- public void exportLockCabinetExcel(@Valid LockCabinetPageReqVO pageReqVO,
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
- List<LockCabinetDO> list = lockCabinetService.getLockCabinetPage(pageReqVO).getList();
|
|
|
- // 导出 Excel
|
|
|
- ExcelUtils.write(response, "锁控机柜.xls", "数据", LockCabinetRespVO.class,
|
|
|
- BeanUtils.toBean(list, LockCabinetRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet.vo.LockCabinetPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet.vo.LockCabinetRespVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.lockcabinet.vo.LockCabinetSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.dal.dataobject.lockcabinet.LockCabinetDO;
|
|
|
+import cn.iocoder.yudao.module.iscs.service.lockcabinet.LockCabinetService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import jakarta.validation.Valid;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 锁控机柜")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/iscs/lock-cabinet")
|
|
|
+@Validated
|
|
|
+public class LockCabinetController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private LockCabinetService lockCabinetService;
|
|
|
+
|
|
|
+ @PostMapping("/insertLockCabinet")
|
|
|
+ @Operation(summary = "创建锁控机柜")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:create')")
|
|
|
+ public CommonResult<Long> insertLockCabinet(@Valid @RequestBody LockCabinetSaveReqVO createReqVO) {
|
|
|
+ return success(lockCabinetService.createLockCabinet(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/updateLockCabinet")
|
|
|
+ @Operation(summary = "更新锁控机柜")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:update')")
|
|
|
+ public CommonResult<Boolean> updateLockCabinet(@Valid @RequestBody LockCabinetSaveReqVO updateReqVO) {
|
|
|
+ lockCabinetService.updateLockCabinet(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/deleteLockCabinetList")
|
|
|
+ @Parameter(name = "ids", description = "编号", required = true)
|
|
|
+ @Operation(summary = "批量删除锁控机柜")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:delete')")
|
|
|
+ public CommonResult<Boolean> deleteLockCabinetList(@RequestParam("ids") List<Long> ids) {
|
|
|
+ lockCabinetService.deleteLockCabinetListByIds(ids);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/selectLockCabinetById")
|
|
|
+ @Operation(summary = "获得锁控机柜")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:query')")
|
|
|
+ public CommonResult<LockCabinetRespVO> selectLockCabinetById(@RequestParam("id") Long id) {
|
|
|
+ LockCabinetDO lockCabinet = lockCabinetService.getLockCabinet(id);
|
|
|
+ return success(BeanUtils.toBean(lockCabinet, LockCabinetRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getLockCabinetPage")
|
|
|
+ @Operation(summary = "获得锁控机柜分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:query')")
|
|
|
+ public CommonResult<PageResult<LockCabinetRespVO>> getLockCabinetPage(@Valid LockCabinetPageReqVO pageReqVO) {
|
|
|
+ PageResult<LockCabinetRespVO> pageResult = lockCabinetService.getLockCabinetPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, LockCabinetRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/exportLockCabinetExcel")
|
|
|
+ @Operation(summary = "导出锁控机柜 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:lock-cabinet:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportLockCabinetExcel(@Valid LockCabinetPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<LockCabinetRespVO> list = lockCabinetService.getLockCabinetPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "锁控机柜.xls", "数据", LockCabinetRespVO.class,
|
|
|
+ BeanUtils.toBean(list, LockCabinetRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|