45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
|
|
package com.sentinel.license.controller;
|
||
|
|
|
||
|
|
import cn.hutool.log.Log;
|
||
|
|
import com.sentinel.license.bean.LicenseInfo;
|
||
|
|
import com.sentinel.license.utils.HaspUtil;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @author fengjunfeng
|
||
|
|
* @date 2021/12/28
|
||
|
|
* @time 16:00
|
||
|
|
* @description
|
||
|
|
**/
|
||
|
|
@RestController
|
||
|
|
public class LicenseController {
|
||
|
|
private static final Log log = Log.get();
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* license锁信息交互
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping("/licenseOperation")
|
||
|
|
public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) {
|
||
|
|
if (licenseInfo.getType() == 1){
|
||
|
|
//获取C2V信息
|
||
|
|
return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
|
||
|
|
}else if (licenseInfo.getType() == 2){
|
||
|
|
//上传license信息
|
||
|
|
return HaspUtil.updateKeyWithLicense(licenseInfo.getV2C());
|
||
|
|
}else if (licenseInfo.getType() == 3){
|
||
|
|
//获取license信息
|
||
|
|
return HaspUtil.getLicenseInfo(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
|
||
|
|
}else if (licenseInfo.getType() == 4){
|
||
|
|
//验证license信息
|
||
|
|
return HaspUtil.verify(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
|
||
|
|
}else {
|
||
|
|
log.info("type error");
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|