修改分类列表 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
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',
|
||||
|
|
@ -177,7 +183,7 @@
|
|||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '100%' : '900px', common.isModile() ? '100%' : '600px'],
|
||||
content: '/category/add?token=' + token
|
||||
content: category_add_url
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -188,7 +194,7 @@
|
|||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/category/edit?token=' + token + '&categoryId=' + obj.data.id
|
||||
content: category_edit_url + '&categoryId=' + obj.data.id
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -201,10 +207,10 @@
|
|||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/category/delete",
|
||||
url: category_delete_url,
|
||||
data: {
|
||||
categoryId: obj.data['id'],
|
||||
token:token
|
||||
access_token: access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
@ -246,10 +252,10 @@
|
|||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/category/batchRemove",
|
||||
url: category_batchRemove_url,
|
||||
data: {
|
||||
ids: checkIds,
|
||||
token:token
|
||||
access_token: access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
|
|||
|
|
@ -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