mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
合并结果
This commit is contained in:
@@ -161,6 +161,9 @@ xblock{
|
||||
.x-green{
|
||||
color: green;
|
||||
}
|
||||
.x-yellow{
|
||||
color: #ffae19;
|
||||
}
|
||||
.x-a{
|
||||
color: #1AA093;
|
||||
}
|
||||
|
180
sop-admin/sop-admin-front/assets/js/Form.js
Normal file
180
sop-admin/sop-admin-front/assets/js/Form.js
Normal file
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* 表单插件,使用方法:
|
||||
* var myform = layui.Form('formId');
|
||||
* myform.setData({...})
|
||||
*
|
||||
* var data = myform.getData();
|
||||
*
|
||||
* var name = myform.getData('name')
|
||||
*/
|
||||
layui.define(function (exports) {
|
||||
|
||||
/**
|
||||
* form = new Form('formId');
|
||||
* @param formId
|
||||
* @constructor
|
||||
*/
|
||||
var Form = function (formId) {
|
||||
this.$form = $('#' + formId);
|
||||
this.parseForm(this.$form);
|
||||
}
|
||||
|
||||
Form.prototype = {
|
||||
fire: function (eventName, data) {
|
||||
var handler = this['on' + eventName];
|
||||
handler && handler(data);
|
||||
}
|
||||
, opt: function (attr) {
|
||||
return this[attr];
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
, parseForm: function ($form) {
|
||||
var that = this;
|
||||
this.form = $form[0];
|
||||
this.$els = $form.find('input,select,textarea');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同load(data)
|
||||
*/
|
||||
, setData: function (data) {
|
||||
this.loadData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
, loadData: function (data) {
|
||||
this.reset();
|
||||
for (var name in data) {
|
||||
var val = data[name];
|
||||
var $el = this.$form.find('[name="' + name + '"]');
|
||||
|
||||
$el.each(function () {
|
||||
var _$el = $(this);
|
||||
if (_$el.is(':radio') || _$el.is(':checkbox')) {
|
||||
_$el.prop('checked', false);
|
||||
var elVal = _$el.val();
|
||||
|
||||
if ($.isArray(val)) {
|
||||
for (var i = 0, len = val.length; i < len; i++) {
|
||||
if (elVal == val[i]) {
|
||||
_$el.prop('checked', true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_$el.prop('checked', elVal == val);
|
||||
}
|
||||
|
||||
} else {
|
||||
_$el.val(val);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 清除表单中的值,清除错误信息
|
||||
*/
|
||||
, clear: function () {
|
||||
this.$els.each(function () {
|
||||
var _$el = $(this);
|
||||
if (_$el.is(':radio') || _$el.is(':checkbox')) {
|
||||
this.checked = false;
|
||||
} else {
|
||||
this.value = '';
|
||||
}
|
||||
|
||||
var msg = _$el.data('msg');
|
||||
if (msg) {
|
||||
msg.text('');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 重置表单
|
||||
*/
|
||||
, reset: function () {
|
||||
var form = this.form;
|
||||
if (form && form.reset) {
|
||||
form.reset();
|
||||
} else {
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取表单数据,如果有fieldName参数则返回表单对应的值<br>
|
||||
* var id = form.getData('id') 等同于 var id = form.getData().id;
|
||||
* @param {String} fieldName
|
||||
* @return {Object} 返回JSON对象,如果有fieldName参数,则返回对应的值
|
||||
*/
|
||||
, getData: function (fieldName) {
|
||||
var that = this;
|
||||
var data = {};
|
||||
|
||||
this.$els.each(function () {
|
||||
var value = that._getInputVal($(this));
|
||||
if (value) {
|
||||
var name = this.name;
|
||||
var dataValue = data[name];
|
||||
if (dataValue) {
|
||||
if ($.isArray(dataValue)) {
|
||||
dataValue.push(value);
|
||||
} else {
|
||||
data[name] = [dataValue, value];
|
||||
}
|
||||
} else {
|
||||
data[name] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof fieldName === 'string') {
|
||||
return data[fieldName];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
, getFormData: function ($form) {
|
||||
var data = {};
|
||||
var dataArr = $form.serializeArray();
|
||||
for (var i = 0, len = dataArr.length; i < len; i++) {
|
||||
var item = dataArr[i];
|
||||
var name = item.name;
|
||||
var itemValue = item.value;
|
||||
var dataValue = data[name];
|
||||
|
||||
if (dataValue) {
|
||||
if ($.isArray(dataValue)) {
|
||||
dataValue.push(itemValue);
|
||||
} else {
|
||||
data[name] = [dataValue, itemValue];
|
||||
}
|
||||
} else {
|
||||
data[name] = itemValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
, _getInputVal: function ($input) {
|
||||
if ($input.is(":radio") || $input.is(":checkbox")) {
|
||||
if ($input.is(':checked')) {
|
||||
return $input.val();
|
||||
}
|
||||
} else {
|
||||
return $input.val();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports('Form', function (formId) {
|
||||
return new Form(formId);
|
||||
});
|
||||
});
|
@@ -14,6 +14,7 @@ var lib = (function () {
|
||||
,'../../assets/lib/layui/layui.js'
|
||||
,'../../assets/lib/easyopen/sdk.js'
|
||||
,'../../assets/js/ApiUtil.js'
|
||||
,'../../assets/js/Form.js'
|
||||
,'../../assets/js/profile.js'
|
||||
]
|
||||
|
||||
@@ -53,7 +54,7 @@ var lib = (function () {
|
||||
}
|
||||
return jsArr;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
/**
|
||||
* 加载js模块
|
||||
|
@@ -82,18 +82,25 @@
|
||||
<input type="text" name="path" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">合并结果</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="mergeResult" value="1" title="合并">
|
||||
<input type="radio" name="mergeResult" value="0" title="不合并">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">忽略验证</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="ignoreValidate" value="true" title="是">
|
||||
<input type="radio" name="ignoreValidate" value="false" title="否">
|
||||
<input type="radio" name="ignoreValidate" value="1" title="是">
|
||||
<input type="radio" name="ignoreValidate" value="0" title="否">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="disabled" value="false" title="启用">
|
||||
<input type="radio" name="disabled" value="true" title="<span class='x-red'>禁用</span>">
|
||||
<input type="radio" name="status" value="1" title="启用">
|
||||
<input type="radio" name="status" value="2" title="<span class='x-red'>禁用</span>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
@@ -127,18 +134,25 @@
|
||||
<input type="text" name="path" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">合并结果</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="mergeResult" value="1" title="合并">
|
||||
<input type="radio" name="mergeResult" value="0" title="不合并">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">忽略验证</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="ignoreValidate" value="true" title="是">
|
||||
<input type="radio" name="ignoreValidate" value="false" title="否">
|
||||
<input type="radio" name="ignoreValidate" value="1" title="是">
|
||||
<input type="radio" name="ignoreValidate" value="0" title="否">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="disabled" value="false" title="启用">
|
||||
<input type="radio" name="disabled" value="true" title="<span class='x-red'>禁用</span>">
|
||||
<input type="radio" name="status" value="1" title="启用">
|
||||
<input type="radio" name="status" value="2" title="<span class='x-red'>禁用</span>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
|
@@ -1,13 +1,20 @@
|
||||
lib.use(['element', 'table', 'tree', 'form'], function () {
|
||||
var ROUTE_STATUS = {
|
||||
'0': '待审核'
|
||||
,'1': '<span class="x-green">已启用</span>'
|
||||
,'2': '<span class="x-red">已禁用</span>'
|
||||
}
|
||||
var profile = window.profile;
|
||||
var form = layui.form;
|
||||
var updateForm = layui.Form('updateForm');
|
||||
var addForm = layui.Form('addForm');
|
||||
var table = layui.table;
|
||||
|
||||
var currentServiceId;
|
||||
var routeTable;
|
||||
var profile = window.profile;
|
||||
var $updateForm = $('#updateForm');
|
||||
var $addForm = $('#addForm');
|
||||
var smTitle;
|
||||
|
||||
|
||||
form.on('submit(searchFilter)', function (data) {
|
||||
var param = data.field;
|
||||
param.serviceId = currentServiceId;
|
||||
@@ -108,16 +115,17 @@ lib.use(['element', 'table', 'tree', 'form'], function () {
|
||||
, {field: 'path', title: 'path', width: 200}
|
||||
, {
|
||||
field: 'ignoreValidate', width: 80, title: '忽略验证', templet: function (row) {
|
||||
return row.ignoreValidate
|
||||
? '<span class="x-red">是</span>'
|
||||
: '<span>否</span>';
|
||||
return row.ignoreValidate ? '<span class="x-red">是</span>' : '<span>否</span>';
|
||||
}
|
||||
}
|
||||
, {
|
||||
field: 'disabled', title: '状态', width: 80, templet: function (row) {
|
||||
return row.disabled
|
||||
? '<span class="x-red">禁用</span>'
|
||||
: '<span class="x-green">启用</span>';
|
||||
field: 'mergeResult', title: '合并结果', width: 80, templet: function (row) {
|
||||
return row.mergeResult ? '合并' : '<span class="x-yellow">不合并</span>';
|
||||
}
|
||||
}
|
||||
, {
|
||||
field: 'status', title: '状态', width: 80, templet: function (row) {
|
||||
return ROUTE_STATUS[row.status + ''];
|
||||
}
|
||||
}
|
||||
, {fixed: 'right', title: '操作', toolbar: '#optBar', width: 100}
|
||||
@@ -128,38 +136,37 @@ lib.use(['element', 'table', 'tree', 'form'], function () {
|
||||
table.on('tool(routeTable)', function(obj) {
|
||||
var data = obj.data;
|
||||
if(obj.event === 'edit'){
|
||||
$updateForm.get(0).reset();
|
||||
//表单初始赋值
|
||||
data.profile = profile;
|
||||
data.serviceId = currentServiceId;
|
||||
data.disabled = data.disabled + '';
|
||||
data.ignoreValidate = data.ignoreValidate + '';
|
||||
form.val('updateWinFilter', data)
|
||||
|
||||
updateForm.setData(data);
|
||||
|
||||
// form.val('updateWinFilter', data);
|
||||
|
||||
layer.open({
|
||||
type: 1
|
||||
,title: '修改路由' + smTitle
|
||||
,area: ['500px', '400px']
|
||||
,area: ['500px', '460px']
|
||||
,content: $('#updateWin') //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
});
|
||||
}
|
||||
});
|
||||
table.on('toolbar(routeTable)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
$addForm.find('input[name=id]').prop('readonly', false);
|
||||
$addForm.get(0).reset();
|
||||
var data = {};
|
||||
data.profile = profile;
|
||||
data.serviceId = currentServiceId;
|
||||
data.id = '';
|
||||
// 新加的路由先设置成禁用
|
||||
data.disabled = 'true';
|
||||
data.ignoreValidate = 'false';
|
||||
form.val('addWinFilter', data);
|
||||
data.status = 2;
|
||||
data.ignoreValidate = 0;
|
||||
data.mergeResult = 1;
|
||||
addForm.setData(data);
|
||||
layer.open({
|
||||
type: 1
|
||||
,title: '添加路由' + smTitle
|
||||
,area: ['500px', '400px']
|
||||
,area: ['500px', '460px']
|
||||
,content: $('#addWin')
|
||||
});
|
||||
}
|
||||
|
@@ -45,13 +45,20 @@ public class RouteParam {
|
||||
* 是否忽略验证,业务参数验证除外
|
||||
*/
|
||||
@NotNull
|
||||
@ApiDocField(description = "是否忽略验证")
|
||||
private Boolean ignoreValidate;
|
||||
@ApiDocField(description = "是否忽略验证,1:是,0:否")
|
||||
private Integer ignoreValidate;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 状态
|
||||
*/
|
||||
@NotNull
|
||||
@ApiDocField(description = "是否禁用")
|
||||
private Boolean disabled;
|
||||
@ApiDocField(description = "状态,0:审核,1:启用,2:禁用")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull
|
||||
@ApiDocField(description = "是否合并结果,1:是,0:否")
|
||||
private Integer mergeResult;
|
||||
}
|
||||
|
@@ -43,10 +43,15 @@ public class GatewayRouteDefinition {
|
||||
/**
|
||||
* 是否忽略验证,业务参数验证除外
|
||||
*/
|
||||
private boolean ignoreValidate;
|
||||
private int ignoreValidate;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 状态,0:待审核,1:启用,2:禁用
|
||||
*/
|
||||
private boolean disabled;
|
||||
private int status = 1;
|
||||
|
||||
/**
|
||||
* 合并结果
|
||||
*/
|
||||
private int mergeResult = 1;
|
||||
}
|
@@ -93,15 +93,17 @@ public class ApiConfig {
|
||||
private List<String> i18nModules = new ArrayList<String>();
|
||||
|
||||
// -------- fields ---------
|
||||
|
||||
/**
|
||||
* 忽略验证
|
||||
* 忽略验证,设置true,则所有接口不会进行签名校验
|
||||
*/
|
||||
private boolean ignoreValidate;
|
||||
|
||||
/**
|
||||
* 是否对结果进行合并
|
||||
* 是否对结果进行合并。<br>
|
||||
* 默认情况下是否合并结果由微服务端决定,一旦指定该值,则由该值决定,不管微服务端如何设置。
|
||||
*/
|
||||
private boolean mergeResult = true;
|
||||
private Boolean mergeResult;
|
||||
|
||||
/**
|
||||
* 超时时间
|
||||
|
@@ -9,6 +9,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class BaseRouteDefinition {
|
||||
|
||||
/**
|
||||
* 路由的Id
|
||||
*/
|
||||
@@ -31,15 +32,19 @@ public class BaseRouteDefinition {
|
||||
/**
|
||||
* 是否忽略验证,业务参数验证除外
|
||||
*/
|
||||
private boolean ignoreValidate;
|
||||
private int ignoreValidate;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 状态,0:待审核,1:启用,2:禁用
|
||||
*/
|
||||
private boolean disabled;
|
||||
private int status = 1;
|
||||
|
||||
/**
|
||||
* 是否合并结果
|
||||
*/
|
||||
private boolean mergeResult;
|
||||
private int mergeResult;
|
||||
|
||||
public boolean enable() {
|
||||
return status == RouteStatus.ENABLE.getStatus();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package com.gitee.sop.gatewaycommon.bean;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public enum RouteStatus {
|
||||
AUDIT(0, "待审核"),
|
||||
ENABLE(1, "已启用"),
|
||||
DISABLE(2, "已禁用"),
|
||||
;
|
||||
private int status;
|
||||
private String description;
|
||||
|
||||
RouteStatus(int status, String description) {
|
||||
this.status = status;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}}
|
@@ -64,7 +64,7 @@ public class NameVersionRoutePredicateFactory extends AbstractRoutePredicateFact
|
||||
boolean match = (name + version).equals(nameVersion);
|
||||
if (match) {
|
||||
TargetRoute targetRoute = RouteRepositoryContext.getRouteRepository().get(nameVersion);
|
||||
if (targetRoute != null && targetRoute.getRouteDefinition().isDisabled()) {
|
||||
if (targetRoute != null && !targetRoute.getRouteDefinition().enable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import com.gitee.sop.gatewaycommon.manager.RouteRepository;
|
||||
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||
import com.gitee.sop.gatewaycommon.message.ErrorEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class ApiParamFactory {
|
||||
if (routeDefinition == null) {
|
||||
throw ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException();
|
||||
}
|
||||
apiParam.setIgnoreValidate(routeDefinition.isIgnoreValidate());
|
||||
apiParam.setIgnoreValidate(BooleanUtils.toBoolean(routeDefinition.getIgnoreValidate()));
|
||||
return apiParam;
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||
import com.gitee.sop.gatewaycommon.message.ErrorEnum;
|
||||
import com.gitee.sop.gatewaycommon.message.ErrorMeta;
|
||||
import com.gitee.sop.gatewaycommon.param.ParamNames;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -48,7 +49,7 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
||||
|
||||
@Override
|
||||
public String mergeResult(T request, String serviceResult) {
|
||||
boolean isMergeResult = this.isRouteMergeResult(request);
|
||||
boolean isMergeResult = this.isMergeResult(request);
|
||||
if (!isMergeResult) {
|
||||
return serviceResult;
|
||||
}
|
||||
@@ -80,26 +81,26 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
protected boolean isRouteMergeResult(T request) {
|
||||
boolean defaultSetting = ApiContext.getApiConfig().isMergeResult();
|
||||
boolean isMergeResult = true;
|
||||
protected boolean isMergeResult(T request) {
|
||||
// 默认全局设置
|
||||
Boolean defaultSetting = ApiContext.getApiConfig().getMergeResult();
|
||||
if (defaultSetting != null) {
|
||||
return defaultSetting;
|
||||
}
|
||||
Map<String, ?> params = this.getApiParam(request);
|
||||
Object name = params.get(ParamNames.API_NAME);
|
||||
Object version = params.get(ParamNames.VERSION_NAME);
|
||||
if(name == null) {
|
||||
// 随便生成一个name
|
||||
name = System.currentTimeMillis();
|
||||
}
|
||||
TargetRoute targetRoute = RouteRepositoryContext.getRouteRepository().get(String.valueOf(name) + version);
|
||||
if (targetRoute == null) {
|
||||
return defaultSetting;
|
||||
return true;
|
||||
} else {
|
||||
isMergeResult = targetRoute.getRouteDefinition().isMergeResult();
|
||||
int mergeResult = targetRoute.getRouteDefinition().getMergeResult();
|
||||
return BooleanUtils.toBoolean(mergeResult);
|
||||
}
|
||||
// 如果路由说合并,还得看网关全局设置,网关全局设置优先级最大
|
||||
if (isMergeResult) {
|
||||
isMergeResult = defaultSetting;
|
||||
}
|
||||
return isMergeResult;
|
||||
}
|
||||
|
||||
protected String wrapResult(String serviceResult) {
|
||||
|
@@ -50,8 +50,8 @@ public class SopRouteLocator implements RouteLocator, Ordered {
|
||||
if (zuulTargetRoute == null) {
|
||||
return null;
|
||||
}
|
||||
// 路由被禁用
|
||||
if (zuulTargetRoute.getRouteDefinition().isDisabled()) {
|
||||
// 路由是否启用
|
||||
if (!zuulTargetRoute.getRouteDefinition().enable()) {
|
||||
throw ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException();
|
||||
}
|
||||
return zuulTargetRoute.getTargetRouteDefinition();
|
||||
|
@@ -16,6 +16,7 @@
|
||||
<spring-boot.version>2.1.2.RELEASE</spring-boot.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<fastjson.version>1.2.15</fastjson.version>
|
||||
<zookeeper.version>3.4.12</zookeeper.version>
|
||||
</properties>
|
||||
@@ -50,6 +51,13 @@
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- commons -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
|
@@ -23,9 +23,9 @@ public class ServiceApiInfo {
|
||||
/** 版本号 */
|
||||
private String version;
|
||||
/** 是否忽略验证 */
|
||||
private boolean ignoreValidate;
|
||||
private int ignoreValidate;
|
||||
/** 是否合并结果 */
|
||||
private boolean mergeResult;
|
||||
private int mergeResult;
|
||||
|
||||
public ApiMeta() {
|
||||
}
|
||||
|
@@ -1,30 +1,26 @@
|
||||
package com.gitee.sop.servercommon.configuration;
|
||||
|
||||
import com.gitee.easyopen.ApiContext;
|
||||
import com.gitee.easyopen.annotation.Api;
|
||||
import com.gitee.easyopen.annotation.ApiService;
|
||||
import com.gitee.easyopen.util.ReflectionUtil;
|
||||
import com.gitee.sop.servercommon.bean.ServiceApiInfo;
|
||||
import com.gitee.sop.servercommon.manager.ApiMetaManager;
|
||||
import com.gitee.sop.servercommon.manager.DefaultRequestMappingEvent;
|
||||
import com.gitee.sop.servercommon.manager.RequestMappingEvent;
|
||||
import com.gitee.sop.servercommon.mapping.ApiMappingHandlerMapping;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 提供给easyopen项目使用
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
public class EasyopenServiceConfiguration extends BaseServiceConfiguration {
|
||||
@@ -59,7 +55,7 @@ public class EasyopenServiceConfiguration extends BaseServiceConfiguration {
|
||||
ServiceApiInfo.ApiMeta apiMeta = new ServiceApiInfo.ApiMeta();
|
||||
apiMeta.setName(api.name());
|
||||
apiMeta.setVersion(api.version());
|
||||
apiMeta.setIgnoreValidate(api.ignoreValidate());
|
||||
apiMeta.setIgnoreValidate(BooleanUtils.toInteger(api.ignoreValidate()));
|
||||
// /api/goods.get/
|
||||
String servletPath = this.buildPath(api);
|
||||
apiMeta.setPath(servletPath);
|
||||
|
@@ -5,8 +5,8 @@ import com.gitee.sop.servercommon.mapping.ApiMappingHandlerMapping;
|
||||
import com.gitee.sop.servercommon.mapping.ApiMappingInfo;
|
||||
import com.gitee.sop.servercommon.mapping.ApiMappingRequestCondition;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.mvc.condition.RequestCondition;
|
||||
@@ -92,8 +92,8 @@ public class DefaultRequestMappingEvent implements RequestMappingEvent {
|
||||
name = buildName(path);
|
||||
}
|
||||
ServiceApiInfo.ApiMeta apiMeta = new ServiceApiInfo.ApiMeta(name, path, version);
|
||||
apiMeta.setIgnoreValidate(apiMappingInfo.isIgnoreValidate());
|
||||
apiMeta.setMergeResult(apiMappingInfo.isMergeResult());
|
||||
apiMeta.setIgnoreValidate(BooleanUtils.toInteger(apiMappingInfo.isIgnoreValidate()));
|
||||
apiMeta.setMergeResult(BooleanUtils.toInteger(apiMappingInfo.isMergeResult()));
|
||||
return apiMeta;
|
||||
}
|
||||
return null;
|
||||
|
@@ -110,8 +110,8 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager {
|
||||
String path = this.buildServletPath(serviceApiInfo, apiMeta);
|
||||
gatewayRouteDefinition.setUri(uri);
|
||||
gatewayRouteDefinition.setPath(path);
|
||||
gatewayRouteDefinition.setIgnoreValidate(apiMeta.isIgnoreValidate());
|
||||
gatewayRouteDefinition.setMergeResult(apiMeta.isMergeResult());
|
||||
gatewayRouteDefinition.setIgnoreValidate(apiMeta.getIgnoreValidate());
|
||||
gatewayRouteDefinition.setMergeResult(apiMeta.getMergeResult());
|
||||
return gatewayRouteDefinition;
|
||||
}
|
||||
|
||||
|
@@ -43,15 +43,15 @@ public class GatewayRouteDefinition {
|
||||
/**
|
||||
* 是否忽略验证,业务参数验证除外
|
||||
*/
|
||||
private boolean ignoreValidate;
|
||||
private int ignoreValidate;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 状态,0:待审核,1:启用,2:禁用
|
||||
*/
|
||||
private boolean disabled;
|
||||
private int status = 1;
|
||||
|
||||
/**
|
||||
* 是否合并结果
|
||||
*/
|
||||
private boolean mergeResult;
|
||||
private int mergeResult;
|
||||
}
|
Reference in New Issue
Block a user