mirror of
https://gitee.com/raoxy/kongx.git
synced 2025-07-23 00:00:01 +08:00
优化环境管理
This commit is contained in:
parent
ae9244d179
commit
9419ec5a3d
@ -23,6 +23,5 @@ public class HealthCheckController {
|
|||||||
@RequestMapping(value = "/health/check")
|
@RequestMapping(value = "/health/check")
|
||||||
public void check(HttpServletResponse response) {
|
public void check(HttpServletResponse response) {
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,4 @@ public class SignInController {
|
|||||||
@RequestParam(value = "logout", required = false) String logout) {
|
@RequestParam(value = "logout", required = false) String logout) {
|
||||||
return "index.html";
|
return "index.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.kongx.serve.controller.system;
|
package com.kongx.serve.controller.system;
|
||||||
|
|
||||||
|
import com.kongx.common.core.entity.UserInfo;
|
||||||
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
import com.kongx.common.jsonwrapper.JsonHeaderWrapper;
|
||||||
import com.kongx.serve.controller.BaseController;
|
import com.kongx.serve.controller.BaseController;
|
||||||
import com.kongx.serve.entity.system.OperationLog;
|
import com.kongx.serve.entity.system.OperationLog;
|
||||||
import com.kongx.serve.entity.system.SystemProfile;
|
import com.kongx.serve.entity.system.SystemProfile;
|
||||||
import com.kongx.common.core.entity.UserInfo;
|
|
||||||
import com.kongx.serve.service.system.SystemProfileService;
|
import com.kongx.serve.service.system.SystemProfileService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -64,6 +64,20 @@ public class SystemProfileController extends BaseController {
|
|||||||
return jsonHeaderWrapper;
|
return jsonHeaderWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/profiles/probing", method = RequestMethod.POST)
|
||||||
|
public JsonHeaderWrapper probing(@RequestBody SystemProfile systemProfile) {
|
||||||
|
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||||
|
try {
|
||||||
|
Map map = this.systemProfileService.probing(systemProfile);
|
||||||
|
jsonHeaderWrapper.setData(map.get("version"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
jsonHeaderWrapper.setErrmsg(e.getMessage());
|
||||||
|
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
|
||||||
|
}
|
||||||
|
return jsonHeaderWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/profiles/{clientId}", method = RequestMethod.POST)
|
@RequestMapping(value = "/profiles/{clientId}", method = RequestMethod.POST)
|
||||||
public JsonHeaderWrapper update(@PathVariable int clientId, @RequestBody SystemProfile systemProfile, UserInfo userInfo) {
|
public JsonHeaderWrapper update(@PathVariable int clientId, @RequestBody SystemProfile systemProfile, UserInfo userInfo) {
|
||||||
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
JsonHeaderWrapper jsonHeaderWrapper = this.init();
|
||||||
|
@ -21,16 +21,14 @@ public class SystemProfile {
|
|||||||
|
|
||||||
private String env;
|
private String env;
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
private String deployType;
|
private String deployType;
|
||||||
|
|
||||||
private String ab;//环境缩写
|
private String ab;//环境缩写
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
private String consul_url;
|
|
||||||
|
|
||||||
private String config_url;
|
|
||||||
|
|
||||||
private String extensions = "[]";//扩展配置
|
private String extensions = "[]";//扩展配置
|
||||||
|
|
||||||
private String creator;
|
private String creator;
|
||||||
|
@ -14,15 +14,14 @@ public interface SystemProfileMapper {
|
|||||||
})
|
})
|
||||||
List<SystemProfile> findAll();
|
List<SystemProfile> findAll();
|
||||||
|
|
||||||
@Insert({"insert into kongx_system_profile(profile_code,name,env,deploy_type,ab,url, consul_url,config_url,extensions,profile, creator, create_at) " +
|
@Insert({"insert into kongx_system_profile(profile_code,name,env,deploy_type,ab,url,version, extensions,profile, creator, create_at) " +
|
||||||
"values(#{profileCode},#{name},#{env},#{deployType},#{ab}, #{url},#{consul_url},#{config_url},#{extensions}, #{profile}, #{creator}, #{create_at, jdbcType=TIMESTAMP})"})
|
"values(#{profileCode},#{name},#{env},#{deployType},#{ab}, #{url},#{version},#{extensions}, #{profile}, #{creator}, #{create_at, jdbcType=TIMESTAMP})"})
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||||
int add(SystemProfile systemProfile);
|
int add(SystemProfile systemProfile);
|
||||||
|
|
||||||
@Update({"update kongx_system_profile set ",
|
@Update({"update kongx_system_profile set ",
|
||||||
"profile_code=#{client.profileCode},name=#{client.name},ab=#{client.ab},url=#{client.url},",
|
"profile_code=#{client.profileCode},name=#{client.name},ab=#{client.ab},url=#{client.url},",
|
||||||
"env=#{client.env},deploy_type=#{client.deployType},",
|
"env=#{client.env},deploy_type=#{client.deployType},version=#{client.version},",
|
||||||
"consul_url=#{client.consul_url},config_url=#{client.config_url},",
|
|
||||||
"extensions=#{client.extensions},profile=#{client.profile} where id=#{client.id}"})
|
"extensions=#{client.extensions},profile=#{client.profile} where id=#{client.id}"})
|
||||||
int update(@Param("client") SystemProfile client);
|
int update(@Param("client") SystemProfile client);
|
||||||
|
|
||||||
|
@ -37,4 +37,6 @@ public class KongInfoService extends AbstractService {
|
|||||||
public Map status(SystemProfile systemProfile) throws URISyntaxException {
|
public Map status(SystemProfile systemProfile) throws URISyntaxException {
|
||||||
return kongInfoFeignService.status(uri(systemProfile, STATUS_URI));
|
return kongInfoFeignService.status(uri(systemProfile, STATUS_URI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ public class EnvService {
|
|||||||
values.forEach((profile) -> {
|
values.forEach((profile) -> {
|
||||||
Map map = new HashMap<>();
|
Map map = new HashMap<>();
|
||||||
map.put("label", profile.get("code"));
|
map.put("label", profile.get("code"));
|
||||||
map.put("value", profile.get("profile"));
|
|
||||||
map.put("profile", deployType + "" + profile.get("profile"));
|
map.put("profile", deployType + "" + profile.get("profile"));
|
||||||
|
map.put("value", deployType + "" + profile.get("profile"));
|
||||||
map.put("profileCode", profile.get("code"));
|
map.put("profileCode", profile.get("code"));
|
||||||
results.add(map);
|
results.add(map);
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.kongx.serve.service.system;
|
package com.kongx.serve.service.system;
|
||||||
|
|
||||||
import com.kongx.serve.entity.system.SystemProfile;
|
|
||||||
import com.kongx.serve.mapper.SystemProfileMapper;
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
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.gateway.KongInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service("SystemProfileService")
|
@Service("SystemProfileService")
|
||||||
public class SystemProfileService {
|
public class SystemProfileService extends AbstractService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemProfileMapper systemProfileMapper;
|
private SystemProfileMapper systemProfileMapper;
|
||||||
@ -21,6 +23,13 @@ public class SystemProfileService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EnvService envService;
|
private EnvService envService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private KongInfoService kongInfoService;
|
||||||
|
|
||||||
|
public Map probing(SystemProfile systemProfile) throws Exception {
|
||||||
|
return this.kongInfoService.info(systemProfile);
|
||||||
|
}
|
||||||
|
|
||||||
protected Cache<String, SystemProfile> KONG_CLIENT_CACHE = CacheBuilder.newBuilder()
|
protected Cache<String, SystemProfile> KONG_CLIENT_CACHE = CacheBuilder.newBuilder()
|
||||||
.maximumSize(1000)
|
.maximumSize(1000)
|
||||||
.build();
|
.build();
|
||||||
@ -73,7 +82,7 @@ public class SystemProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, Object>> findAllByGroup() {
|
public List<Map<String, Object>> findAllByGroup() {
|
||||||
List<Map<String,Object>> systemProfiles = new ArrayList<>();
|
List<Map<String, Object>> systemProfiles = new ArrayList<>();
|
||||||
List<SystemProfile> results = this.systemProfileMapper.findAll();
|
List<SystemProfile> results = this.systemProfileMapper.findAll();
|
||||||
List<Map> envs = this.envService.findAllEnvs();
|
List<Map> envs = this.envService.findAllEnvs();
|
||||||
for (Map env : envs) {
|
for (Map env : envs) {
|
||||||
|
@ -9,7 +9,7 @@ spring:
|
|||||||
server:
|
server:
|
||||||
port: 8095
|
port: 8095
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /
|
context-path: /kongx
|
||||||
mybatis:
|
mybatis:
|
||||||
configuration:
|
configuration:
|
||||||
default-fetch-size: 100
|
default-fetch-size: 100
|
||||||
|
Loading…
x
Reference in New Issue
Block a user