修改分类列表 2021年11月10日16:13:31
parent
dd31a658bd
commit
1ea24fdccb
|
|
@ -263,4 +263,29 @@ public class UrlRequestController extends BaseController {
|
|||
}
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.zhangmeng.model.entity.Article;
|
|||
import com.zhangmeng.model.entity.Category;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -15,5 +16,5 @@ public interface CategoryFeign {
|
|||
public List<Category> findAll();
|
||||
|
||||
@GetMapping("/category/findById")
|
||||
public Category findById(long categoryId);
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 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_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";
|
||||
//批量删除
|
||||
|
|
@ -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 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";
|
||||
|
||||
|
||||
//页面跳转
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -53,8 +53,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/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/layui/layui.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>
|
||||
layui.use(['form','jquery'],function(){
|
||||
let form = layui.form;
|
||||
|
|
@ -62,14 +63,11 @@
|
|||
|
||||
form.on('submit(category-save)', function(data){
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url:'/category/save',
|
||||
url:category_save_url,
|
||||
data:obj,
|
||||
type:'post',
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("token:"+ localStorage.getItem("token"));
|
||||
},
|
||||
success:function(result){
|
||||
if(result.flag){
|
||||
layer.msg(result.message,{icon:1,time:1000},function(){
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -62,8 +62,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/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/layui/layui.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>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
|
|
@ -71,9 +72,9 @@
|
|||
|
||||
form.on('submit(category-edit)', function (data) {
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
obj['access_token'] = access_token;
|
||||
$.ajax({
|
||||
url: '/category/save',
|
||||
url: category_save_url,
|
||||
data: obj,
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<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>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
|
@ -49,27 +50,30 @@
|
|||
</script>
|
||||
|
||||
<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-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
|
||||
<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-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<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 type="text/html" id="category-addTime">
|
||||
{{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}}
|
||||
</script>
|
||||
|
||||
<script src="${springMacroRequestContext.contextPath}/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/layui/layui.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>
|
||||
layui.use(['table', 'form', 'jquery','common'], function() {
|
||||
layui.use(['table', 'form', 'jquery', 'common'], function () {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let common = layui.common;
|
||||
let token = localStorage.getItem("token");
|
||||
let cols = [
|
||||
[{
|
||||
type: 'checkbox'
|
||||
|
|
@ -110,8 +114,10 @@
|
|||
|
||||
table.render({
|
||||
elem: '#category-table',
|
||||
url: '/category/list',
|
||||
headers: {token: localStorage.getItem("token")},
|
||||
url: category_list_url,
|
||||
headers: {
|
||||
access_token: access_token
|
||||
},
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
|
|
@ -121,18 +127,18 @@
|
|||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
,request: {
|
||||
, request: {
|
||||
pageName: 'pageNum' //页码的参数名称,默认:page
|
||||
,limitName: 'pageSize' //每页数据量的参数名,默认:limit
|
||||
, limitName: 'pageSize' //每页数据量的参数名,默认:limit
|
||||
}
|
||||
,response: {
|
||||
, response: {
|
||||
statusName: 'code' //规定数据状态的字段名称,默认:code
|
||||
,statusCode: 2001 //规定成功的状态码,默认:0
|
||||
,msgName: 'message' //规定状态信息的字段名称,默认:msg
|
||||
,countName: 'count' //规定数据总数的字段名称,默认:count
|
||||
,dataName: 'data' //规定数据列表的字段名称,默认:data
|
||||
, statusCode: 2001 //规定成功的状态码,默认:0
|
||||
, msgName: 'message' //规定状态信息的字段名称,默认:msg
|
||||
, countName: 'count' //规定数据总数的字段名称,默认:count
|
||||
, dataName: 'data' //规定数据列表的字段名称,默认:data
|
||||
}
|
||||
,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
|
||||
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
|
||||
return {
|
||||
"code": res.code, //解析接口状态
|
||||
"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') {
|
||||
window.remove(obj);
|
||||
} 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') {
|
||||
window.add();
|
||||
} 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', {
|
||||
where: data.field
|
||||
});
|
||||
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);
|
||||
});
|
||||
|
||||
window.add = function() {
|
||||
window.add = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'],
|
||||
content: '/category/add?token=' + token
|
||||
area: [common.isModile() ? '100%' : '900px', common.isModile() ? '100%' : '600px'],
|
||||
content: category_add_url
|
||||
});
|
||||
};
|
||||
|
||||
window.edit = function(obj) {
|
||||
window.edit = function (obj) {
|
||||
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
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('确定要删除该用户', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function(index) {
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/category/delete",
|
||||
data:{
|
||||
categoryId:obj.data['id'],
|
||||
token:token
|
||||
url: category_delete_url,
|
||||
data: {
|
||||
categoryId: obj.data['id'],
|
||||
access_token: access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function(result) {
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.flag) {
|
||||
layer.msg(result.message, {
|
||||
icon: 1,
|
||||
time: 1000
|
||||
}, function() {
|
||||
}, function () {
|
||||
obj.del();
|
||||
});
|
||||
} 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 === "") {
|
||||
layer.msg("未选中数据", {
|
||||
|
|
@ -242,23 +248,23 @@
|
|||
layer.confirm('确定要删除这些用户', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function(index) {
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/category/batchRemove",
|
||||
data:{
|
||||
ids:checkIds,
|
||||
token:token
|
||||
url: category_batchRemove_url,
|
||||
data: {
|
||||
ids: checkIds,
|
||||
access_token: access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function(result) {
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.flag) {
|
||||
layer.msg(result.message, {
|
||||
icon: 1,
|
||||
time: 1000
|
||||
}, function() {
|
||||
}, function () {
|
||||
table.reload('category-table');
|
||||
});
|
||||
} else {
|
||||
|
|
@ -272,7 +278,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
window.refresh = function(param) {
|
||||
window.refresh = function (param) {
|
||||
table.reload('category-table');
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ public interface CategoryControllerApi {
|
|||
public List<Category> findAll();
|
||||
|
||||
@ApiOperation("根据id查询")
|
||||
public Category findById(@RequestParam long categoryId);
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
|||
*/
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http.headers().frameOptions().disable();
|
||||
|
||||
// 所有请求必须认证通过
|
||||
http.authorizeRequests()
|
||||
// 跨域预检请求
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ public class CategoryController extends BaseController implements CategoryContro
|
|||
return this.categoryService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/category/findById")
|
||||
public Category findById(@RequestParam long categoryId){
|
||||
@GetMapping("findById")
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId){
|
||||
return this.categoryService.findById(categoryId);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue