|
|
@@ -1,95 +1,110 @@
|
|
|
-package cn.iocoder.yudao.module.iscs.controller.admin.key;
|
|
|
-
|
|
|
-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.key.vo.*;
|
|
|
-import cn.iocoder.yudao.module.iscs.dal.dataobject.key.KeyDO;
|
|
|
-import cn.iocoder.yudao.module.iscs.service.key.KeyService;
|
|
|
-
|
|
|
-@Tag(name = "管理后台 - 钥匙")
|
|
|
-@RestController
|
|
|
-@RequestMapping("/iscs/key")
|
|
|
-@Validated
|
|
|
-public class KeyController {
|
|
|
-
|
|
|
- @Resource
|
|
|
- private KeyService keyService;
|
|
|
-
|
|
|
- @PostMapping("/insertKey")
|
|
|
- @Operation(summary = "创建钥匙")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:create')")
|
|
|
- public CommonResult<Long> insertKey(@Valid @RequestBody KeySaveReqVO createReqVO) {
|
|
|
- return success(keyService.createKey(createReqVO));
|
|
|
- }
|
|
|
-
|
|
|
- @PutMapping("/updateKey")
|
|
|
- @Operation(summary = "更新钥匙")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:update')")
|
|
|
- public CommonResult<Boolean> updateKey(@Valid @RequestBody KeySaveReqVO updateReqVO) {
|
|
|
- keyService.updateKey(updateReqVO);
|
|
|
- return success(true);
|
|
|
- }
|
|
|
-
|
|
|
- @DeleteMapping("/deleteKeyList")
|
|
|
- @Parameter(name = "ids", description = "编号", required = true)
|
|
|
- @Operation(summary = "批量删除钥匙")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:delete')")
|
|
|
- public CommonResult<Boolean> deleteKeyList(@RequestParam("ids") List<Long> ids) {
|
|
|
- keyService.deleteKeyListByIds(ids);
|
|
|
- return success(true);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/selectKeyById")
|
|
|
- @Operation(summary = "获得钥匙")
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:query')")
|
|
|
- public CommonResult<KeyRespVO> selectKeyById(@RequestParam("id") Long id) {
|
|
|
- KeyDO key = keyService.getKey(id);
|
|
|
- return success(BeanUtils.toBean(key, KeyRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/getKeyPage")
|
|
|
- @Operation(summary = "获得钥匙分页")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:query')")
|
|
|
- public CommonResult<PageResult<KeyRespVO>> getKeyPage(@Valid KeyPageReqVO pageReqVO) {
|
|
|
- PageResult<KeyDO> pageResult = keyService.getKeyPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, KeyRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/exportKeyExcel")
|
|
|
- @Operation(summary = "导出钥匙 Excel")
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:key:export')")
|
|
|
- @ApiAccessLog(operateType = EXPORT)
|
|
|
- public void exportKeyExcel(@Valid KeyPageReqVO pageReqVO,
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
- List<KeyDO> list = keyService.getKeyPage(pageReqVO).getList();
|
|
|
- // 导出 Excel
|
|
|
- ExcelUtils.write(response, "钥匙.xls", "数据", KeyRespVO.class,
|
|
|
- BeanUtils.toBean(list, KeyRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package cn.iocoder.yudao.module.iscs.controller.admin.key;
|
|
|
+
|
|
|
+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.key.vo.KeyPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.key.vo.KeyRespVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.key.vo.KeySaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.dal.dataobject.key.KeyDO;
|
|
|
+import cn.iocoder.yudao.module.iscs.service.key.KeyService;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+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/key")
|
|
|
+@Validated
|
|
|
+public class KeyController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private KeyService keyService;
|
|
|
+
|
|
|
+ @PostMapping("/insertKey")
|
|
|
+ @Operation(summary = "创建钥匙")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:create')")
|
|
|
+ public CommonResult<Long> insertKey(@Valid @RequestBody KeySaveReqVO createReqVO) {
|
|
|
+ return success(keyService.createKey(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/updateKey")
|
|
|
+ @Operation(summary = "更新钥匙")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:update')")
|
|
|
+ public CommonResult<Boolean> updateKey(@Valid @RequestBody KeySaveReqVO updateReqVO) {
|
|
|
+ keyService.updateKey(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/deleteKeyList")
|
|
|
+ @Parameter(name = "ids", description = "编号", required = true)
|
|
|
+ @Operation(summary = "批量删除钥匙")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:delete')")
|
|
|
+ public CommonResult<Boolean> deleteKeyList(@RequestParam("ids") List<Long> ids) {
|
|
|
+ keyService.deleteKeyListByIds(ids);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/selectKeyById")
|
|
|
+ @Operation(summary = "获得钥匙")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:query')")
|
|
|
+ public CommonResult<KeyRespVO> selectKeyById(@RequestParam("id") Long id) {
|
|
|
+ KeyDO key = keyService.getKey(id);
|
|
|
+ return success(BeanUtils.toBean(key, KeyRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getKeyPage")
|
|
|
+ @Operation(summary = "获得钥匙分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:query')")
|
|
|
+ public CommonResult<PageResult<KeyRespVO>> getKeyPage(@Valid KeyPageReqVO pageReqVO) {
|
|
|
+ PageResult<KeyRespVO> pageResult = keyService.getKeyPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, KeyRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/exportKeyExcel")
|
|
|
+ @Operation(summary = "导出钥匙 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportKeyExcel(@Valid KeyPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<KeyRespVO> list = keyService.getKeyPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "钥匙.xls", "数据", KeyRespVO.class,
|
|
|
+ BeanUtils.toBean(list, KeyRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/selectKeyByNfc")
|
|
|
+ @Operation(summary = "通过NFC获取钥匙详细信息-开放不登陆情况下可调用")
|
|
|
+ @Parameter(name = "nfc", description = "nfc")
|
|
|
+ public CommonResult<KeyRespVO> selectKeyByNfc(String nfc) {
|
|
|
+ KeyDO one = keyService.getOne(Wrappers.<KeyDO>lambdaQuery()
|
|
|
+ .eq(KeyDO::getKeyNfc, nfc));
|
|
|
+ return CommonResult.success(BeanUtils.toBean(one, KeyRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/insertKeyByCabinet")
|
|
|
+ @Operation(summary = "机柜录入钥匙")
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:key:create')")
|
|
|
+ public CommonResult<Long> insertKeyByCabinet(@Valid @RequestBody KeySaveReqVO createReqVO) {
|
|
|
+ return success(keyService.insertKeyByCabinet(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|