修改分类列表 2021年11月10日16:13:31

master
zhangmeng 2021-11-10 16:13:43 +08:00
parent dd31a658bd
commit 1ea24fdccb
9 changed files with 113 additions and 67 deletions

View File

@ -263,4 +263,29 @@ public class UrlRequestController extends BaseController {
} }
return this.jumpPage("admin/article/edit"); return this.jumpPage("admin/article/edit");
} }
@GetMapping("/category/index")
public ModelAndView category_index(){
return this.jumpPage("admin/category/list");
}
@GetMapping("/category/add")
public ModelAndView category_add(Model model){
Category.Type[] values = Category.Type.values();
model.addAttribute("categoryTypeList",values);
return this.jumpPage("admin/category/add");
}
@GetMapping("/category/edit")
public ModelAndView category_edit(Model model,String categoryId){
Category.Type[] values = Category.Type.values();
model.addAttribute("categoryTypeList",values);
Category category = null;
if (categoryId != null && !categoryId.equals("")){
category = this.categoryFeign.findById(Long.parseLong(categoryId));
}
model.addAttribute("category",category);
return this.jumpPage("admin/category/edit");
}
} }

View File

@ -5,6 +5,7 @@ import com.zhangmeng.model.entity.Article;
import com.zhangmeng.model.entity.Category; import com.zhangmeng.model.entity.Category;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@ -15,5 +16,5 @@ public interface CategoryFeign {
public List<Category> findAll(); public List<Category> findAll();
@GetMapping("/category/findById") @GetMapping("/category/findById")
public Category findById(long categoryId); public Category findById(@RequestParam("categoryId") Long categoryId);
} }

View File

@ -47,15 +47,15 @@ var role_getRolePower_url = gate_way_url + "/" + admin_manager_url + "/role/getR
var role_saveRolePower_url = gate_way_url + "/" + admin_manager_url + "/role/saveRolePower"; var role_saveRolePower_url = gate_way_url + "/" + admin_manager_url + "/role/saveRolePower";
//----------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------
//权限列表 //权限列表
var permission_list_url = gate_way_url + "/" + admin_manager_url + "/permission/list" + access_token_url; var permission_list_url = gate_way_url + "/" + admin_manager_url + "/permission/list" + access_token_url;
//新增权限 //新增权限
var permission_add_url = gate_way_url + "/" + admin_manager_url + "/permission/add" + access_token_url; var permission_add_url = gate_way_url + "/" + admin_manager_url + "/permission/add" + access_token_url;
//修改 //修改
var permission_edit_url = gate_way_url + "/" + admin_manager_url + "/permission/edit" + access_token_url ; var permission_edit_url = gate_way_url + "/" + admin_manager_url + "/permission/edit" + access_token_url;
//查询上级 //查询上级
var permission_selectParent_url = gate_way_url + "/" + admin_manager_url + "/permission/selectParent"; var permission_selectParent_url = gate_way_url + "/" + admin_manager_url + "/permission/selectParent";
//权限保存 //权限保存
var permission_save_url = gate_way_url + "/" + admin_manager_url+ "/permission/save"; var permission_save_url = gate_way_url + "/" + admin_manager_url + "/permission/save";
//删除 //删除
var permission_delete_url = gate_way_url + "/" + admin_manager_url + "/permission/delete"; var permission_delete_url = gate_way_url + "/" + admin_manager_url + "/permission/delete";
//批量删除 //批量删除
@ -78,7 +78,19 @@ var article_batchRemove_url = gate_way_url + "/" + blog_url + "/article/batchRem
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
//文件上传 //文件上传
var file_upload_url = gate_way_url + "/" + file_url + "/upload/file"; var file_upload_url = gate_way_url + "/" + file_url + "/upload/file";
//----------------------------------------------------------------------------------------------------------------
//分类列表
var category_list_url = gate_way_url + "/" + blog_url + "/category/list";
//添加分类
var category_add_url = gate_way_url + "/" + admin_manager_url + "/category/add" + access_token_url;
//修改分类
var category_edit_url = gate_way_url + "/" + admin_manager_url + "/category/edit" + access_token_url;
//分类删除
var category_delete_url = gate_way_url + "/" + blog_url + "/category/delete";
//批量删除
var category_batchRemove_url = gate_way_url + "/" + blog_url + "/category/batchRemove";
//分类保存
var category_save_url = gate_way_url + "/" + blog_url + "/category/save";
//页面跳转 //页面跳转

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>分类添加</title> <title>分类添加</title>
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" /> <link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
</head> </head>
<body> <body>
<form class="layui-form" action=""> <form class="layui-form" action="">
@ -53,8 +53,9 @@
</div> </div>
</div> </div>
</form> </form>
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
<script> <script>
layui.use(['form','jquery'],function(){ layui.use(['form','jquery'],function(){
let form = layui.form; let form = layui.form;
@ -62,14 +63,11 @@
form.on('submit(category-save)', function(data){ form.on('submit(category-save)', function(data){
var obj = data.field; var obj = data.field;
obj['token'] = localStorage.getItem("token"); obj['access_token'] = access_token;
$.ajax({ $.ajax({
url:'/category/save', url:category_save_url,
data:obj, data:obj,
type:'post', type:'post',
beforeSend: function(xhr) {
xhr.setRequestHeader("token:"+ localStorage.getItem("token"));
},
success:function(result){ success:function(result){
if(result.flag){ if(result.flag){
layer.msg(result.message,{icon:1,time:1000},function(){ layer.msg(result.message,{icon:1,time:1000},function(){

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>分类编辑</title> <title>分类编辑</title>
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css"/> <link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
</head> </head>
<body> <body>
<form class="layui-form" action=""> <form class="layui-form" action="">
@ -62,8 +62,9 @@
</div> </div>
</div> </div>
</form> </form>
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
<script> <script>
layui.use(['form', 'jquery'], function () { layui.use(['form', 'jquery'], function () {
let form = layui.form; let form = layui.form;
@ -71,9 +72,9 @@
form.on('submit(category-edit)', function (data) { form.on('submit(category-edit)', function (data) {
var obj = data.field; var obj = data.field;
obj['token'] = localStorage.getItem("token"); obj['access_token'] = access_token;
$.ajax({ $.ajax({
url: '/category/save', url: category_save_url,
data: obj, data: obj,
type: 'post', type: 'post',
success: function (result) { success: function (result) {

View File

@ -3,7 +3,8 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>分类管理</title> <title>分类管理</title>
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" /> <link rel="stylesheet"
href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
</head> </head>
<body class="pear-container"> <body class="pear-container">
<div class="layui-card"> <div class="layui-card">
@ -49,27 +50,30 @@
</script> </script>
<script type="text/html" id="category-bar"> <script type="text/html" id="category-bar">
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button> <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button> </button>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
</button>
</script> </script>
<script type="text/html" id="category-enable"> <script type="text/html" id="category-enable">
<input type="checkbox" name="enable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="category-enable" checked = "{{ d.enable == 0 ? 'true' : 'false' }}"> <input type="checkbox" name="enable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用"
lay-filter="category-enable" checked="{{ d.enable == 0 ? 'true' : 'false' }}">
</script> </script>
<script type="text/html" id="category-addTime"> <script type="text/html" id="category-addTime">
{{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}} {{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}}
</script> </script>
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script> <script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
<script> <script>
layui.use(['table', 'form', 'jquery','common'], function() { layui.use(['table', 'form', 'jquery', 'common'], function () {
let table = layui.table; let table = layui.table;
let form = layui.form; let form = layui.form;
let $ = layui.jquery; let $ = layui.jquery;
let common = layui.common; let common = layui.common;
let token = localStorage.getItem("token");
let cols = [ let cols = [
[{ [{
type: 'checkbox' type: 'checkbox'
@ -110,8 +114,10 @@
table.render({ table.render({
elem: '#category-table', elem: '#category-table',
url: '/category/list', url: category_list_url,
headers: {token: localStorage.getItem("token")}, headers: {
access_token: access_token
},
page: true, page: true,
cols: cols, cols: cols,
skin: 'line', skin: 'line',
@ -121,18 +127,18 @@
layEvent: 'refresh', layEvent: 'refresh',
icon: 'layui-icon-refresh', icon: 'layui-icon-refresh',
}, 'filter', 'print', 'exports'] }, 'filter', 'print', 'exports']
,request: { , request: {
pageName: 'pageNum' //页码的参数名称默认page pageName: 'pageNum' //页码的参数名称默认page
,limitName: 'pageSize' //每页数据量的参数名默认limit , limitName: 'pageSize' //每页数据量的参数名默认limit
} }
,response: { , response: {
statusName: 'code' //规定数据状态的字段名称默认code statusName: 'code' //规定数据状态的字段名称默认code
,statusCode: 2001 //规定成功的状态码默认0 , statusCode: 2001 //规定成功的状态码默认0
,msgName: 'message' //规定状态信息的字段名称默认msg , msgName: 'message' //规定状态信息的字段名称默认msg
,countName: 'count' //规定数据总数的字段名称默认count , countName: 'count' //规定数据总数的字段名称默认count
,dataName: 'data' //规定数据列表的字段名称默认data , dataName: 'data' //规定数据列表的字段名称默认data
} }
,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据 , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
return { return {
"code": res.code, //解析接口状态 "code": res.code, //解析接口状态
"msg": res.message, //解析提示文本 "msg": res.message, //解析提示文本
@ -142,7 +148,7 @@
} }
}); });
table.on('tool(category-table)', function(obj) { table.on('tool(category-table)', function (obj) {
if (obj.event === 'remove') { if (obj.event === 'remove') {
window.remove(obj); window.remove(obj);
} else if (obj.event === 'edit') { } else if (obj.event === 'edit') {
@ -150,7 +156,7 @@
} }
}); });
table.on('toolbar(category-table)', function(obj) { table.on('toolbar(category-table)', function (obj) {
if (obj.event === 'add') { if (obj.event === 'add') {
window.add(); window.add();
} else if (obj.event === 'refresh') { } else if (obj.event === 'refresh') {
@ -160,60 +166,60 @@
} }
}); });
form.on('submit(category-query)', function(data) { form.on('submit(category-query)', function (data) {
table.reload('category-table', { table.reload('category-table', {
where: data.field where: data.field
}); });
return false; return false;
}); });
form.on('switch(category-enable)', function(obj) { form.on('switch(category-enable)', function (obj) {
layer.tips(this.value + ' ' + this.name + '' + obj.elem.checked, obj.othis); layer.tips(this.value + ' ' + this.name + '' + obj.elem.checked, obj.othis);
}); });
window.add = function() { window.add = function () {
layer.open({ layer.open({
type: 2, type: 2,
title: '新增', title: '新增',
shade: 0.1, shade: 0.1,
area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'], area: [common.isModile() ? '100%' : '900px', common.isModile() ? '100%' : '600px'],
content: '/category/add?token=' + token content: category_add_url
}); });
}; };
window.edit = function(obj) { window.edit = function (obj) {
layer.open({ layer.open({
type: 2, type: 2,
title: '修改', title: '修改',
shade: 0.1, shade: 0.1,
area: ['900px', '600px'], area: ['900px', '600px'],
content: '/category/edit?token=' + token + '&categoryId=' + obj.data.id content: category_edit_url + '&categoryId=' + obj.data.id
}); });
}; };
window.remove = function(obj) { window.remove = function (obj) {
layer.confirm('确定要删除该用户', { layer.confirm('确定要删除该用户', {
icon: 3, icon: 3,
title: '提示' title: '提示'
}, function(index) { }, function (index) {
layer.close(index); layer.close(index);
let loading = layer.load(); let loading = layer.load();
$.ajax({ $.ajax({
url: "/category/delete", url: category_delete_url,
data:{ data: {
categoryId:obj.data['id'], categoryId: obj.data['id'],
token:token access_token: access_token
}, },
type: 'post', type: 'post',
success: function(result) { success: function (result) {
layer.close(loading); layer.close(loading);
if (result.flag) { if (result.flag) {
layer.msg(result.message, { layer.msg(result.message, {
icon: 1, icon: 1,
time: 1000 time: 1000
}, function() { }, function () {
obj.del(); obj.del();
}); });
} else { } else {
@ -227,9 +233,9 @@
}); });
}; };
window.batchRemove = function(obj) { window.batchRemove = function (obj) {
var checkIds = common.checkField(obj,'id'); var checkIds = common.checkField(obj, 'id');
if (checkIds === "") { if (checkIds === "") {
layer.msg("未选中数据", { layer.msg("未选中数据", {
@ -242,23 +248,23 @@
layer.confirm('确定要删除这些用户', { layer.confirm('确定要删除这些用户', {
icon: 3, icon: 3,
title: '提示' title: '提示'
}, function(index) { }, function (index) {
layer.close(index); layer.close(index);
let loading = layer.load(); let loading = layer.load();
$.ajax({ $.ajax({
url: "/category/batchRemove", url: category_batchRemove_url,
data:{ data: {
ids:checkIds, ids: checkIds,
token:token access_token: access_token
}, },
type: 'post', type: 'post',
success: function(result) { success: function (result) {
layer.close(loading); layer.close(loading);
if (result.flag) { if (result.flag) {
layer.msg(result.message, { layer.msg(result.message, {
icon: 1, icon: 1,
time: 1000 time: 1000
}, function() { }, function () {
table.reload('category-table'); table.reload('category-table');
}); });
} else { } else {
@ -272,7 +278,7 @@
}); });
}; };
window.refresh = function(param) { window.refresh = function (param) {
table.reload('category-table'); table.reload('category-table');
} }
}) })

View File

@ -32,5 +32,5 @@ public interface CategoryControllerApi {
public List<Category> findAll(); public List<Category> findAll();
@ApiOperation("根据id查询") @ApiOperation("根据id查询")
public Category findById(@RequestParam long categoryId); public Category findById(@RequestParam("categoryId") Long categoryId);
} }

View File

@ -78,6 +78,9 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
*/ */
@Override @Override
public void configure(HttpSecurity http) throws Exception { public void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable();
// 所有请求必须认证通过 // 所有请求必须认证通过
http.authorizeRequests() http.authorizeRequests()
// 跨域预检请求 // 跨域预检请求

View File

@ -112,8 +112,8 @@ public class CategoryController extends BaseController implements CategoryContro
return this.categoryService.findAll(); return this.categoryService.findAll();
} }
@GetMapping("/category/findById") @GetMapping("findById")
public Category findById(@RequestParam long categoryId){ public Category findById(@RequestParam("categoryId") Long categoryId){
return this.categoryService.findById(categoryId); return this.categoryService.findById(categoryId);
} }
} }