|
|
@@ -4,19 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.dliyun.oap.framework.security.algorithm.Rsa;
|
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
|
import com.zhiqiyun.open.core.enmus.YN;
|
|
|
import com.zhiqiyun.open.core.models.app.ApiRequestLog;
|
|
|
import com.zhiqiyun.open.core.models.app.AppKeyInfo;
|
|
|
import com.zhiqiyun.open.core.service.ApiRequestLogService;
|
|
|
+import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
|
import com.zhiqiyun.open.mvc.manager.params.QueryApiRequestLogParams;
|
|
|
import com.zhiqiyun.open.mvc.manager.params.QueryAppKeyInfoParams;
|
|
|
import com.zhiqiyun.open.mvc.manager.params.SaveAppKeyInfoParam;
|
|
|
-import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
|
-import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
|
-import com.zhiqiyun.open.utils.RandomUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@@ -95,15 +96,16 @@ public class AppKeyInfoController {
|
|
|
|
|
|
@Permission(value = "app.key.add", tags = "新建AppKey")
|
|
|
@PostMapping("/save")
|
|
|
- public Result save(@RequestBody SaveAppKeyInfoParam param) {
|
|
|
+ public Result save(@Valid @RequestBody SaveAppKeyInfoParam param) throws Exception {
|
|
|
|
|
|
AppKeyInfo appKeyInfo = new AppKeyInfo();
|
|
|
BeanUtils.copyProperties(param, appKeyInfo);
|
|
|
|
|
|
Long id = this.sequenceService.nextId();
|
|
|
- String encryptKey = RandomUtil.get(64);
|
|
|
appKeyInfo.setId(id);
|
|
|
- appKeyInfo.setEncryptKey(encryptKey);
|
|
|
+ Rsa.RsaKeys rsaKeys = Rsa.genKeyPair();
|
|
|
+ appKeyInfo.setPublicKey(rsaKeys.getPublicKey());
|
|
|
+ appKeyInfo.setPrivateKey(rsaKeys.getPrivateKey());
|
|
|
appKeyInfo.setCreatedTime(DateUtil.current());
|
|
|
appKeyInfo.setIsEnable(YN.Y);
|
|
|
this.appKeyInfoService.save(appKeyInfo);
|
|
|
@@ -113,7 +115,7 @@ public class AppKeyInfoController {
|
|
|
|
|
|
@Permission(value = "app.key.add", tags = "更新AppKey")
|
|
|
@PostMapping("/updateById")
|
|
|
- public Result updateById(Long id, @RequestBody SaveAppKeyInfoParam param) {
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveAppKeyInfoParam param) {
|
|
|
AppKeyInfo appKeyInfo = new AppKeyInfo();
|
|
|
BeanUtils.copyProperties(param, appKeyInfo);
|
|
|
appKeyInfo.setId(id);
|