更新初始化文件

pull/1/head
759675757@qq.com 2019-10-18 11:24:59 +08:00
parent 373906b1ea
commit 913af750bd
15 changed files with 389 additions and 68 deletions

View File

@ -56,7 +56,7 @@ public class SysDictController extends BaseController {
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysDict record) {
public Result addOrUpd(SysDict record) {
sysDictService.saveOrUpdate(record);
return Result.success(record.getId());
}

View File

@ -6,14 +6,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.songpeng.sparchetype.common.BaseController;
import com.songpeng.sparchetype.common.Result;
import com.songpeng.sparchetype.system.entity.SysMenu;
import com.songpeng.sparchetype.system.entity.SysRole;
import com.songpeng.sparchetype.system.service.ISysMenuService;
import com.songpeng.sparchetype.system.service.ISysRoleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* <p>
@ -53,7 +54,7 @@ public class SysMenuController extends BaseController {
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysMenu record) {
public Result addOrUpd(SysMenu record) {
sysMenuService.saveOrUpdate(record);
return Result.success(record.getId());
}

View File

@ -54,7 +54,7 @@ public class SysRoleController extends BaseController {
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysRole record) {
public Result addOrUpd(SysRole record) {
sysRoleService.saveOrUpdate(record);
return Result.success(record.getId());
}

View File

@ -56,7 +56,7 @@ public class SysUserController extends BaseController {
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysUser record) {
public Result addOrUpd(SysUser record) {
sysUserService.saveOrUpdate(record);
return Result.success(record.getId());
}

View File

@ -1,5 +1,6 @@
package com.songpeng.sparchetype.system.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songpeng.sparchetype.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -16,6 +17,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sp_sys_menu")
public class SysMenu extends BaseEntity {
private static final long serialVersionUID = 1L;

View File

@ -1,5 +1,6 @@
package com.songpeng.sparchetype.system.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songpeng.sparchetype.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -16,6 +17,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sp_sys_role")
public class SysRole extends BaseEntity {
private static final long serialVersionUID = 1L;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.songpeng.sparchetype.mapper.system.SysRoleMapper">
<mapper namespace="com.songpeng.sparchetype.system.mapper.SysRoleMapper">
</mapper>

View File

@ -175,7 +175,7 @@ body {
width: 100%;
}
.weadmin-body {
padding: 20px;
padding: 12px;
}
.weadmin-nav {
padding: 0 20px;
@ -196,7 +196,7 @@ body {
background-color: #f2f2f2;
}
.we-search {
margin-bottom: 20px;
margin-bottom: 10px;
font-size: 14px;
}
.we-search input.layui-input {

View File

@ -95,7 +95,7 @@
"id": 17,
"name": "权限管理",
"icon": "",
"url": "/blog/article/listui"
"url": "/admin/sys/menu/list-ui"
}]
},
{

View File

@ -40,28 +40,15 @@
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="recommend"><i class="layui-icon">&#xe6c6;</i>推荐</button>
<button class="layui-btn layui-btn-sm" lay-event="top"><i class="layui-icon">&#xe619;</i>置顶</button>
<button class="layui-btn layui-btn-sm" lay-event="review"><i class="layui-icon">&#xe6b2;</i>审核</button>
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加用户','${request.contextPath}/admin/sys/dict/add-or-upd-ui',600,400)"><i class="layui-icon">&#xe61f;</i>添加</button>
</div>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="zzz" lay-skin="switch" lay-text="已推荐|未推荐" {{d.recommend}}>
</script>
<script type="text/html" id="topTpl">
<input type="checkbox" name="show" lay-skin="switch" lay-text="已置顶|未置顶" {{d.top}}>
</script>
<script type="text/html" id="reviewTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/dict/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看文章','./show.html',600,400)" href="javascript:;">
<a title="查看" onclick="WeAdminShow('查看字典','./show.html',600,400)" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">

View File

@ -0,0 +1,154 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加菜单</title>
<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">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<form class="layui-form">
<div class="layui-form-item">
<label for="js-name" class="layui-form-label">
<span class="we-red">*</span>菜单名称
</label>
<div class="layui-input-inline">
<input type="text" id="js-name" name="name" lay-verify="required" autocomplete="off" class="layui-input" value="${result.name}">
</div>
</div>
<div class="layui-form-item">
<label for="js-url" class="layui-form-label">
<span class="we-red">*</span>菜单URL
</label>
<div class="layui-input-inline">
<input type="text" id="js-url" name="url" lay-verify="required" autocomplete="off" class="layui-input" value="${result.url}">
</div>
</div>
<div class="layui-form-item">
<label for="js-parent-id" class="layui-form-label">
父菜单ID
</label>
<div class="layui-input-inline">
<input type="text" id="js-parent-id" name="parentId" lay-verify="" autocomplete="off" class="layui-input" value="${result.parentId}">
</div>
</div>
<div class="layui-form-item">
<label for="js-grade" class="layui-form-label">
层级
</label>
<div class="layui-input-inline">
<input type="text" id="js-grade" name="grade" lay-verify="" autocomplete="off" class="layui-input" value="${result.grade}">
</div>
</div>
<div class="layui-form-item">
<label for="js-sort-num" class="layui-form-label">
排序
</label>
<div class="layui-input-inline">
<input type="text" id="js-sort-num" name="sortNum" lay-verify="" autocomplete="off" class="layui-input" value="${result.sortNum}">
</div>
</div>
<div class="layui-form-item">
<label for="js-type" class="layui-form-label">
类型
</label>
<div class="layui-input-inline">
<input type="text" id="js-type" name="type" lay-verify="" autocomplete="off" class="layui-input" value="${result.type}">
</div>
</div>
<div class="layui-form-item">
<label for="js-permission" class="layui-form-label">
授权
</label>
<div class="layui-input-inline">
<input type="text" id="js-permission" name="permission" lay-verify="" autocomplete="off" class="layui-input" value="${result.permission}">
</div>
</div>
<div class="layui-form-item">
<label for="js-icon" class="layui-form-label">
菜单图标
</label>
<div class="layui-input-inline">
<input type="text" id="js-icon" name="icon" lay-verify="" autocomplete="off" class="layui-input" value="${result.icon}">
</div>
</div>
<div class="layui-form-item">
<label for="js-descr" class="layui-form-label">
描述
</label>
<div class="layui-input-inline">
<input type="text" id="js-descr" name="descr" lay-verify="" autocomplete="off" class="layui-input" value="${result.descr}">
</div>
</div>
<div class="layui-form-item">
<input type="hidden" name="id" id="js-id" value="" />
<label for="js-add-btn" class="layui-form-label"></label>
<button id="js-add-btn" class="layui-btn" lay-filter="add" lay-submit="">确定</button>
</div>
</form>
</div>
</body>
<script>
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
admin = layui.admin,
layer = layui.layer;
//监听提交
form.on('submit(add)', function(data) {
$.ajax({
type: "POST",
//请求的媒体类型
//contentType: "application/json;charset=UTF-8",
url: "${request.contextPath}/admin/sys/menu/add-or-upd",
//data: JSON.stringify(data),
data: data.field,
success: function(result) {
if (result.code === 0) {
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//刷新父页面注意一定要在关闭当前iframe层之前执行刷新
parent.location.reload();
//关闭当前frame
parent.layer.close(index);
} else {
layer.alert(result.msg, {
icon: 2
})
}
},
error: function(e){
layer.alert(e, {
icon: 2
})
}
});
return false;
});
});
</script>
</html>

View File

@ -0,0 +1,214 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>系统菜单列表</title>
<meta name="Description" content="基于layUI数据表格操作"/>
<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">
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<div class="layui-row">
<form class="layui-form layui-col-md12 we-search" lay-filter="search-form-filter">
<div class="layui-input-inline">
<select name="cateid">
<option>请选择分类</option>
<option>文章</option>
<option>会员</option>
<option>权限</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="开始日" name="start" id="start">
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="截止日" name="end" id="end">
</div>
<div class="layui-inline">
<input type="text" name="keyword" placeholder="请输入关键字" autocomplete="off" class="layui-input">
</div>
<button class="layui-btn" lay-submit lay-filter="search-form-btn-filter"><i class="layui-icon">&#xe615;</i></button>
</form>
</div>
<!--数据表格-->
<table class="layui-hide" id="record-table" lay-filter="table-filter"></table>
</div>
</body>
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加菜单','${request.contextPath}/admin/sys/menu/add-or-upd-ui',600,400)"><i class="layui-icon">&#xe61f;</i>添加</button>
</div>
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/menu/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看菜单','./show.html',600,400)" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
<i class="layui-icon">&#xe640;</i>
</a>
</script>
<script type="text/javascript">
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['table', 'jquery','form', 'admin', 'laydate'], function() {
var table = layui.table,
$ = layui.jquery,
form = layui.form,
admin = layui.admin,
laydate = layui.laydate;
laydate.render({
elem: '#start'
});
laydate.render({
elem: '#end'
});
var tableIns = table.render({
elem: '#record-table',
cellMinWidth: 80,
toolbar: '#toolbar-top',
method: 'POST',
event: true,
page: true,
url: '${request.contextPath}/admin/sys/menu/page',
request: {
pageName: 'current' //页码的参数名称默认page
,limitName: 'size' //每页数据量的参数名默认limit
},
parseData: function(res){ //res 即为原始返回的数据
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data ? res.data.total : 0, //解析数据长度
"data": res.data ? res.data.records : [] //解析数据列表
};
},
cols: [
[{
type: 'checkbox'
}, {
field: 'name', title: '角色名称'
}, {
field: 'url', title: '菜单URL'
}, {
field: 'parentId', title: 'parentId'
}, {
field: 'grade', title: '层级'
}, {
field: 'sortNum', title: '排序'
}, {
field: 'type', title: '类型'
}, {
field: 'permission', title: '授权'
}, {
field: 'icon', title: '菜单图标'
}, {
field: 'descr', title: '角色描述'
}, {
fixed: 'right', field: 'operate',title: '操作', toolbar: '#operateTpl', unresize: true, width: 90
}]
],
done: function(res, curr, count){
//如果是异步请求数据方式res即为你接口返回的信息。
//如果是直接赋值的方式res即为{data: [], count: 99} data为当前页数据、count为数据总长度
}
});
/*
* 数据表格中form表单元素是动态插入,所以需要更新渲染下
* http://www.layui.com/doc/modules/form.html#render
*/
$(function(){
form.render();
});
form.on('submit(search-form-btn-filter)', function(data){
tableIns.reload({
// 设定异步数据接口的额外参数,任意设
where: data.field,
page: {
curr: 1 //重新从第 1 页开始
}
});
// 阻止表单跳转。如果需要表单跳转,去掉这段即可。
return false;
});
//头工具栏事件
table.on('toolbar(table-filter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'getCheckData':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.confirm('确认要删除吗?' + JSON.stringify(data), function(index) {
layer.msg('删除成功', {
icon: 1
});
//找到所有被选中的,发异步进行删除
$(".layui-table-body .layui-form-checked").parents('tr').remove();
});
} else {
layer.msg("请先选择需要删除的文章!");
}
break;
case 'recommend':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.msg("您点击了推荐操作");
for(var i = 0; i < data.length; i++) {
data[i].recommend = "checked";
form.render();
}
} else {
layer.msg("请先选择");
}
break;
case 'top':
layer.msg("您点击了置顶操作");
break;
case 'review':
layer.msg("您点击了审核操作");
break;
};
});
/*用户-删除*/
window.member_del = function(obj, id) {
layer.confirm('确认要删除吗?', function(index) {
//发异步删除数据
$(obj).parents("tr").remove();
layer.msg('已删除!', {
icon: 1,
time: 1000
});
});
}
});
function delAll(argument) {
var data = tableCheck.getData();
layer.confirm('确认要删除吗?' + data, function(index) {
//捉到所有被选中的,发异步进行删除
layer.msg('删除成功', {
icon: 1
});
$(".layui-form-checked").not('.header').parents('tr').remove();
});
}
</script>
</html>

View File

@ -27,7 +27,7 @@
</div>
<div class="layui-form-item">
<label for="js-username" class="layui-form-label">
<label for="js-code" class="layui-form-label">
<span class="we-red">*</span>角色编码
</label>
<div class="layui-input-inline">
@ -71,30 +71,17 @@
admin = layui.admin,
layer = layui.layer;
//失去焦点时判断值为空不验证,一旦填写必须验证
$('input[name="email"]').blur(function(){
//这里是失去焦点时的事件
if($('input[name="email"]').val()){
$('input[name="email"]').attr('lay-verify','email');
}else{
$('input[name="email"]').removeAttr('lay-verify');
}
});
//监听提交
form.on('submit(add)', function(data) {
$.ajax({
type: "POST",
//请求的媒体类型
//contentType: "application/json;charset=UTF-8",
url: "${request.contextPath}/admin/sys/user/add-or-upd",
url: "${request.contextPath}/admin/sys/role/add-or-upd",
//data: JSON.stringify(data),
data: data.field,
success: function(result) {
if (result.code === 0) {
//获取提交成功的时间
var time = new Date();
var timeNow = util.toDateString(time);
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//刷新父页面注意一定要在关闭当前iframe层之前执行刷新

View File

@ -40,28 +40,15 @@
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="recommend"><i class="layui-icon">&#xe6c6;</i>推荐</button>
<button class="layui-btn layui-btn-sm" lay-event="top"><i class="layui-icon">&#xe619;</i>置顶</button>
<button class="layui-btn layui-btn-sm" lay-event="review"><i class="layui-icon">&#xe6b2;</i>审核</button>
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加角色','${request.contextPath}/admin/sys/role/add-or-upd-ui',600,400)"><i class="layui-icon">&#xe61f;</i>添加</button>
</div>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="zzz" lay-skin="switch" lay-text="已推荐|未推荐" {{d.recommend}}>
</script>
<script type="text/html" id="topTpl">
<input type="checkbox" name="show" lay-skin="switch" lay-text="已置顶|未置顶" {{d.top}}>
</script>
<script type="text/html" id="reviewTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/role/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看文章','./show.html',600,400)" href="javascript:;">
<a title="查看" onclick="WeAdminShow('查看权限','./show.html',600,400)" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">

View File

@ -40,28 +40,15 @@
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="recommend"><i class="layui-icon">&#xe6c6;</i>推荐</button>
<button class="layui-btn layui-btn-sm" lay-event="top"><i class="layui-icon">&#xe619;</i>置顶</button>
<button class="layui-btn layui-btn-sm" lay-event="review"><i class="layui-icon">&#xe6b2;</i>审核</button>
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加用户','${request.contextPath}/admin/sys/user/add-or-upd-ui',600,400)"><i class="layui-icon">&#xe61f;</i>添加</button>
</div>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="zzz" lay-skin="switch" lay-text="已推荐|未推荐" {{d.recommend}}>
</script>
<script type="text/html" id="topTpl">
<input type="checkbox" name="show" lay-skin="switch" lay-text="已置顶|未置顶" {{d.top}}>
</script>
<script type="text/html" id="reviewTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/user/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看文章','./show.html',600,400)" href="javascript:;">
<a title="查看" onclick="WeAdminShow('查看用户','./show.html',600,400)" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">