新增路由类型
This commit is contained in:
parent
3babff60fd
commit
4f62d30d12
@ -0,0 +1,20 @@
|
||||
package ink.wgink.gateway.dao.routetype;
|
||||
|
||||
import ink.wgink.gateway.pojo.routetype.RouteType;
|
||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRouteTypeDao
|
||||
* @Description: 路由类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/5/8 12:10
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IRouteTypeDao extends ReactiveMongoRepository<RouteType, String> {
|
||||
String COLLECTION_NAME = "sys_route_type";
|
||||
}
|
@ -7,29 +7,21 @@ import ink.wgink.gateway.handler.BaseHandler;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResult;
|
||||
import ink.wgink.gateway.pojo.route.Route;
|
||||
import ink.wgink.gateway.util.RequestFieldCheckUtil;
|
||||
import ink.wgink.gateway.util.UUIDUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
|
||||
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||
import org.springframework.cloud.gateway.route.RouteDefinition;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -124,8 +116,9 @@ public class RouteHandler extends BaseHandler implements ApplicationEventPublish
|
||||
Route route = new Route();
|
||||
Example example = Example.of(route);
|
||||
if (keywords.isPresent()) {
|
||||
route.setTitle(keywords.get());
|
||||
route.setSummary(keywords.get());
|
||||
String keywordTrim = keywords.get().trim();
|
||||
route.setTitle(keywordTrim);
|
||||
route.setSummary(keywordTrim);
|
||||
|
||||
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAny()
|
||||
.withMatcher("title", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
|
@ -0,0 +1,103 @@
|
||||
package ink.wgink.gateway.handler.routetype;
|
||||
|
||||
import ink.wgink.gateway.consts.ISystemConst;
|
||||
import ink.wgink.gateway.dao.routetype.IRouteTypeDao;
|
||||
import ink.wgink.gateway.exception.ParamsException;
|
||||
import ink.wgink.gateway.exception.SearchException;
|
||||
import ink.wgink.gateway.handler.BaseHandler;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResult;
|
||||
import ink.wgink.gateway.pojo.route.Route;
|
||||
import ink.wgink.gateway.pojo.routetype.RouteType;
|
||||
import ink.wgink.gateway.util.RequestFieldCheckUtil;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteTypeHandler
|
||||
* @Description: 路由类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/5/8 12:09
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class RouteTypeHandler extends BaseHandler {
|
||||
|
||||
private IRouteTypeDao routeTypeDao;
|
||||
|
||||
public RouteTypeHandler(IRouteTypeDao routeTypeDao) {
|
||||
this.routeTypeDao = routeTypeDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> save(ServerRequest serverRequest) {
|
||||
Mono<RouteType> routeTypeMono = serverRequest.bodyToMono(RouteType.class);
|
||||
return routeTypeMono.flatMap(routeType -> {
|
||||
RequestFieldCheckUtil.check(routeType);
|
||||
setSave(routeType);
|
||||
|
||||
RouteType routeTypeExample = new RouteType();
|
||||
routeTypeExample.setTitle(routeType.getTitle().trim());
|
||||
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAny().withMatcher("title", ExampleMatcher.GenericPropertyMatcher::exact).withIgnoreCase("id");
|
||||
Example example = Example.of(routeTypeExample, exampleMatcher);
|
||||
return routeTypeDao.findOne(example).flatMap(r -> Mono.error(new SearchException("类型已经存在")))
|
||||
.switchIfEmpty(routeTypeDao.save(routeType))
|
||||
.then(ServerResponse.ok().contentType(MediaType.APPLICATION_JSON_UTF8).body(Flux.just(new SuccessResult()), SuccessResult.class));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> delete(ServerRequest serverRequest) {
|
||||
String ids = serverRequest.pathVariable("ids");
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
return routeTypeDao.findAllById(idList).flatMap(route -> routeTypeDao.delete(route))
|
||||
.then(ServerResponse.ok().contentType(MediaType.APPLICATION_JSON_UTF8).body(Mono.just(new SuccessResult()), SuccessResult.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> list(ServerRequest serverRequest) {
|
||||
Optional<String> keywords = serverRequest.queryParam("keywords");
|
||||
|
||||
RouteType routeType = new RouteType();
|
||||
Example example = Example.of(routeType);
|
||||
if (keywords.isPresent()) {
|
||||
String keywordTrim = keywords.get().trim();
|
||||
routeType.setTitle(keywordTrim);
|
||||
routeType.setSummary(keywordTrim);
|
||||
|
||||
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAny()
|
||||
.withMatcher("title", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
.withMatcher("summary", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
.withIgnoreCase("id");
|
||||
example = Example.of(routeType, exampleMatcher);
|
||||
}
|
||||
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON_UTF8).body(routeTypeDao.findAll(example), RouteType.class);
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package ink.wgink.gateway.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
@ -14,7 +12,6 @@ import org.springframework.data.annotation.Id;
|
||||
* @Date: 2021/4/13 5:56 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasePOJO {
|
||||
|
||||
@Id
|
||||
@ -24,4 +21,43 @@ public class BasePOJO {
|
||||
private String gmtModified;
|
||||
private String modifier;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid == null ? "" : uuid.trim();
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getGmtCreate() {
|
||||
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||
}
|
||||
|
||||
public void setGmtCreate(String gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return creator == null ? "" : creator.trim();
|
||||
}
|
||||
|
||||
public void setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getGmtModified() {
|
||||
return gmtModified == null ? "" : gmtModified.trim();
|
||||
}
|
||||
|
||||
public void setGmtModified(String gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public String getModifier() {
|
||||
return modifier == null ? "" : modifier.trim();
|
||||
}
|
||||
|
||||
public void setModifier(String modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,11 @@ import java.io.Serializable;
|
||||
* @Date: 2021/4/13 7:15 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@Document(collection = IRouteDao.COLLECTION_NAME)
|
||||
public class Route extends BasePOJO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4892456861969101733L;
|
||||
@CheckEmptyAnnotation(name = "title")
|
||||
@CheckEmptyAnnotation(name = "名称")
|
||||
private String title;
|
||||
@CheckEmptyAnnotation(name = "说明")
|
||||
private String summary;
|
||||
@ -36,4 +34,43 @@ public class Route extends BasePOJO implements Serializable {
|
||||
@CheckEmptyAnnotation(name = "测试接口", verifyType = "path")
|
||||
private String testPath;
|
||||
|
||||
public String getTitle() {
|
||||
return title == null ? "" : title.trim();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary == null ? "" : summary.trim();
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path == null ? "" : path.trim();
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri == null ? "" : uri.trim();
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getTestPath() {
|
||||
return testPath == null ? "" : testPath.trim();
|
||||
}
|
||||
|
||||
public void setTestPath(String testPath) {
|
||||
this.testPath = testPath;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package ink.wgink.gateway.pojo.routetype;
|
||||
|
||||
import ink.wgink.gateway.annoation.CheckEmptyAnnotation;
|
||||
import ink.wgink.gateway.dao.routetype.IRouteTypeDao;
|
||||
import ink.wgink.gateway.pojo.BasePOJO;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteType
|
||||
* @Description: 路由类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/5/8 12:10
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Document(collection = IRouteTypeDao.COLLECTION_NAME)
|
||||
public class RouteType extends BasePOJO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4213129156239577757L;
|
||||
@CheckEmptyAnnotation(name = "名称")
|
||||
private String title;
|
||||
@CheckEmptyAnnotation(name = "说明")
|
||||
private String summary;
|
||||
|
||||
public String getTitle() {
|
||||
return title == null ? "" : title.trim();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary == null ? "" : summary.trim();
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ink.wgink.gateway.router.routetype;
|
||||
|
||||
import ink.wgink.gateway.consts.ISystemConst;
|
||||
import ink.wgink.gateway.handler.routetype.RouteTypeHandler;
|
||||
import ink.wgink.gateway.router.BaseRouter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.RequestPredicates;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteTypeRouter
|
||||
* @Description: 路由类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/5/8 13:14
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
public class RouteTypeRouter extends BaseRouter {
|
||||
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> routeTypeRouterFunction(RouteTypeHandler routeTypeHandler) {
|
||||
return RouterFunctions.nest(RequestPredicates.path(ISystemConst.ADMIN_ROUTER_PREFIX + "/api/route-type"),
|
||||
RouterFunctions
|
||||
.route(RequestPredicates.POST("/save"), routeTypeHandler::save)
|
||||
.andRoute(RequestPredicates.GET("/list"), routeTypeHandler::list));
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,8 @@
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:void(0);">网关管理</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a href="javascript:void(0);">映射管理</a></dd>
|
||||
<dd><a href="javascript:void(0);" class="menu-item" data-href="route/route-type/list.html">路由分类</a></dd>
|
||||
<dd><a href="javascript:void(0);" class="menu-item" data-href="route/route/list.html">映射管理</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item" style="float: right;">
|
||||
@ -32,9 +33,8 @@
|
||||
</div>
|
||||
<div class="iframe-container">
|
||||
<div class="iframe-breadcrumb-box">
|
||||
<span class="layui-breadcrumb">
|
||||
<span id="breadcrumbTitle" class="layui-breadcrumb">
|
||||
<a href="">首页</a>
|
||||
<a><cite>路由映射</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="iframe-box">
|
||||
@ -65,6 +65,17 @@
|
||||
window.onresize = resize;
|
||||
|
||||
$('#defaultIFrame').attr('src', 'route/route/list.html');
|
||||
|
||||
$('.menu-item').on('click', function() {
|
||||
$('#defaultIFrame').attr('src', this.dataset.href);
|
||||
if($('#subBreadcrumbTitle').length > 0) {
|
||||
$('#subBreadcrumbTitle').empty();
|
||||
$('#subBreadcrumbTitle').append('<cite>'+ this.text +'</cite>');
|
||||
} else {
|
||||
$('#breadcrumbTitle').append('<span lay-separator="">/</span><a href="javascript:void(0);" id="subBreadcrumbTitle"><cite>'+ this.text +'</cite></a>');
|
||||
}
|
||||
})
|
||||
|
||||
$('#LAY-logout').on('click', function () {
|
||||
top.dialog.confirm('确认退出?', function () {
|
||||
window.location.href = 'logout';
|
||||
|
226
src/main/resources/static/wg/route/route-type/list.html
Normal file
226
src/main/resources/static/wg/route/route-type/list.html
Normal file
@ -0,0 +1,226 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/wg/">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/font/font-awesome/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/admin.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein list-page-container">
|
||||
<div class="test-table-reload-btn">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
<!-- 表头按钮组 -->
|
||||
<script type="text/html" id="headerToolBar">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||
<i class="fa fa-lg fa-plus"></i> 新增
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm"
|
||||
lay-event="updateEvent">
|
||||
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm"
|
||||
lay-event="removeEvent">
|
||||
<i class="fa fa-lg fa-trash"></i> 删除
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
<script src="assets/layui-v2.6.4/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layui-v2.6.4/layui/modules/'
|
||||
}).extend({}).use(['layer', 'table'], function () {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var layer = layui.layer;
|
||||
var table = layui.table;
|
||||
var laydate = layui.laydate;
|
||||
var resizeTimeout = null;
|
||||
var tableData = {
|
||||
tableUrl: 'api/route-type/list',
|
||||
dataArray: [],
|
||||
currentPage: null
|
||||
}
|
||||
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
data: tableData.dataArray,
|
||||
page: {
|
||||
curr: currentPage ? currentPage : tableData.currentPage
|
||||
}
|
||||
});
|
||||
}
|
||||
function initTable() {
|
||||
top.restAjax.get(top.restAjax.path(tableData.tableUrl, []), {
|
||||
keywords: $('#keywords').val(),
|
||||
}, null, function(code, data) {
|
||||
tableData.dataArray = [];
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
tableData.dataArray.push(item);
|
||||
}
|
||||
if(tableData.currentPage) {
|
||||
reloadTable();
|
||||
return;
|
||||
}
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
width: '100%',
|
||||
height: $win.height() - 78,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: '#headerToolBar',
|
||||
cols: [[
|
||||
{type: 'checkbox', fixed: 'left'},
|
||||
{field: 'rowNum', width: 80, title: '序号', fixed: 'left', align: 'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field: 'title', width: 200, title: '名称', align: 'center', sort: true,
|
||||
templet: function (row) {
|
||||
var rowData = row[this.field];
|
||||
if (typeof (rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'summary', width: 200, title: '描述', align: 'center', sort: true,
|
||||
templet: function (row) {
|
||||
var rowData = row[this.field];
|
||||
if (typeof (rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'gmtCreate', width: 180, title: '添加时间', align: 'center', sort: true,
|
||||
templet: function (row) {
|
||||
var rowData = row[this.field];
|
||||
if (typeof (rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
}
|
||||
]],
|
||||
data: tableData.dataArray,
|
||||
page: true,
|
||||
done: function(res, curr, count) {
|
||||
tableData.currentPage = curr;
|
||||
if (curr > 1 && res.data.length === 0) {
|
||||
tableData.currentPage = curr - 1;
|
||||
reloadTable(tableData.currentPage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
})
|
||||
}
|
||||
|
||||
initTable();
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
initTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
initTable(1);
|
||||
});
|
||||
|
||||
// 删除
|
||||
function removeData(ids) {
|
||||
top.dialog.msg(top.dataMessage.delete, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.delete(top.restAjax.path('api/route-type/delete/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
initTable();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function () {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// 事件 - 增删改
|
||||
table.on('toolbar(dataTable)', function(obj) {
|
||||
var layEvent = obj.event;
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/route-type/save.html', []),
|
||||
end: function() {
|
||||
initTable();
|
||||
}
|
||||
});
|
||||
} else if(layEvent === 'updateEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||
} else if(checkDatas.length > 1) {
|
||||
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||
} else {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/route-type/update.html?uuid={uuid}', [checkDatas[0].uuid]),
|
||||
end: function() {
|
||||
initTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
} else {
|
||||
var ids = '';
|
||||
for(var i = 0, item; item = checkDatas[i++];) {
|
||||
if(i > 1) {
|
||||
ids += ',';
|
||||
}
|
||||
ids += item['uuid'];
|
||||
}
|
||||
removeData(ids);
|
||||
}
|
||||
} else if(layEvent === 'levelUpEvent') {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
102
src/main/resources/static/wg/route/route-type/save.html
Normal file
102
src/main/resources/static/wg/route/route-type/save.html
Normal file
@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/wg/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/admin.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" class="layui-input" lay-verify="required" placeholder="请输入名称">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="summary" class="layui-input" lay-verify="required" placeholder="请输入描述">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="footer-button-box layui-btn-group">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layui-v2.6.4/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layui-v2.6.4/layui/modules/'
|
||||
}).extend({}).use(['form', 'laydate', 'laytpl', 'regex'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var regex = layui.regex;
|
||||
var uuid = top.restAjax.params(window.location.href).uuid;
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/route-type/save', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
117
src/main/resources/static/wg/route/route-type/update.html
Normal file
117
src/main/resources/static/wg/route/route-type/update.html
Normal file
@ -0,0 +1,117 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/wg/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="assets/layui-v2.6.4/layui/css/admin.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" class="layui-input" lay-verify="required" placeholder="请输入名称">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="summary" class="layui-input" lay-verify="required" placeholder="请输入描述">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="footer-button-box layui-btn-group">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layui-v2.6.4/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layui-v2.6.4/layui/modules/'
|
||||
}).extend({}).use(['form', 'laydate', 'laytpl', 'regex'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var regex = layui.regex;
|
||||
var uuid = top.restAjax.params(window.location.href).uuid;
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/route-type/get/{uuid}', [uuid]), {}, null, function(code, data) {
|
||||
var dataFormData = {};
|
||||
for(var i in data) {
|
||||
dataFormData[i] = data[i] +'';
|
||||
}
|
||||
form.val('dataForm', dataFormData);
|
||||
form.render(null, 'dataForm');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/route/update-type/{uuid}', [uuid]), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -124,16 +124,16 @@
|
||||
if (typeof (rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
return '<a href="'+ rowData +'" target="_blank">'+ rowData +'</a>';
|
||||
}
|
||||
},
|
||||
{field: 'testPath', width: 100, title: '测试接口', align: 'center', sort: true,
|
||||
{field: 'testPath', width: 180, title: '测试接口', align: 'center', sort: true,
|
||||
templet: function (row) {
|
||||
var rowData = row[this.field];
|
||||
if (typeof (rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return '<a href="'+ rowData +'" target="_blank">点击测试</a>';
|
||||
return '<a href="'+ rowData +'" target="_blank">'+ rowData +'</a>';
|
||||
}
|
||||
},
|
||||
{field: 'gmtCreate', width: 180, title: '添加时间', align: 'center', sort: true,
|
||||
|
Loading…
Reference in New Issue
Block a user