|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.psdc.controller.key; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.psdc.core.controller.BaseController; |
|
|
|
|
import com.psdc.core.domain.AjaxResult; |
|
|
|
|
import com.psdc.entity.SecretKey; |
|
|
|
|
import com.psdc.service.IGenerateKey; |
|
|
|
@ -8,10 +9,11 @@ import com.psdc.service.IPrivateKeyService; |
|
|
|
|
import com.psdc.service.ISecretKeyService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import com.psdc.core.controller.BaseController; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -19,7 +21,7 @@ import java.util.Map; |
|
|
|
|
*/ |
|
|
|
|
@RestController |
|
|
|
|
@RequestMapping("/system/key") |
|
|
|
|
public class GenerateKeyController extends BaseController{ |
|
|
|
|
public class GenerateKeyController extends BaseController { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IGenerateKey generateKey; |
|
|
|
@ -31,7 +33,6 @@ public class GenerateKeyController extends BaseController{ |
|
|
|
|
IPrivateKeyService privateKeyService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/getKey") |
|
|
|
|
public AjaxResult getGenerateKey(@RequestBody Map<String, Object> requestBody) { |
|
|
|
|
List<String> cpuIds = (List<String>) requestBody.get("cpuIds"); |
|
|
|
@ -39,21 +40,26 @@ public class GenerateKeyController extends BaseController{ |
|
|
|
|
String key = (String) requestBody.get("key"); |
|
|
|
|
String companyname = (String) requestBody.get("companyname"); |
|
|
|
|
Map map = new HashMap(); |
|
|
|
|
map.put("companyname",companyname); |
|
|
|
|
map.put("expireTime",expiration); |
|
|
|
|
map.put("cpuIds",cpuIds.toString()); |
|
|
|
|
map.put("companyname", companyname); |
|
|
|
|
map.put("expireTime", expiration); |
|
|
|
|
map.put("cpuIds", cpuIds.toString()); |
|
|
|
|
AjaxResult ajax = AjaxResult.success(); |
|
|
|
|
String s = generateKey.generateKey(map, key); |
|
|
|
|
ajax.put("key", s); |
|
|
|
|
SecretKey secretKey = new SecretKey(); |
|
|
|
|
secretKey.setKeyValue(s); |
|
|
|
|
secretKey.setExportDate(expiration); |
|
|
|
|
secretKeyService.insert(secretKey); |
|
|
|
|
SecretKey selOne = secretKeyService.selOne(s, expiration); |
|
|
|
|
if (Optional.ofNullable(selOne).isPresent()) { |
|
|
|
|
secretKeyService.update(s, selOne.getKeyValue()); |
|
|
|
|
} else { |
|
|
|
|
secretKeyService.insert(secretKey); |
|
|
|
|
} |
|
|
|
|
return ajax; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping("/selAll") |
|
|
|
|
public AjaxResult queryById(){ |
|
|
|
|
public AjaxResult queryById() { |
|
|
|
|
return privateKeyService.selectAll(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|