密钥管理接口
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
package com.sunyard.chsm.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sunyard.chsm.auth.AuthCode;
|
||||
import com.sunyard.chsm.constant.AuthCodeConst;
|
||||
import com.sunyard.chsm.model.R;
|
||||
import com.sunyard.chsm.model.dto.KeyInfoDTO;
|
||||
import com.sunyard.chsm.service.KeyInfoService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.sunyard.chsm.param.KeyCreateReq;
|
||||
import com.sunyard.chsm.param.KeyInfoQuery;
|
||||
import com.sunyard.chsm.param.KeyInfoResp;
|
||||
import com.sunyard.chsm.param.KeyManageReq;
|
||||
import com.sunyard.chsm.param.KeyUpdateReq;
|
||||
import com.sunyard.chsm.service.KeyManageService;
|
||||
import org.springframework.util.Assert;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 密钥管理类接口
|
||||
@@ -20,22 +26,106 @@ import javax.annotation.Resource;
|
||||
* @since 2024/12/6
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/key/manage")
|
||||
@RequestMapping("/key")
|
||||
public class KeyManageController {
|
||||
|
||||
@Resource
|
||||
private KeyInfoService keyInfoService;
|
||||
private KeyManageService keyManageService;
|
||||
|
||||
/**
|
||||
* 查询密钥列表
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
@PostMapping("/pageList")
|
||||
public R<Page<KeyInfoResp>> queryPageList(@RequestBody KeyInfoQuery query) {
|
||||
Page<KeyInfoResp> page = keyManageService.queryPageList(query);
|
||||
return R.data(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询密钥详情
|
||||
*
|
||||
* @param id 查询条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
public R<KeyInfoResp> queryInfo(Long id) {
|
||||
Assert.notNull(id, "密钥id不能为空");
|
||||
KeyInfoResp resp = keyManageService.queryInfo(id);
|
||||
return R.data(resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建密钥
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/gen")
|
||||
public R<Long> save(@Valid @RequestBody KeyCreateReq req) {
|
||||
Long id = keyManageService.create(req);
|
||||
return R.data(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新密钥
|
||||
*
|
||||
* @param req 参数
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<Void> update(@Valid @RequestBody KeyUpdateReq req) {
|
||||
keyManageService.update(req);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @param req 密钥ids
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@AuthCode(AuthCodeConst.key_enable)
|
||||
public R<Void> enableKey(@Validated @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.enableKey(param.getIds());
|
||||
public R<Void> enableKey(@Valid @RequestBody KeyManageReq req) {
|
||||
keyManageService.enableKey(req.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用密钥
|
||||
*
|
||||
* @param req 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/disable")
|
||||
public R<Void> disableKey(@Valid @RequestBody KeyManageReq req) {
|
||||
keyManageService.disableKey(req.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档密钥
|
||||
*
|
||||
* @param req 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/archive")
|
||||
public R<Void> archiveKey(@Valid @RequestBody KeyManageReq req) {
|
||||
keyManageService.archiveKey(req.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁密钥
|
||||
*
|
||||
* @param req 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/destroy")
|
||||
public R<Void> destroyKey(@Valid @RequestBody KeyManageReq req) {
|
||||
keyManageService.destroyKey(req.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user