1、修复1.3.1版本路由增加失败的问题

2、修复修改插件时,下拉列表无法回显用户所选择的数据
This commit is contained in:
raoxiaoyan 2020-11-26 18:39:54 +08:00
parent 6dff4ef19a
commit 1711668a9c
22 changed files with 220 additions and 18 deletions

View File

@ -0,0 +1,30 @@
package com.kongx.serve.controller.flow;
import com.kongx.serve.controller.system.DefaultController;
import com.kongx.serve.entity.flow.ServicePipeline;
import com.kongx.serve.entity.system.OperationLog;
import com.kongx.serve.service.IBaseService;
import com.kongx.serve.service.flow.ServicePipelineService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController("/ServiceFlowController")
@RequestMapping("/kong/api/pipeline")
public class ServicePipelineController extends DefaultController<ServicePipeline, Integer> {
@Resource(name = "servicePipelineService")
private ServicePipelineService servicePipelineService;
@Override
@Resource(name = "servicePipelineService")
protected void setBaseService(IBaseService<ServicePipeline, Integer> iBaseService) {
this.baseService = iBaseService;
}
@Override
protected OperationLog.OperationTarget operationTarget() {
return OperationLog.OperationTarget.SERVICE_PIPELINE;
}
}

View File

@ -113,8 +113,8 @@ public class RouteController extends BaseController {
public JsonHeaderWrapper add(UserInfo userInfo, @PathVariable String serviceId, @RequestBody Route route) { public JsonHeaderWrapper add(UserInfo userInfo, @PathVariable String serviceId, @RequestBody Route route) {
JsonHeaderWrapper jsonHeaderWrapper = this.init(); JsonHeaderWrapper jsonHeaderWrapper = this.init();
try { try {
KongEntity<Route> routeKongEntity = this.kongFeignService.add(systemProfile(userInfo), serviceId, route.clear()); Route results = this.kongFeignService.add(systemProfile(userInfo), serviceId, route.clear());
jsonHeaderWrapper.setData(routeKongEntity.getData()); jsonHeaderWrapper.setData(results);
} catch (Exception e) { } catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode()); jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage()); jsonHeaderWrapper.setErrmsg(e.getMessage());

View File

@ -60,7 +60,7 @@ public class TargetController extends BaseController {
public JsonHeaderWrapper add(UserInfo userInfo, @PathVariable String id, @RequestBody Target target) { public JsonHeaderWrapper add(UserInfo userInfo, @PathVariable String id, @RequestBody Target target) {
JsonHeaderWrapper jsonHeaderWrapper = init(); JsonHeaderWrapper jsonHeaderWrapper = init();
try { try {
this.targetFeignService.add(systemProfile(userInfo), id, target); jsonHeaderWrapper.setData(this.targetFeignService.add(systemProfile(userInfo), id, target));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode()); jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());

View File

@ -6,6 +6,7 @@ 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.service.IBaseService; import com.kongx.serve.service.IBaseService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -65,6 +66,30 @@ public abstract class DefaultController<T, PK> extends BaseController {
return jsonHeaderWrapper; return jsonHeaderWrapper;
} }
@RequestMapping(path = "/{id}", method = RequestMethod.GET)
public JsonHeaderWrapper findById(@PathVariable Integer id) {
JsonHeaderWrapper jsonHeaderWrapper = init();
try {
jsonHeaderWrapper.setData(this.baseService.findById(id));
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
@RequestMapping(path = "/{id}", method = RequestMethod.DELETE)
public JsonHeaderWrapper removeById(@PathVariable Integer id) {
JsonHeaderWrapper jsonHeaderWrapper = init();
try {
this.baseService.remove(id);
} catch (Exception e) {
jsonHeaderWrapper.setStatus(JsonHeaderWrapper.StatusEnum.Failed.getCode());
jsonHeaderWrapper.setErrmsg(e.getMessage());
}
return jsonHeaderWrapper;
}
protected abstract void setBaseService(IBaseService<T, PK> iBaseService); protected abstract void setBaseService(IBaseService<T, PK> iBaseService);
protected abstract OperationLog.OperationTarget operationTarget(); protected abstract OperationLog.OperationTarget operationTarget();

View File

@ -0,0 +1,15 @@
package com.kongx.serve.entity.flow;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class FlowNode {
private List coordinate = new ArrayList<Integer>();
private int height;
private String id;
private NodeMeta meta;
private int width;
}

View File

@ -0,0 +1,13 @@
package com.kongx.serve.entity.flow;
import lombok.Data;
import java.util.Map;
@Data
public class NodeMeta {
private Map entity;
private String id;
private String name;
private String prop;
}

View File

@ -0,0 +1,17 @@
package com.kongx.serve.entity.flow;
import com.kongx.common.core.entity.BaseEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Data
public class ServicePipeline extends BaseEntity {
private String name;
private String img = "/img/plugins/kong.svg";
private List linkList = new ArrayList<Map>();
private List nodeList = new ArrayList<FlowNode>();
private List origin = new ArrayList<Integer>();
}

View File

@ -98,6 +98,7 @@ public class OperationLog {
USER_INFO("user_info", "用户信息"), USER_INFO("user_info", "用户信息"),
SYSTEM_PROFILE("system_profile", "系统环境"), SYSTEM_PROFILE("system_profile", "系统环境"),
SERVER_CONFIG("service_config", "系统配置"), SERVER_CONFIG("service_config", "系统配置"),
SERVICE_PIPELINE("service_pipeline", "网关服务流水线"),
LOGGER_LEVEL("logger_level", "日志级别"); LOGGER_LEVEL("logger_level", "日志级别");
private String type; private String type;
private String target; private String target;

View File

@ -0,0 +1,50 @@
package com.kongx.serve.mapper;
import com.kongx.common.handler.JSONHandler;
import com.kongx.serve.entity.flow.ServicePipeline;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface ServicePipelineMapper {
@Select({"<script>", "SELECT * FROM kongx_service_pipeline where 1=1 ",
"<when test='job.name!=null'>",
" and (name like CONCAT('%',#{job.name},'%'))",
"</when>",
"order by create_at desc", "</script>"})
@Results({
@Result(property = "linkList", column = "link_list", typeHandler = JSONHandler.class),
@Result(property = "nodeList", column = "node_list", typeHandler = JSONHandler.class),
})
List<ServicePipeline> findAll(@Param("job") ServicePipeline project);
@Insert({"insert into kongx_service_pipeline(name,link_list,node_list,origin,remark,creator,create_at) values (",
"#{name},#{linkList,typeHandler=com.kongx.common.handler.JSONHandler},",
"#{nodeList,typeHandler=com.kongx.common.handler.JSONHandler},",
"#{origin,typeHandler=com.kongx.common.handler.JSONHandler},",
"#{remark},",
"#{creator}, #{create_at, jdbcType=TIMESTAMP}",
")"})
int insert(ServicePipeline project);
@Update({"update kongx_service_pipeline set " +
"name=#{name},",
"link_list=#{linkList,typeHandler=com.kongx.common.handler.JSONHandler},",
"node_list=#{nodeList,typeHandler=com.kongx.common.handler.JSONHandler},",
"origin=#{origin,typeHandler=com.kongx.common.handler.JSONHandler},",
"modifier=#{modifier},modify_at=#{modify_at, jdbcType=TIMESTAMP},",
"remark=#{remark} where id=#{id} "})
int update(ServicePipeline project);
@Select({"select * from kongx_service_pipeline where id = #{id} "})
@Results({
@Result(property = "linkList", column = "link_list", typeHandler = JSONHandler.class),
@Result(property = "nodeList", column = "node_list", typeHandler = JSONHandler.class),
})
ServicePipeline findById(int id);
@Delete("delete from kongx_service_pipeline where id=#{id}")
int deleteById(int id);
}

View File

@ -17,6 +17,9 @@ public interface IBaseService<T, PK> {
void add(T entity, UserInfo userInfo); void add(T entity, UserInfo userInfo);
default void remove(int pk) {
}
void update(T entity, UserInfo userInfo); void update(T entity, UserInfo userInfo);
T findById(PK id); T findById(PK id);

View File

@ -0,0 +1,48 @@
package com.kongx.serve.service.flow;
import com.kongx.common.core.entity.UserInfo;
import com.kongx.serve.entity.flow.ServicePipeline;
import com.kongx.serve.mapper.ServicePipelineMapper;
import com.kongx.serve.service.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("servicePipelineService")
public class ServicePipelineService implements IBaseService<ServicePipeline, Integer> {
@Autowired
private ServicePipelineMapper servicePipelineMapper;
@Override
public List<ServicePipeline> findAll(ServicePipeline entity) {
return this.servicePipelineMapper.findAll(entity);
}
@Override
public void add(ServicePipeline entity, UserInfo userInfo) {
entity.setCreator(userInfo.getName());
entity.setCreate_at(new Date());
this.servicePipelineMapper.insert(entity);
}
@Override
public void update(ServicePipeline entity, UserInfo userInfo) {
entity.setModifier(userInfo.getName());
entity.setModify_at(new Date());
this.servicePipelineMapper.update(entity);
}
@Override
public void remove(int pk) {
this.servicePipelineMapper.deleteById(pk);
}
@Override
public ServicePipeline findById(Integer id) {
return this.servicePipelineMapper.findById(id);
}
}

View File

@ -74,9 +74,10 @@ public class RouteService extends AbstractCacheService<KongEntity<Route>> {
* @return * @return
* @throws URISyntaxException * @throws URISyntaxException
*/ */
public KongEntity<Route> add(SystemProfile systemProfile, String serviceId, Route route) throws URISyntaxException { public Route add(SystemProfile systemProfile, String serviceId, Route route) throws URISyntaxException {
this.kongFeignService.add(uri(systemProfile, String.format(ROUTE_SERVICE_URI, serviceId)), route); Route results = this.kongFeignService.add(uri(systemProfile, String.format(ROUTE_SERVICE_URI, serviceId)), route);
return this.refresh(systemProfile, CACHE_ROUTES_KEY).getData(); this.refresh(systemProfile, CACHE_ROUTES_KEY);
return results;
} }
/** /**

View File

@ -63,9 +63,8 @@ public class TargetService extends AbstractCacheService {
* @return * @return
* @throws URISyntaxException * @throws URISyntaxException
*/ */
public KongEntity<Target> add(SystemProfile systemProfile, String id, Target target) throws URISyntaxException { public Target add(SystemProfile systemProfile, String id, Target target) throws URISyntaxException {
this.targetFeignService.add(uri(systemProfile, String.format(TARGET_URI, id)), target); return this.targetFeignService.add(uri(systemProfile, String.format(TARGET_URI, id)), target);
return findAll(systemProfile, id);
} }
/** /**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black><meta name=format-detection content="telephone=no"><meta http-equiv=X-UA-Compatible content="chrome=1"><link rel=stylesheet href=cdn/element-ui/2.13.0/theme-chalk/index.css><link rel=stylesheet href=cdn/animate/3.5.2/animate.css><link rel=stylesheet href=cdn/iconfont/1.0.0/index.css><link rel=stylesheet href="https://fonts.googleapis.com/icon?family=Material+Icons"><link rel=icon href=favicon.ico><title>kongx</title><style>html, <!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black><meta name=format-detection content="telephone=no"><meta http-equiv=X-UA-Compatible content="chrome=1"><link rel=stylesheet href=cdn/element-ui/2.13.0/theme-chalk/index.css><link rel=stylesheet href=cdn/animate/3.5.2/animate.css><link rel=stylesheet href=cdn/iconfont/1.0.0/index.css><link rel=stylesheet href="https://fonts.googleapis.com/icon?family=Material+Icons"><link rel=icon href=favicon.ico><script src=https://cdn.staticfile.org/jsPlumb/2.11.1/js/jsplumb.min.js></script><title>kongx</title><style>html,
body, body,
#app { #app {
height: 100%; height: 100%;
@ -51,4 +51,4 @@
.avue-home__sub-title { .avue-home__sub-title {
color: #ABABAB; color: #ABABAB;
font-size: 12px; font-size: 12px;
}</style><link href=css/chunk-05d1190a.889d7b72.css rel=prefetch><link href=css/chunk-e71f815c.ab7edb4f.css rel=prefetch><link href=css/page.5cf41a71.css rel=prefetch><link href=js/chunk-05d1190a.b42234c2.js rel=prefetch><link href=js/chunk-2d0e4caf.fea686c4.js rel=prefetch><link href=js/chunk-e71f815c.1647f971.js rel=prefetch><link href=js/page.114cf767.js rel=prefetch><link href=js/views.4d62ea9b.js rel=prefetch><link href=css/app.6db76f0a.css rel=preload as=style><link href=css/chunk-vendors.e426cd01.css rel=preload as=style><link href=js/app.b22022b5.js rel=preload as=script><link href=js/chunk-vendors.48ed5c43.js rel=preload as=script><link href=css/chunk-vendors.e426cd01.css rel=stylesheet><link href=css/app.6db76f0a.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有 JavaScript 支持Avue-cli 将不能正常工作。请启用浏览器的 JavaScript 然后继续。</strong></noscript><div id=app><div class=avue-home><div class=avue-home__main><img class=avue-home__loading src=./svg/loading-spin.svg alt=loading><div class=avue-home__title>正在加载资源</div><div class=avue-home__sub-title>初次加载资源可能需要较多时间 请耐心等待</div></div><div class=avue-home__footer><a href=https://gitee.com/raoxy/kongx target=_blank>https://gitee.com/raoxy/kongx</a></div></div></div><script src=util/aes.js charset=utf-8></script><script src=cdn/vue/2.6.10/vue.min.js charset=utf-8></script><script src=cdn/vuex/3.0.1/vuex.min.js charset=utf-8></script><script src=cdn/vue-router/3.0.1/vue-router.min.js charset=utf-8></script><script src=cdn/axios/1.0.0/axios.min.js charset=utf-8></script><script src=cdn/element-ui/2.13.0/index.js charset=utf-8></script><script src=cdn/xlsx/0.14.1/xlsx.full.min.js charset=utf-8></script><script src=cdn/fileSaver/1.3.8/FileSaver.min.js charset=utf-8></script><script src=cdn/lodash/4.13.1/lodash.min.js charset=utf-8></script><script src=js/chunk-vendors.48ed5c43.js></script><script src=js/app.b22022b5.js></script></body></html> }</style><link href=css/chunk-05d1190a.889d7b72.css rel=prefetch><link href=css/chunk-5ffe123b.541b2dcd.css rel=prefetch><link href=css/page.5cf41a71.css rel=prefetch><link href=js/chunk-05d1190a.b42234c2.js rel=prefetch><link href=js/chunk-2d0e4caf.fea686c4.js rel=prefetch><link href=js/chunk-5ffe123b.ebbf3c2a.js rel=prefetch><link href=js/page.114cf767.js rel=prefetch><link href=js/views.4d62ea9b.js rel=prefetch><link href=css/app.21cbf1c9.css rel=preload as=style><link href=css/chunk-vendors.425c1559.css rel=preload as=style><link href=js/app.4b7f7c81.js rel=preload as=script><link href=js/chunk-vendors.a94c5304.js rel=preload as=script><link href=css/chunk-vendors.425c1559.css rel=stylesheet><link href=css/app.21cbf1c9.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有 JavaScript 支持Avue-cli 将不能正常工作。请启用浏览器的 JavaScript 然后继续。</strong></noscript><div id=app><div class=avue-home><div class=avue-home__main><img class=avue-home__loading src=./svg/loading-spin.svg alt=loading><div class=avue-home__title>正在加载资源</div><div class=avue-home__sub-title>初次加载资源可能需要较多时间 请耐心等待</div></div><div class=avue-home__footer><a href=https://gitee.com/raoxy/kongx target=_blank>https://gitee.com/raoxy/kongx</a></div></div></div><script src=util/aes.js charset=utf-8></script><script src=cdn/vue/2.6.10/vue.min.js charset=utf-8></script><script src=cdn/vuex/3.0.1/vuex.min.js charset=utf-8></script><script src=cdn/vue-router/3.0.1/vue-router.min.js charset=utf-8></script><script src=cdn/axios/1.0.0/axios.min.js charset=utf-8></script><script src=cdn/element-ui/2.13.0/index.js charset=utf-8></script><script src=cdn/xlsx/0.14.1/xlsx.full.min.js charset=utf-8></script><script src=cdn/fileSaver/1.3.8/FileSaver.min.js charset=utf-8></script><script src=cdn/lodash/4.13.1/lodash.min.js charset=utf-8></script><script src=js/chunk-vendors.a94c5304.js></script><script src=js/app.4b7f7c81.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long