|
|
@@ -0,0 +1,98 @@
|
|
|
+package com.zhongshu.secretKey.server.core.controller.secret;
|
|
|
+
|
|
|
+import com.github.microservice.auth.security.annotations.ResourceAuth;
|
|
|
+import com.github.microservice.auth.security.type.AuthType;
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.base.IDParam;
|
|
|
+import com.zhongshu.secretKey.client.model.secret.SecretKeyModel;
|
|
|
+import com.zhongshu.secretKey.client.model.secret.SecretKeyParam;
|
|
|
+import com.zhongshu.secretKey.client.model.secret.SecretKeySearch;
|
|
|
+import com.zhongshu.secretKey.client.model.secret.SecretKeyUpdateParam;
|
|
|
+import com.zhongshu.secretKey.client.types.DataState;
|
|
|
+import com.zhongshu.secretKey.server.core.service.secret.SecretKeyService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.web.PageableDefault;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 管理
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/6/5
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/secretKey")
|
|
|
+@Tag(name = "秘钥管理-管理")
|
|
|
+public class SecretKeyController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SecretKeyService secretKeyService;
|
|
|
+
|
|
|
+// @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "生成一个ak、sk", description = "生成一个ak、sk")
|
|
|
+ @RequestMapping(value = "createSecret", method = {RequestMethod.POST})
|
|
|
+ public ResultContent createSecret(@RequestBody SecretKeyParam param) {
|
|
|
+ return this.secretKeyService.createSecret(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "编辑数据", description = "编辑数据")
|
|
|
+ @RequestMapping(value = "updateInfo", method = {RequestMethod.POST})
|
|
|
+ public ResultContent updateInfo(@RequestBody SecretKeyUpdateParam param) {
|
|
|
+ return this.secretKeyService.updateInfo(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "数据详情", description = "数据详情")
|
|
|
+ @RequestMapping(value = "getDetailInfo", method = {RequestMethod.POST})
|
|
|
+ public ResultContent<SecretKeyModel> getDetailInfo(@RequestBody IDParam param) {
|
|
|
+ return this.secretKeyService.getDetailInfo(param.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "删除数据", description = "删除数据")
|
|
|
+ @RequestMapping(value = "deleteInfo", method = {RequestMethod.POST})
|
|
|
+ public ResultContent deleteInfo(@RequestBody IDParam param) {
|
|
|
+ return this.secretKeyService.deleteInfo(param.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "数据列表-分页查询", description = "数据列表-分页查询")
|
|
|
+ @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
|
|
|
+ public ResultContent<Page<SecretKeyModel>> page(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) SecretKeySearch param) {
|
|
|
+ return secretKeyService.page(param, pageable);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "数据列表-分页查询(供选择)", description = "数据列表-分页查询")
|
|
|
+ @RequestMapping(value = {"pageForSelect"}, method = {RequestMethod.POST})
|
|
|
+ public ResultContent<Page<SecretKeyModel>> pageForSelect(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) SecretKeySearch param) {
|
|
|
+ Assert.hasText(param.getProjectOid(), "projectOid不能为空");
|
|
|
+ return secretKeyService.page(param, pageable);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "启用数据", description = "启用数据")
|
|
|
+ @RequestMapping(value = "enableData", method = {RequestMethod.POST})
|
|
|
+ public ResultContent enableData(@RequestBody IDParam param) {
|
|
|
+ return this.secretKeyService.changeState(param.getId(), DataState.Enable);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResourceAuth(value = "user", type = AuthType.User)
|
|
|
+ @Operation(summary = "禁用数据", description = "禁用数据")
|
|
|
+ @RequestMapping(value = "disableData", method = {RequestMethod.POST})
|
|
|
+ public ResultContent disableData(@RequestBody IDParam param) {
|
|
|
+ return this.secretKeyService.changeState(param.getId(), DataState.Disable);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|