mirror of
https://gitee.com/raoxy/kongx.git
synced 2025-07-10 00:00:02 +08:00
1、增加sni、certificate、ca_certificate及consumers相关证书等功能
2、优化service、upstream以便适配后续各版本功能
This commit is contained in:
parent
9d5de06b3b
commit
f93e8fc9ec
@ -0,0 +1,128 @@
|
||||
package com.kongx.serve.controller.gateway;
|
||||
|
||||
import com.kongx.common.core.entity.UserInfo;
|
||||
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
||||
import com.kongx.serve.controller.BaseController;
|
||||
import com.kongx.serve.entity.gateway.CaCertificate;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.system.OperationLog;
|
||||
import com.kongx.serve.service.gateway.CaCertificateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@RestController("CaCertificateController")
|
||||
@RequestMapping("/kong/api/")
|
||||
@Slf4j
|
||||
public class CaCertificateController extends BaseController {
|
||||
private static final String CERTIFICATES_URI = "/ca_certificates";
|
||||
private static final String CERTIFICATES_URI_ID = "/ca_certificates/{id}";
|
||||
|
||||
@Autowired
|
||||
private CaCertificateService caCertificateService;
|
||||
|
||||
/**
|
||||
* 查询所有sni
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findAll(UserInfo userInfo) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
KongEntity<CaCertificate> upstreamKongEntity = caCertificateService.findAll(systemProfile(userInfo));
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody CaCertificate sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
CaCertificate results = this.caCertificateService.add(systemProfile(userInfo), sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CaCertificate, sni);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新consumer
|
||||
*
|
||||
* @param id
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody CaCertificate sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
CaCertificate results = this.caCertificateService.update(systemProfile(userInfo), id, sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.CaCertificate, sni, sni.getId());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除sni
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.DELETE)
|
||||
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
CaCertificate sni = this.caCertificateService.findEntity(systemProfile(userInfo), id);
|
||||
KongEntity<CaCertificate> upstreamKongEntity = this.caCertificateService.remove(systemProfile(userInfo), id);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CaCertificate, sni);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个sni的信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
CaCertificate results = this.caCertificateService.findEntity(systemProfile(userInfo), id);
|
||||
jsonHeaderWrapper.setData(results);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package com.kongx.serve.controller.gateway;
|
||||
|
||||
import com.kongx.common.core.entity.UserInfo;
|
||||
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
||||
import com.kongx.serve.controller.BaseController;
|
||||
import com.kongx.serve.entity.gateway.Certificate;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.system.OperationLog;
|
||||
import com.kongx.serve.service.gateway.CertificateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@RestController("CertificateController")
|
||||
@RequestMapping("/kong/api/")
|
||||
@Slf4j
|
||||
public class CertificateController extends BaseController {
|
||||
private static final String CERTIFICATES_URI = "/certificates";
|
||||
private static final String CERTIFICATES_URI_ID = "/certificates/{id}";
|
||||
|
||||
@Autowired
|
||||
private CertificateService certificateService;
|
||||
|
||||
/**
|
||||
* 查询所有sni
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findAll(UserInfo userInfo) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
KongEntity<Certificate> upstreamKongEntity = certificateService.findAll(systemProfile(userInfo));
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Certificate sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Certificate results = this.certificateService.add(systemProfile(userInfo), sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.Certificate, sni);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新consumer
|
||||
*
|
||||
* @param id
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Certificate sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Certificate results = this.certificateService.update(systemProfile(userInfo), id, sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.Certificate, sni, sni.getKey());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除sni
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.DELETE)
|
||||
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Certificate sni = this.certificateService.findEntity(systemProfile(userInfo), id);
|
||||
KongEntity<Certificate> upstreamKongEntity = this.certificateService.remove(systemProfile(userInfo), id);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.Certificate, sni);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个sni的信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CERTIFICATES_URI_ID, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Certificate results = this.certificateService.findEntity(systemProfile(userInfo), id);
|
||||
jsonHeaderWrapper.setData(results);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
}
|
@ -5,13 +5,17 @@ import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
||||
import com.kongx.serve.controller.BaseController;
|
||||
import com.kongx.serve.entity.gateway.Consumer;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.gateway.PluginVO;
|
||||
import com.kongx.serve.entity.system.OperationLog;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.service.gateway.ConsumerService;
|
||||
import com.kongx.serve.service.gateway.PluginService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController("consumerController")
|
||||
@RequestMapping("/kong/api/")
|
||||
@ -19,10 +23,16 @@ import java.net.URISyntaxException;
|
||||
public class ConsumerController extends BaseController {
|
||||
private static final String CONSUMER_URI = "/consumers";
|
||||
private static final String CONSUMER_URI_ID = "/consumers/{id}";
|
||||
private static final String CONSUMER_URI_plugins = "/consumers/{customerId}/plugins";
|
||||
private static final String CREDENTIALS_URI = "/consumers/{customerId}/{entityName}";
|
||||
private static final String CREDENTIALS_URI_ID = "/consumers/{customerId}/{entityName}/{entityId}";
|
||||
|
||||
@Autowired
|
||||
private ConsumerService consumerService;
|
||||
|
||||
@Autowired
|
||||
private PluginService pluginService;
|
||||
|
||||
/**
|
||||
* 查询所有upstream
|
||||
*
|
||||
@ -41,6 +51,48 @@ public class ConsumerController extends BaseController {
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
@RequestMapping(value = CONSUMER_URI_plugins, method = {RequestMethod.POST})
|
||||
public JsonHeaderWrapper findAllPlugin(UserInfo userInfo, @PathVariable String customerId, @RequestBody SystemProfile systemProfile) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
SystemProfile activeClient = this.systemProfile(userInfo);
|
||||
KongEntity<PluginVO> pluginVOKongEntity = pluginService.findAllByConsumer(systemProfile.IS_NULL() ? activeClient : systemProfile, customerId);
|
||||
jsonHeaderWrapper.setData(pluginVOKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = CREDENTIALS_URI, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findAllCredentials(UserInfo userInfo, @PathVariable String customerId, @PathVariable String entityName) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
KongEntity<Map> upstreamKongEntity = consumerService.findAllCredentials(systemProfile(userInfo), customerId, entityName);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
@RequestMapping(value = CREDENTIALS_URI, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper addCredentials(UserInfo userInfo, @RequestBody Map map, @PathVariable String customerId, @PathVariable String entityName) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Map results = this.consumerService.addCredentials(systemProfile(userInfo), map, customerId, entityName);
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CONSUMERS, map);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
@ -49,12 +101,12 @@ public class ConsumerController extends BaseController {
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CONSUMER_URI, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Consumer consumer) {
|
||||
public JsonHeaderWrapper add(UserInfo userInfo, @RequestBody Consumer consumer) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Consumer results = this.consumerService.add(systemProfile(userInfo), consumer.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.UPSTREAM, consumer.getUsername());
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.CONSUMERS, consumer.getUsername());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
@ -76,7 +128,7 @@ public class ConsumerController extends BaseController {
|
||||
try {
|
||||
Consumer results = this.consumerService.update(systemProfile(userInfo), id, consumer.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.UPSTREAM, consumer, consumer.getUsername());
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.CONSUMERS, consumer, consumer.getUsername());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
@ -85,19 +137,34 @@ public class ConsumerController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除consumer
|
||||
* 删除credential
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = CREDENTIALS_URI_ID, method = RequestMethod.DELETE)
|
||||
public JsonHeaderWrapper removeCredential(UserInfo userInfo, @PathVariable String customerId, @PathVariable String entityName,
|
||||
@PathVariable String entityId) throws Exception {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
KongEntity<Map> upstreamKongEntity =
|
||||
this.consumerService.removeCredentials(systemProfile(userInfo), customerId, entityName, entityId);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CONSUMERS, entityId);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
@RequestMapping(value = CONSUMER_URI_ID, method = RequestMethod.DELETE)
|
||||
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Consumer consumer = this.consumerService.findConsumer(systemProfile(userInfo), id);
|
||||
KongEntity<Consumer> upstreamKongEntity = this.consumerService.remove(systemProfile(userInfo), id);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.UPSTREAM, consumer);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.CONSUMERS, consumer);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
|
@ -54,7 +54,6 @@ public class ServiceController extends BaseController {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
SystemProfile activeClient = this.systemProfile(userInfo);
|
||||
Service service = this.kongFeignService.find(this.systemProfile(userInfo), serviceId);
|
||||
KongEntity<PluginVO> pluginVOKongEntity = pluginService.findAllPluginByService(systemProfile.IS_NULL() ? activeClient : systemProfile, serviceId);
|
||||
jsonHeaderWrapper.setData(pluginVOKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
@ -75,7 +74,7 @@ public class ServiceController extends BaseController {
|
||||
public JsonHeaderWrapper add(UserInfo userInfo, @RequestBody Service service) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Service results = this.kongFeignService.add(systemProfile(userInfo), service);
|
||||
Service results = this.kongFeignService.add(systemProfile(userInfo), service.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.SERVICE, results, results.getName());
|
||||
} catch (Exception e) {
|
||||
@ -97,7 +96,7 @@ public class ServiceController extends BaseController {
|
||||
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Service service) throws URISyntaxException {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Service results = this.kongFeignService.update(systemProfile(userInfo), id, service);
|
||||
Service results = this.kongFeignService.update(systemProfile(userInfo), id, service.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.SERVICE, results, results.getName());
|
||||
} catch (Exception e) {
|
||||
|
@ -0,0 +1,128 @@
|
||||
package com.kongx.serve.controller.gateway;
|
||||
|
||||
import com.kongx.common.core.entity.UserInfo;
|
||||
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
||||
import com.kongx.serve.controller.BaseController;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.gateway.Sni;
|
||||
import com.kongx.serve.entity.system.OperationLog;
|
||||
import com.kongx.serve.service.gateway.SniService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@RestController("sniController")
|
||||
@RequestMapping("/kong/api/")
|
||||
@Slf4j
|
||||
public class SniController extends BaseController {
|
||||
private static final String SNIS_URI = "/snis";
|
||||
private static final String SNIS_URI_ID = "/snis/{id}";
|
||||
|
||||
@Autowired
|
||||
private SniService sniService;
|
||||
|
||||
/**
|
||||
* 查询所有sni
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = SNIS_URI, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findAll(UserInfo userInfo) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
KongEntity<Sni> upstreamKongEntity = sniService.findAll(systemProfile(userInfo));
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = SNIS_URI, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Sni sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Sni results = this.sniService.add(systemProfile(userInfo), sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.SNI, sni);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新consumer
|
||||
*
|
||||
* @param id
|
||||
* @param sni
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.POST)
|
||||
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Sni sni) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Sni results = this.sniService.update(systemProfile(userInfo), id, sni.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.SNI, sni, sni.getName());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除sni
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.DELETE)
|
||||
public JsonHeaderWrapper remove(UserInfo userInfo, @PathVariable String id) throws Exception {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Sni sni = this.sniService.findEntity(systemProfile(userInfo), id);
|
||||
KongEntity<Sni> upstreamKongEntity = this.sniService.remove(systemProfile(userInfo), id);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_DELETE, OperationLog.OperationTarget.SNI, sni);
|
||||
jsonHeaderWrapper.setData(upstreamKongEntity.getData());
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个sni的信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = SNIS_URI_ID, method = RequestMethod.GET)
|
||||
public JsonHeaderWrapper findSni(UserInfo userInfo, @PathVariable String id) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Sni results = this.sniService.findEntity(systemProfile(userInfo), id);
|
||||
jsonHeaderWrapper.setData(results);
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
}
|
||||
return jsonHeaderWrapper;
|
||||
}
|
||||
}
|
@ -54,11 +54,10 @@ public class UpstreamController extends BaseController {
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
@RequestMapping(value = UPSTREAM_URI, method = RequestMethod.POST)
|
||||
@PreAuthorize("upstream_add")
|
||||
public JsonHeaderWrapper addUpstream(UserInfo userInfo, @RequestBody Upstream upstream) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Upstream results = this.upstreamService.add(systemProfile(userInfo), upstream.clear());
|
||||
Upstream results = this.upstreamService.add(systemProfile(userInfo), upstream.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_ADD, OperationLog.OperationTarget.UPSTREAM, upstream, upstream.getName());
|
||||
} catch (Exception e) {
|
||||
@ -80,7 +79,7 @@ public class UpstreamController extends BaseController {
|
||||
public JsonHeaderWrapper update(UserInfo userInfo, @PathVariable String id, @RequestBody Upstream upstream) {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
Upstream results = this.upstreamService.update(systemProfile(userInfo), id, upstream.clear());
|
||||
Upstream results = this.upstreamService.update(systemProfile(userInfo), id, upstream.trim());
|
||||
jsonHeaderWrapper.setData(results);
|
||||
this.log(userInfo, OperationLog.OperationType.OPERATION_UPDATE, OperationLog.OperationTarget.UPSTREAM, upstream, upstream.getName());
|
||||
} catch (Exception e) {
|
||||
|
@ -70,7 +70,7 @@ public class ServerConfigController extends BaseController {
|
||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||
try {
|
||||
ServerConfig serverConfig = this.serverConfigService.findByKey(key);
|
||||
jsonHeaderWrapper.setData(Jackson2Helper.parsonObject(serverConfig.getConfigValue(), new TypeReference<Object>() {
|
||||
jsonHeaderWrapper.setData(Jackson2Helper.parsonObject(serverConfig.getConfigValue().toString(), new TypeReference<Object>() {
|
||||
}));
|
||||
} catch (Exception e) {
|
||||
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.kongx.serve.entity.gateway;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* @since 1.3.x
|
||||
*/
|
||||
public class CaCertificate implements Comparable {
|
||||
private Timestamp created_at;
|
||||
private String cert;
|
||||
private String id;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o == null) {
|
||||
return 1;
|
||||
}
|
||||
CaCertificate sni = null;
|
||||
if (o instanceof CaCertificate) {
|
||||
sni = (CaCertificate) o;
|
||||
}
|
||||
return sni.created_at.compareTo(this.created_at);
|
||||
}
|
||||
|
||||
public CaCertificate trim() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.kongx.serve.entity.gateway;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Certificate implements Comparable {
|
||||
private Timestamp created_at;
|
||||
private String cert;
|
||||
private String key;
|
||||
private String id;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
private List<String> snis = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o == null) {
|
||||
return 1;
|
||||
}
|
||||
Certificate sni = null;
|
||||
if (o instanceof Certificate) {
|
||||
sni = (Certificate) o;
|
||||
}
|
||||
return sni.created_at.compareTo(this.created_at);
|
||||
}
|
||||
|
||||
public Certificate trim() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Copyright 2019 bejson.com
|
||||
*/
|
||||
* Copyright 2019 bejson.com
|
||||
*/
|
||||
package com.kongx.serve.entity.gateway;
|
||||
|
||||
/**
|
||||
@ -12,11 +12,12 @@ package com.kongx.serve.entity.gateway;
|
||||
public class EntityId {
|
||||
|
||||
private String id;
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class Plugin implements Comparable {
|
||||
private List<String> protocols;
|
||||
private boolean enabled;
|
||||
private String run_on;
|
||||
private String consumer;
|
||||
private EntityId consumer;
|
||||
private EntityId route;
|
||||
private String tags;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class PluginVO extends Plugin {
|
||||
private List<String> protocols;
|
||||
private boolean enabled;
|
||||
private String run_on;
|
||||
private String consumer;
|
||||
private EntityId consumer;
|
||||
private EntityId route;
|
||||
private String tags;
|
||||
private String scope = "global";
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||
public class Route implements Comparable {
|
||||
|
||||
private String id;
|
||||
private String tags;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
private List<String> paths = new ArrayList<>();
|
||||
private String destinations;
|
||||
private List<String> protocols;
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @website http://www.bejson.com/java2pojo/
|
||||
*/
|
||||
@Data
|
||||
public class Service implements Comparable {
|
||||
public class Service implements Comparable {
|
||||
|
||||
private String host;
|
||||
private Timestamp created_at;
|
||||
@ -29,6 +29,10 @@ public class Service implements Comparable {
|
||||
private long updated_at;
|
||||
private int retries;
|
||||
private int write_timeout;
|
||||
/**
|
||||
* @since 1.3.x
|
||||
*/
|
||||
private EntityId client_certificate;
|
||||
private List<String> tags;
|
||||
|
||||
@Override
|
||||
@ -44,8 +48,11 @@ public class Service implements Comparable {
|
||||
}
|
||||
|
||||
|
||||
public Service clear() {
|
||||
public Service trim() {
|
||||
this.protocol = set(this.protocol);
|
||||
if (this.client_certificate != null && this.client_certificate.getId() == null) {
|
||||
this.client_certificate = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.kongx.serve.entity.gateway;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Sni implements Comparable {
|
||||
private Timestamp created_at;
|
||||
private String name;
|
||||
private String id;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
private EntityId certificate;
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o == null) {
|
||||
return 1;
|
||||
}
|
||||
Sni sni = null;
|
||||
if (o instanceof Sni) {
|
||||
sni = (Sni) o;
|
||||
}
|
||||
return sni.created_at.compareTo(this.created_at);
|
||||
}
|
||||
|
||||
public Sni trim() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -7,13 +7,18 @@ import com.kongx.serve.entity.gateway.upstream.Healthchecks;
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Upstream implements Comparable {
|
||||
|
||||
private Timestamp created_at;
|
||||
private String id;
|
||||
private String tags;
|
||||
/**
|
||||
* @since 1.3.x
|
||||
*/
|
||||
private String algorithm;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
private String hash_on;
|
||||
private String hash_fallback_header;
|
||||
private String hash_on_header;
|
||||
@ -36,7 +41,7 @@ public class Upstream implements Comparable {
|
||||
return upstream.created_at.compareTo(this.created_at);
|
||||
}
|
||||
|
||||
public Upstream clear() {
|
||||
public Upstream trim() {
|
||||
this.hash_fallback = set(this.hash_fallback);
|
||||
this.hash_on = set(this.hash_on);
|
||||
this.hash_fallback_header = set(this.hash_fallback_header);
|
||||
@ -44,6 +49,7 @@ public class Upstream implements Comparable {
|
||||
this.hash_on_cookie = set(this.hash_on_cookie);
|
||||
this.hash_on_cookie_path = set(this.hash_on_cookie_path);
|
||||
this.hash_fallback = set(this.hash_fallback);
|
||||
this.algorithm = set(this.algorithm);
|
||||
if (this.healthchecks != null)
|
||||
this.healthchecks.getActive().setHttps_sni(set(this.healthchecks.getActive().getHttps_sni()));
|
||||
return this;
|
||||
|
@ -81,6 +81,10 @@ public class OperationLog {
|
||||
ROUTE("route", "路由"),
|
||||
SERVICE("service", "服务"),
|
||||
UPSTREAM("upstream", "上游服务"),
|
||||
SNI("sni", "sni"),
|
||||
CONSUMERS("consumers", "消费者"),
|
||||
CaCertificate("ca_certificate", "CA认证"),
|
||||
Certificate("certificate", "认证"),
|
||||
TARGETS("targets", "上游代理"),
|
||||
SYSTEM("system", "系统"),
|
||||
SYSTEM_ROLE("system_role", "系统角色"),
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.kongx.serve.feign;
|
||||
|
||||
import com.kongx.serve.entity.gateway.CaCertificate;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
@FeignClient(name = "caCertificateFeignService")
|
||||
public interface CaCertificateFeignService extends KongFeignService<CaCertificate> {
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.kongx.serve.feign;
|
||||
|
||||
import com.kongx.serve.entity.gateway.Certificate;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
@FeignClient(name = "certificateFeignService")
|
||||
public interface CertificateFeignService extends KongFeignService<Certificate> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.kongx.serve.feign;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = "credentialsFeignService")
|
||||
public interface CredentialsFeignService extends KongFeignService<Map> {
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.kongx.serve.feign;
|
||||
|
||||
import com.kongx.serve.entity.gateway.Sni;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
@FeignClient(name = "sniFeignService")
|
||||
public interface SniFeignService extends KongFeignService<Sni> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.kongx.serve.feign;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = "upstreamMapFeignService")
|
||||
public interface UpstreamMapFeignService extends KongFeignService<Map> {
|
||||
}
|
@ -15,7 +15,7 @@ import java.net.URISyntaxException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class AbstractService<T> {
|
||||
public abstract class AbstractCacheService<T> {
|
||||
|
||||
@Autowired
|
||||
protected ServerConfigService serverConfigService;
|
@ -0,0 +1,78 @@
|
||||
package com.kongx.serve.service;
|
||||
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public abstract class GatewayService<T> extends AbstractCacheService<KongEntity<T>> {
|
||||
|
||||
protected KongFeignService<T> kongFeignService;
|
||||
|
||||
protected String CACHE_KEY;
|
||||
|
||||
protected String ENTITY_URI = "";
|
||||
protected String ENTITY_URI_ID = "";
|
||||
|
||||
/**
|
||||
* 查询所有upstream
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public KongEntity<T> findAll(SystemProfile systemProfile) {
|
||||
return this.get(systemProfile, CACHE_KEY).getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public T add(SystemProfile systemProfile, T entity) throws Exception {
|
||||
T results = this.kongFeignService.add(uri(systemProfile, ENTITY_URI), entity);
|
||||
refresh(systemProfile, CACHE_KEY);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新sni
|
||||
*
|
||||
* @param id
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public T update(SystemProfile systemProfile, String id, T entity) throws Exception {
|
||||
T results = this.kongFeignService.update(uri(systemProfile, String.format(ENTITY_URI_ID, id)), entity);
|
||||
refresh(systemProfile, CACHE_KEY);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除sni
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public KongEntity<T> remove(SystemProfile systemProfile, String id) throws Exception {
|
||||
this.kongFeignService.remove(uri(systemProfile, String.format(ENTITY_URI_ID, id)));
|
||||
return refresh(systemProfile, CACHE_KEY).getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个sni的信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public T findEntity(SystemProfile systemProfile, String id) throws URISyntaxException {
|
||||
return this.kongFeignService.findById(uri(systemProfile, String.format(ENTITY_URI_ID, id)));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.gateway.CaCertificate;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.feign.CaCertificateFeignService;
|
||||
import com.kongx.serve.service.GatewayService;
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service("caCertificateService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class CaCertificateService extends GatewayService<CaCertificate> {
|
||||
@Autowired
|
||||
public CaCertificateService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
|
||||
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CaCertificateFeignService.class));
|
||||
ENTITY_URI = "/ca_certificates";
|
||||
ENTITY_URI_ID = "/ca_certificates/%s";
|
||||
CACHE_KEY = "LISTS";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String prefix() {
|
||||
return "CaCertificates";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CacheResults<KongEntity<CaCertificate>> loadFromClient(KongCacheKey key) throws URISyntaxException {
|
||||
log.info("Loading Services {} from kong client!", key);
|
||||
KongEntity<CaCertificate> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
|
||||
Collections.sort(kongEntity.getData());
|
||||
return new CacheResults<>(kongEntity);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.gateway.Certificate;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.feign.CertificateFeignService;
|
||||
import com.kongx.serve.service.GatewayService;
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service("certificateService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class CertificateService extends GatewayService<Certificate> {
|
||||
@Autowired
|
||||
public CertificateService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
|
||||
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CertificateFeignService.class));
|
||||
ENTITY_URI = "/certificates";
|
||||
ENTITY_URI_ID = "/certificates/%s";
|
||||
CACHE_KEY = "LISTS";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String prefix() {
|
||||
return "Certificates";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CacheResults<KongEntity<Certificate>> loadFromClient(KongCacheKey key) throws URISyntaxException {
|
||||
log.info("Loading Services {} from kong client!", key);
|
||||
KongEntity<Certificate> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
|
||||
Collections.sort(kongEntity.getData());
|
||||
return new CacheResults<>(kongEntity);
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.gateway.Consumer;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.feign.ConsumerFeignService;
|
||||
import com.kongx.serve.feign.CredentialsFeignService;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.Target;
|
||||
@ -20,23 +22,29 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("ConsumerService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class ConsumerService extends AbstractService<KongEntity<Consumer>> {
|
||||
public class ConsumerService extends AbstractCacheService<KongEntity<Consumer>> {
|
||||
private static final String CONSUMER_URI = "/consumers";
|
||||
private static final String CONSUMER_URI_ID = "/consumers/%s";
|
||||
private static final String CREDENTIALS_URI = "/consumers/%s/%s";
|
||||
private static final String CREDENTIALS_URI_ID = "/consumers/%s/%s/%s";
|
||||
|
||||
private static final String CACHE_CONSUMERS_KEY = "LISTS";
|
||||
|
||||
private KongFeignService<Consumer> kongFeignService;
|
||||
private KongFeignService<Map> credentialsFeignService;
|
||||
|
||||
@Autowired
|
||||
public ConsumerService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
|
||||
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(ConsumerFeignService.class))
|
||||
;
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(ConsumerFeignService.class));
|
||||
credentialsFeignService = Feign.builder().encoder(encoder).decoder(decoder)
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(CredentialsFeignService.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,6 +56,31 @@ public class ConsumerService extends AbstractService<KongEntity<Consumer>> {
|
||||
return this.get(systemProfile, CACHE_CONSUMERS_KEY).getData();
|
||||
}
|
||||
|
||||
public KongEntity<Map> findAllCredentials(SystemProfile systemProfile, String customerId, String credentials) throws URISyntaxException {
|
||||
return this.credentialsFeignService.findAll(uri(systemProfile, String.format(CREDENTIALS_URI, customerId, credentials)));
|
||||
}
|
||||
|
||||
public Map addCredentials(SystemProfile systemProfile, Map map, String customerId, String credentials) throws URISyntaxException {
|
||||
return this.credentialsFeignService.add(uri(systemProfile, String.format(CREDENTIALS_URI, customerId, credentials)), trim(map));
|
||||
}
|
||||
|
||||
private Map trim(Map map) {
|
||||
Map results = new HashMap();
|
||||
|
||||
map.keySet().stream().forEach((key) -> {
|
||||
Object value = map.get(key);
|
||||
if (value != null && !StringUtil.isEmpty(value.toString())) {
|
||||
results.put(key, value);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
public KongEntity<Map> removeCredentials(SystemProfile systemProfile, String customerId, String credentials, String id) throws Exception {
|
||||
this.credentialsFeignService.remove(uri(systemProfile, String.format(CREDENTIALS_URI_ID, customerId, credentials, id)));
|
||||
return this.findAllCredentials(systemProfile, customerId, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增upstream
|
||||
*
|
||||
|
@ -2,7 +2,7 @@ package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.feign.KongInfoFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
@ -19,7 +19,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Service("kongInfoService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
public class KongInfoService extends AbstractService {
|
||||
public class KongInfoService extends AbstractCacheService {
|
||||
|
||||
private static final String INFO_URI = "/";
|
||||
private static final String STATUS_URI = "/status";
|
||||
|
@ -4,7 +4,7 @@ import com.kongx.serve.entity.gateway.*;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.feign.PluginFeignService;
|
||||
import com.kongx.serve.feign.PluginVOFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
@ -23,10 +23,11 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Component("pluginService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
public class PluginService extends AbstractService {
|
||||
public class PluginService extends AbstractCacheService {
|
||||
private static final String PLUGIN_URI = "/plugins";
|
||||
private static final String PLUGIN_ROUTE_URI = "/routes/%s/plugins";
|
||||
private static final String PLUGIN_SERVICE_URI = "/services/%s/plugins";
|
||||
private static final String PLUGIN_CONSUMER_URI = "/consumers/%s/plugins";
|
||||
private static final String PLUGIN_URI_ID = "/plugins/%s";
|
||||
private static final String PLUGIN_URI_SCHEMA_NAME = "/plugins/schema/%s";
|
||||
|
||||
@ -101,6 +102,12 @@ public class PluginService extends AbstractService {
|
||||
return routeKongEntity;
|
||||
}
|
||||
|
||||
public KongEntity<PluginVO> findAllByConsumer(SystemProfile systemProfile, String serviceId) throws URISyntaxException {
|
||||
KongEntity<PluginVO> routeKongEntity = this.pluginVOFeignService.findAll(uri(systemProfile, String.format(PLUGIN_CONSUMER_URI, serviceId)));
|
||||
Collections.sort(routeKongEntity.getData());
|
||||
return routeKongEntity;
|
||||
}
|
||||
|
||||
public Plugin add(SystemProfile systemProfile, Plugin plugin) throws URISyntaxException {
|
||||
return this.kongFeignService.add(uri(systemProfile, PLUGIN_URI), plugin);
|
||||
}
|
||||
@ -113,6 +120,10 @@ public class PluginService extends AbstractService {
|
||||
return this.kongFeignService.add(uri(systemProfile, String.format(PLUGIN_SERVICE_URI, serviceId)), plugin);
|
||||
}
|
||||
|
||||
public Plugin addByConsumer(SystemProfile systemProfile, String consumerId, Plugin plugin) throws URISyntaxException {
|
||||
return this.kongFeignService.add(uri(systemProfile, String.format(PLUGIN_CONSUMER_URI, consumerId)), plugin);
|
||||
}
|
||||
|
||||
public Plugin update(SystemProfile systemProfile, String id, Plugin plugin) throws URISyntaxException {
|
||||
//先删除,再更新
|
||||
try {
|
||||
|
@ -7,7 +7,7 @@ import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.gateway.Route;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
import com.kongx.serve.feign.RouteFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
@ -24,7 +24,7 @@ import java.util.Collections;
|
||||
@Slf4j
|
||||
@Component("routeService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
public class RouteService extends AbstractService<KongEntity<Route>> {
|
||||
public class RouteService extends AbstractCacheService<KongEntity<Route>> {
|
||||
private static final String CACHE_ROUTES_KEY = "LISTS";
|
||||
private static final String ROUTE_URI = "/routes";
|
||||
private static final String ROUTE_URI_ID = "/routes/%s";
|
||||
|
@ -6,7 +6,7 @@ import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.gateway.Service;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
import com.kongx.serve.feign.ServiceFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
@ -22,7 +22,7 @@ import java.util.Collections;
|
||||
@Slf4j
|
||||
@org.springframework.stereotype.Service("serviceService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
public class ServiceService extends AbstractService<KongEntity<Service>> {
|
||||
public class ServiceService extends AbstractCacheService<KongEntity<Service>> {
|
||||
private static final String CACHE_SERVICES_KEY = "LISTS";
|
||||
private static final String SERVICE_URI = "/services";
|
||||
private static final String SERVICE_URI_ID = "/services/%s";
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.gateway.Sni;
|
||||
import com.kongx.serve.feign.SniFeignService;
|
||||
import com.kongx.serve.service.GatewayService;
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.Target;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service("sniService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class SniService extends GatewayService<Sni> {
|
||||
@Autowired
|
||||
public SniService(Decoder decoder, Encoder encoder, RequestInterceptor requestInterceptor) {
|
||||
kongFeignService = Feign.builder().encoder(encoder).decoder(decoder)
|
||||
.requestInterceptor(requestInterceptor).target(Target.EmptyTarget.create(SniFeignService.class));
|
||||
ENTITY_URI = "/snis";
|
||||
ENTITY_URI_ID = "/snis/%s";
|
||||
CACHE_KEY = "LISTS";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String prefix() {
|
||||
return "SNIS";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CacheResults<KongEntity<Sni>> loadFromClient(KongCacheKey key) throws URISyntaxException {
|
||||
log.info("Loading Services {} from kong client!", key);
|
||||
KongEntity<Sni> kongEntity = this.kongFeignService.findAll(uri(key.getSystemProfile(), ENTITY_URI));
|
||||
Collections.sort(kongEntity.getData());
|
||||
return new CacheResults<>(kongEntity);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import com.kongx.serve.entity.gateway.TargetHealth;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
import com.kongx.serve.feign.TargetFeignService;
|
||||
import com.kongx.serve.feign.TargetHealthFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
@ -22,7 +22,7 @@ import java.net.URISyntaxException;
|
||||
@Service("targetService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class TargetService extends AbstractService {
|
||||
public class TargetService extends AbstractCacheService {
|
||||
private static final String TARGET_URI = "/upstreams/%s/targets";
|
||||
private static final String TARGET_URI_HEALTH = "/upstreams/%s/health/";
|
||||
private static final String TARGET_URI_ID = "/upstreams/%s/targets/%s";
|
||||
|
@ -2,11 +2,11 @@ package com.kongx.serve.service.gateway;
|
||||
|
||||
import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.gateway.KongEntity;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.entity.gateway.Upstream;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.feign.KongFeignService;
|
||||
import com.kongx.serve.feign.UpstreamFeignService;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.Target;
|
||||
@ -24,7 +24,7 @@ import java.util.Collections;
|
||||
@Service("upstreamService")
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
@Slf4j
|
||||
public class UpstreamService extends AbstractService<KongEntity<Upstream>> {
|
||||
public class UpstreamService extends AbstractCacheService<KongEntity<Upstream>> {
|
||||
private static final String UPSTREAM_URI = "/upstreams";
|
||||
private static final String UPSTREAM_URI_ID = "/upstreams/%s";
|
||||
|
||||
|
@ -38,11 +38,35 @@ public abstract class AbstractSyncHandler implements ISyncHandler {
|
||||
@Autowired
|
||||
protected SyncLogService syncLogService;
|
||||
|
||||
@Autowired
|
||||
protected SniService sniService;
|
||||
|
||||
@Autowired
|
||||
protected ConsumerService consumerService;
|
||||
|
||||
@Autowired
|
||||
protected CertificateService certificateService;
|
||||
|
||||
@Autowired
|
||||
protected CaCertificateService caCertificateService;
|
||||
|
||||
|
||||
protected SyncLog syncLog(SyncConfig syncConfig, Object content, SystemProfile src, SystemProfile dest, String comment) {
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setContent(content);
|
||||
syncLog.setSyncNo(syncConfig.getSyncNo());
|
||||
syncLog.setSrc_client(src.getUrl());
|
||||
syncLog.setDest_client(dest.getUrl());
|
||||
syncLog.setComment(comment);
|
||||
return syncLog;
|
||||
}
|
||||
|
||||
protected SyncLog syncLog(SyncConfig syncConfig, Object content, Service service, SystemProfile src, SystemProfile dest) {
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setContent(content);
|
||||
syncLog.setService(service.getName());
|
||||
if (service != null) {
|
||||
syncLog.setService(service.getName());
|
||||
}
|
||||
syncLog.setSyncNo(syncConfig.getSyncNo());
|
||||
syncLog.setSrc_client(src.getUrl());
|
||||
syncLog.setDest_client(dest.getUrl());
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.kongx.serve.service.gateway.handler;
|
||||
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.entity.gateway.Service;
|
||||
import com.kongx.serve.entity.gateway.SyncConfig;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.service.gateway.ISyncHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("defaultSyncHandler")
|
||||
public class DefaultSyncHandler extends AbstractSyncHandler {
|
||||
@Override
|
||||
public ISyncHandler handler(SystemProfile srcClient, SystemProfile destClient, Service service, SyncConfig syncConfig, Object... values) throws Exception {
|
||||
|
@ -0,0 +1,46 @@
|
||||
package com.kongx.serve.service.gateway.handler;
|
||||
|
||||
import com.kongx.serve.entity.gateway.*;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.service.gateway.ISyncHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component("syncConsumersHandler")
|
||||
public class SyncConsumersHandler extends SyncPluginsHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public ISyncHandler handler(SystemProfile srcClient, SystemProfile destClient, Service service, SyncConfig syncConfig, Object... values) throws Exception {
|
||||
KongEntity<Consumer> consumerKongEntity = this.consumerService.findAll(srcClient);
|
||||
consumerKongEntity.getData().forEach((consumer -> {
|
||||
try {
|
||||
this.syncEntity(syncConfig, consumer, srcClient, destClient);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void syncEntity(SyncConfig syncConfig, Consumer consumer, SystemProfile srcClient, SystemProfile destClient) throws Exception {
|
||||
KongEntity<PluginVO> plugins = pluginService.findAllByConsumer(srcClient, consumer.getId());
|
||||
this.consumerService.update(destClient, consumer.getId(), consumer);
|
||||
for (PluginVO plugin : plugins.getData()) {
|
||||
EntityId entityId = new EntityId();
|
||||
entityId.setId(consumer.getId());
|
||||
plugin.setService(entityId);
|
||||
if (consumer != null) {
|
||||
plugin.setScope("global");
|
||||
Map map = new HashMap();
|
||||
map.put("name", consumer.getId());
|
||||
plugin.setApplyObject(map);
|
||||
}
|
||||
this.syncPlugin(syncConfig, plugin, null, srcClient, destClient);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.kongx.common.cache.CacheResults;
|
||||
import com.kongx.serve.entity.system.ServerConfig;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.mapper.ServerConfigMapper;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -15,7 +15,7 @@ import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("ServerConfigService")
|
||||
public class ServerConfigService extends AbstractService<List<ServerConfig>> {
|
||||
public class ServerConfigService extends AbstractCacheService<List<ServerConfig>> {
|
||||
private static final String SERVERS_CONFIGS_KEY = "LISTS";
|
||||
@Autowired
|
||||
private ServerConfigMapper serverConfigMapper;
|
||||
@ -48,7 +48,7 @@ public class ServerConfigService extends AbstractService<List<ServerConfig>> {
|
||||
|
||||
public URI findUriByCode(SystemProfile systemProfile, String code) throws Exception {
|
||||
ServerConfig serverConfig = serverConfigService.findByKey(code);
|
||||
SystemProfile.System system = systemProfile.to(serverConfig.getConfigValue());
|
||||
SystemProfile.System system = systemProfile.to(serverConfig.getConfigValue().toString());
|
||||
if (system == null) throw new Exception("Please set Hot config url");
|
||||
String url = system.getUrl();
|
||||
if (url.endsWith("/")) {
|
||||
|
@ -4,7 +4,7 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.kongx.serve.entity.system.SystemProfile;
|
||||
import com.kongx.serve.mapper.SystemProfileMapper;
|
||||
import com.kongx.serve.service.AbstractService;
|
||||
import com.kongx.serve.service.AbstractCacheService;
|
||||
import com.kongx.serve.service.gateway.KongInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -15,7 +15,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("SystemProfileService")
|
||||
public class SystemProfileService extends AbstractService {
|
||||
public class SystemProfileService extends AbstractCacheService {
|
||||
|
||||
@Autowired
|
||||
private SystemProfileMapper systemProfileMapper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user