密钥管理接口
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package com.sunyard.chsm.controller;
|
||||
|
||||
/**
|
||||
* @author liulu
|
||||
* @since 2024/10/23
|
||||
*/
|
||||
public class AsymKeyController {
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.sunyard.chsm.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sunyard.chsm.dto.KeyInfoDTO;
|
||||
import com.sunyard.chsm.enums.KeyCategory;
|
||||
import com.sunyard.chsm.model.R;
|
||||
import com.sunyard.chsm.service.KeyInfoService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 非对称密钥管理接口
|
||||
* @author liulu
|
||||
* @since 2024/10/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/key/info/asym")
|
||||
public class KeyInfoAsymController {
|
||||
|
||||
@Resource
|
||||
private KeyInfoService keyInfoService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询非对称密钥列表
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
@GetMapping("/pageList")
|
||||
public R<Page<KeyInfoDTO.View>> aymPageList(KeyInfoDTO.Query query) {
|
||||
query.setKeyType(KeyCategory.ASYM_KEY.getCode());
|
||||
Page<KeyInfoDTO.View> page = keyInfoService.selectPageList(query);
|
||||
return R.data(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.sunyard.chsm.controller;
|
||||
|
||||
import com.sunyard.chsm.dto.KeyInfoDTO;
|
||||
import com.sunyard.chsm.enums.KeyStatus;
|
||||
import com.sunyard.chsm.model.Option;
|
||||
import com.sunyard.chsm.model.R;
|
||||
import com.sunyard.chsm.service.KeyInfoService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 密钥管理公共接口
|
||||
*
|
||||
* @author liulu
|
||||
* @since 2024/10/23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/key/info")
|
||||
public class KeyInfoController {
|
||||
|
||||
@Resource
|
||||
private KeyInfoService keyInfoService;
|
||||
|
||||
/**
|
||||
* 获取密钥状态选项
|
||||
*/
|
||||
@GetMapping("/statusList")
|
||||
public R<List<Option>> getStatusList() {
|
||||
|
||||
List<Option> options = Arrays.stream(KeyStatus.values())
|
||||
.map(it -> new Option(it.getCode(), it.getDesc()))
|
||||
.collect(Collectors.toList());
|
||||
return R.data(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建密钥
|
||||
*
|
||||
* @param save 参数
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public R<String> save(@Valid @RequestBody KeyInfoDTO.Save save) {
|
||||
Long id = keyInfoService.save(save);
|
||||
return R.data(String.valueOf(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新密钥
|
||||
*
|
||||
* @param update 参数
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<Void> save(@Valid @RequestBody KeyInfoDTO.Update update) {
|
||||
keyInfoService.update(update);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
public R<Void> enableKey(@Valid @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.enableKey(param.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/disable")
|
||||
public R<Void> disableKey(@Valid @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.disableKey(param.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/archive")
|
||||
public R<Void> archiveKey(@Valid @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.archiveKey(param.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/recovery")
|
||||
public R<Void> recoveryKey(@Valid @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.recoveryKey(param.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁密钥
|
||||
*
|
||||
* @param param 密钥id
|
||||
* @return id
|
||||
*/
|
||||
@PostMapping("/destroy")
|
||||
public R<Void> destroyKey(@Valid @RequestBody KeyInfoDTO.IDs param) {
|
||||
keyInfoService.destroyKey(param.getIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+9
-27
@@ -3,8 +3,6 @@ package com.sunyard.chsm.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sunyard.chsm.dto.KeyInfoDTO;
|
||||
import com.sunyard.chsm.enums.KeyCategory;
|
||||
import com.sunyard.chsm.enums.KeyStatus;
|
||||
import com.sunyard.chsm.model.Option;
|
||||
import com.sunyard.chsm.model.R;
|
||||
import com.sunyard.chsm.service.KeyInfoService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -15,34 +13,20 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 对称密钥管理接口
|
||||
*
|
||||
* @author liulu
|
||||
* @since 2024/10/23
|
||||
* @since 2024/10/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sym/key")
|
||||
public class SymKeyController {
|
||||
@RequestMapping("/key/info/sym")
|
||||
public class KeyInfoSymController {
|
||||
|
||||
@Resource
|
||||
private KeyInfoService keyInfoService;
|
||||
|
||||
/**
|
||||
* 获取密钥状态列表
|
||||
*/
|
||||
@GetMapping("/statusList")
|
||||
public R<List<Option>> getStatusList() {
|
||||
|
||||
List<Option> options = Arrays.stream(KeyStatus.values())
|
||||
.map(it -> new Option(it.getCode(), it.getDesc()))
|
||||
.collect(Collectors.toList());
|
||||
return R.data(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询对称密钥列表
|
||||
@@ -51,7 +35,7 @@ public class SymKeyController {
|
||||
* @return 分页列表
|
||||
*/
|
||||
@GetMapping("/pageList")
|
||||
public R<Page<KeyInfoDTO.View>> servicePageList(KeyInfoDTO.Query query) {
|
||||
public R<Page<KeyInfoDTO.View>> symPageList(KeyInfoDTO.Query query) {
|
||||
query.setKeyType(KeyCategory.SYM_KEY.getCode());
|
||||
Page<KeyInfoDTO.View> page = keyInfoService.selectPageList(query);
|
||||
|
||||
@@ -59,15 +43,13 @@ public class SymKeyController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建密钥
|
||||
* 密钥备份
|
||||
*
|
||||
* @param save 参数
|
||||
* @return id
|
||||
* @param backup 参数
|
||||
*/
|
||||
@PostMapping
|
||||
public R<String> save(@Valid @RequestBody KeyInfoDTO.Save save) {
|
||||
Long id = keyInfoService.save(save);
|
||||
return R.data(String.valueOf(id));
|
||||
@PostMapping("/backup")
|
||||
public void backupKey(@Valid @RequestBody KeyInfoDTO.Backup backup) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user