增加权限码

This commit is contained in:
liulu 2024-12-18 09:35:30 +08:00
parent 9cb9b43052
commit f19891c39d
2 changed files with 15 additions and 0 deletions

View File

@ -39,6 +39,7 @@ public class KeyManageController {
* @return 分页列表 * @return 分页列表
*/ */
@PostMapping("/pageList") @PostMapping("/pageList")
@AuthCode(AuthCodeConst.key_list)
public R<Page<KeyInfoResp>> queryPageList(@RequestBody KeyInfoQuery query) { public R<Page<KeyInfoResp>> queryPageList(@RequestBody KeyInfoQuery query) {
Page<KeyInfoResp> page = keyManageService.queryPageList(query); Page<KeyInfoResp> page = keyManageService.queryPageList(query);
return R.data(page); return R.data(page);
@ -51,6 +52,7 @@ public class KeyManageController {
* @return 分页列表 * @return 分页列表
*/ */
@PostMapping("/info") @PostMapping("/info")
@AuthCode(AuthCodeConst.key_info)
public R<KeyInfoResp> queryInfo(@RequestBody Long id) { public R<KeyInfoResp> queryInfo(@RequestBody Long id) {
Assert.notNull(id, "密钥id不能为空"); Assert.notNull(id, "密钥id不能为空");
KeyInfoResp resp = keyManageService.queryInfo(id); KeyInfoResp resp = keyManageService.queryInfo(id);
@ -63,6 +65,7 @@ public class KeyManageController {
* @return id * @return id
*/ */
@PostMapping("/gen") @PostMapping("/gen")
@AuthCode(AuthCodeConst.key_create)
public R<Long> save(@Valid @RequestBody KeyCreateReq req) { public R<Long> save(@Valid @RequestBody KeyCreateReq req) {
Long id = keyManageService.create(req); Long id = keyManageService.create(req);
return R.data(id); return R.data(id);
@ -75,6 +78,7 @@ public class KeyManageController {
* @return id * @return id
*/ */
@PostMapping("/update") @PostMapping("/update")
@AuthCode(AuthCodeConst.key_update)
public R<Void> update(@Valid @RequestBody KeyUpdateReq req) { public R<Void> update(@Valid @RequestBody KeyUpdateReq req) {
keyManageService.update(req); keyManageService.update(req);
return R.ok(); return R.ok();
@ -100,6 +104,7 @@ public class KeyManageController {
* @return id * @return id
*/ */
@PostMapping("/disable") @PostMapping("/disable")
@AuthCode(AuthCodeConst.key_disable)
public R<Void> disableKey(@Valid @RequestBody KeyManageReq req) { public R<Void> disableKey(@Valid @RequestBody KeyManageReq req) {
keyManageService.disableKey(req.getIds()); keyManageService.disableKey(req.getIds());
return R.ok(); return R.ok();
@ -112,6 +117,7 @@ public class KeyManageController {
* @return id * @return id
*/ */
@PostMapping("/archive") @PostMapping("/archive")
@AuthCode(AuthCodeConst.key_archive)
public R<Void> archiveKey(@Valid @RequestBody KeyManageReq req) { public R<Void> archiveKey(@Valid @RequestBody KeyManageReq req) {
keyManageService.archiveKey(req.getIds()); keyManageService.archiveKey(req.getIds());
return R.ok(); return R.ok();
@ -124,6 +130,7 @@ public class KeyManageController {
* @return id * @return id
*/ */
@PostMapping("/destroy") @PostMapping("/destroy")
@AuthCode(AuthCodeConst.key_destroy)
public R<Void> destroyKey(@Valid @RequestBody KeyManageReq req) { public R<Void> destroyKey(@Valid @RequestBody KeyManageReq req) {
keyManageService.destroyKey(req.getIds()); keyManageService.destroyKey(req.getIds());
return R.ok(); return R.ok();

View File

@ -1,5 +1,7 @@
package com.sunyard.chsm.controller; package com.sunyard.chsm.controller;
import com.sunyard.chsm.auth.AuthCode;
import com.sunyard.chsm.constant.AuthCodeConst;
import com.sunyard.chsm.model.R; import com.sunyard.chsm.model.R;
import com.sunyard.chsm.param.SymDecryptReq; import com.sunyard.chsm.param.SymDecryptReq;
import com.sunyard.chsm.param.SymDecryptResp; import com.sunyard.chsm.param.SymDecryptResp;
@ -42,6 +44,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/encrypt") @PostMapping("/encrypt")
@AuthCode(AuthCodeConst.sym_enc)
public R<SymEncryptResp> encrypt(@Valid @RequestBody SymEncryptReq req) { public R<SymEncryptResp> encrypt(@Valid @RequestBody SymEncryptReq req) {
SymEncryptResp resp = symKeyService.encrypt(req); SymEncryptResp resp = symKeyService.encrypt(req);
return R.data(resp); return R.data(resp);
@ -54,6 +57,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/decrypt") @PostMapping("/decrypt")
@AuthCode(AuthCodeConst.sym_dec)
public R<SymDecryptResp> decrypt(@Valid @RequestBody SymDecryptReq req) { public R<SymDecryptResp> decrypt(@Valid @RequestBody SymDecryptReq req) {
SymDecryptResp resp = symKeyService.decrypt(req); SymDecryptResp resp = symKeyService.decrypt(req);
return R.data(resp); return R.data(resp);
@ -66,6 +70,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/hmac") @PostMapping("/hmac")
@AuthCode(AuthCodeConst.cal_hmac)
public R<SymHmacResp> hmac(@Valid @RequestBody SymHmacReq req) { public R<SymHmacResp> hmac(@Valid @RequestBody SymHmacReq req) {
SymHmacResp resp = symKeyService.hmac(req); SymHmacResp resp = symKeyService.hmac(req);
return R.data(resp); return R.data(resp);
@ -78,6 +83,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/hmac/check") @PostMapping("/hmac/check")
@AuthCode(AuthCodeConst.check_hmac)
public R<SymHmacCheckResp> macCheck(@Valid @RequestBody SymHmacCheckReq req) { public R<SymHmacCheckResp> macCheck(@Valid @RequestBody SymHmacCheckReq req) {
SymHmacCheckResp resp = symKeyService.hmacCheck(req); SymHmacCheckResp resp = symKeyService.hmacCheck(req);
return R.data(resp); return R.data(resp);
@ -90,6 +96,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/mac") @PostMapping("/mac")
@AuthCode(AuthCodeConst.cal_mac)
public R<SymMacResp> mac(@Valid @RequestBody SymMacReq req) { public R<SymMacResp> mac(@Valid @RequestBody SymMacReq req) {
SymMacResp resp = symKeyService.mac(req); SymMacResp resp = symKeyService.mac(req);
return R.data(resp); return R.data(resp);
@ -102,6 +109,7 @@ public class SymKeyController {
* @return * @return
*/ */
@PostMapping("/mac/check") @PostMapping("/mac/check")
@AuthCode(AuthCodeConst.check_mac)
public R<SymMacCheckResp> macCheck(@Valid @RequestBody SymMacCheckReq req) { public R<SymMacCheckResp> macCheck(@Valid @RequestBody SymMacCheckReq req) {
SymMacCheckResp resp = symKeyService.macCheck(req); SymMacCheckResp resp = symKeyService.macCheck(req);
return R.data(resp); return R.data(resp);