修改文章列表 2021年11月10日11:11:54
parent
0da400a054
commit
0e3f85214e
|
|
@ -2,6 +2,7 @@ package com.zhangmeng.admin.manager.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
||||||
|
import com.zhangmeng.admin.manager.feign.CategoryFeign;
|
||||||
import com.zhangmeng.admin.manager.service.PermissionService;
|
import com.zhangmeng.admin.manager.service.PermissionService;
|
||||||
import com.zhangmeng.admin.manager.service.RoleService;
|
import com.zhangmeng.admin.manager.service.RoleService;
|
||||||
import com.zhangmeng.admin.manager.service.SysLogService;
|
import com.zhangmeng.admin.manager.service.SysLogService;
|
||||||
|
|
@ -12,8 +13,6 @@ import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||||
import com.zhangmeng.model.dto.Menu;
|
import com.zhangmeng.model.dto.Menu;
|
||||||
import com.zhangmeng.model.dto.query.QueryParams;
|
import com.zhangmeng.model.dto.query.QueryParams;
|
||||||
import com.zhangmeng.model.entity.*;
|
import com.zhangmeng.model.entity.*;
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.bouncycastle.math.raw.Mod;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
|
@ -22,7 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
import tk.mybatis.mapper.entity.Condition;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -52,6 +50,9 @@ public class UrlRequestController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryFeign categoryFeign;
|
||||||
|
|
||||||
//跳转首页
|
//跳转首页
|
||||||
@GetMapping({"/login","/"})
|
@GetMapping({"/login","/"})
|
||||||
public ModelAndView login (){
|
public ModelAndView login (){
|
||||||
|
|
@ -231,4 +232,35 @@ public class UrlRequestController extends BaseController {
|
||||||
}
|
}
|
||||||
return this.jumpPage("admin/permission/edit");
|
return this.jumpPage("admin/permission/edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiIgnore
|
||||||
|
@GetMapping("/article/index")
|
||||||
|
public ModelAndView article_index(Model model,Long categoryId) {
|
||||||
|
List<Category> categoryList = this.categoryFeign.findAll();
|
||||||
|
model.addAttribute("categoryList",categoryList);
|
||||||
|
model.addAttribute("categoryId",categoryId == null ? 0L : categoryId);
|
||||||
|
return this.jumpPage("admin/article/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiIgnore
|
||||||
|
@GetMapping("/article/add")
|
||||||
|
public ModelAndView article_add(Model model) {
|
||||||
|
//查询分类
|
||||||
|
List<Category> categoryList = this.categoryFeign.findAll();
|
||||||
|
model.addAttribute("categoryList", categoryList);
|
||||||
|
return this.jumpPage("admin/article/add");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiIgnore
|
||||||
|
@GetMapping("/article/edit")
|
||||||
|
public ModelAndView article_edit(Model model,String articleId) {
|
||||||
|
if (CommonUtil.isNotNull(articleId)){
|
||||||
|
Article article = this.articleFeign.findById(Long.parseLong(articleId));
|
||||||
|
model.addAttribute("article",article);
|
||||||
|
//查询分类
|
||||||
|
List<Category> categoryList = this.categoryFeign.findAll();
|
||||||
|
model.addAttribute("categoryList", categoryList);
|
||||||
|
}
|
||||||
|
return this.jumpPage("admin/article/edit");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.zhangmeng.admin.manager.feign;
|
package com.zhangmeng.admin.manager.feign;
|
||||||
|
|
||||||
import com.zhangmeng.model.dto.SysConstant;
|
import com.zhangmeng.model.dto.SysConstant;
|
||||||
import com.zhangmeng.model.dto.query.QueryParams;
|
|
||||||
import com.zhangmeng.model.entity.Article;
|
import com.zhangmeng.model.entity.Article;
|
||||||
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;
|
||||||
|
|
@ -10,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@FeignClient(SysConstant.mystyle_cloud_blog)
|
@FeignClient(value = SysConstant.mystyle_cloud_blog,contextId ="ArticleFeign")
|
||||||
public interface ArticleFeign {
|
public interface ArticleFeign {
|
||||||
|
|
||||||
@GetMapping("/article/selectCountByDayOfPass")
|
@GetMapping("/article/selectCountByDayOfPass")
|
||||||
|
|
@ -21,4 +20,7 @@ public interface ArticleFeign {
|
||||||
|
|
||||||
@GetMapping("/article/findByCondition")
|
@GetMapping("/article/findByCondition")
|
||||||
List<Article> findByCondition();
|
List<Article> findByCondition();
|
||||||
|
|
||||||
|
@GetMapping("/article/findById")
|
||||||
|
Article findById(@RequestParam(value = "articleId") Long articleId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.zhangmeng.admin.manager.feign;
|
||||||
|
|
||||||
|
import com.zhangmeng.model.dto.SysConstant;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(value = SysConstant.mystyle_cloud_blog,contextId = "CategoryFeign")
|
||||||
|
public interface CategoryFeign {
|
||||||
|
|
||||||
|
@GetMapping("/category/findAll")
|
||||||
|
public List<Category> findAll();
|
||||||
|
|
||||||
|
@GetMapping("/category/findById")
|
||||||
|
public Category findById(long categoryId);
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,8 @@ var gate_way_url = "http://localhost:9000";
|
||||||
var admin_manager_url = "mystyle-cloud-admin-manager";
|
var admin_manager_url = "mystyle-cloud-admin-manager";
|
||||||
//授权微服务
|
//授权微服务
|
||||||
var user_oauth_url = "mystyle-cloud-oauth";
|
var user_oauth_url = "mystyle-cloud-oauth";
|
||||||
|
//博客微服务
|
||||||
|
var blog_url = "mystyle-cloud-blog";
|
||||||
//验证码
|
//验证码
|
||||||
var v_code = gate_way_url + "/" + admin_manager_url + "/verificationCode/generate";
|
var v_code = gate_way_url + "/" + admin_manager_url + "/verificationCode/generate";
|
||||||
var access_token = localStorage.getItem("access_token");
|
var access_token = localStorage.getItem("access_token");
|
||||||
|
|
@ -56,6 +58,9 @@ var permission_save_url = gate_way_url + "/" + admin_manager_url+ "/permission/s
|
||||||
var permission_delete_url = gate_way_url + "/" + admin_manager_url + "/permission/delete";
|
var permission_delete_url = gate_way_url + "/" + admin_manager_url + "/permission/delete";
|
||||||
//批量删除
|
//批量删除
|
||||||
var permission_batchRemove_url = gate_way_url + "/" + admin_manager_url + "";
|
var permission_batchRemove_url = gate_way_url + "/" + admin_manager_url + "";
|
||||||
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
//文章列表
|
||||||
|
var article_list_url = gate_way_url + "/" + blog_url + "/article/list";
|
||||||
|
|
||||||
//页面跳转
|
//页面跳转
|
||||||
function postToPage(url, token) {
|
function postToPage(url, token) {
|
||||||
|
|
|
||||||
|
|
@ -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" />
|
||||||
<style>
|
<style>
|
||||||
.layui-table-cell{
|
.layui-table-cell{
|
||||||
display:table-cell;
|
display:table-cell;
|
||||||
|
|
@ -102,17 +102,15 @@
|
||||||
|
|
||||||
</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'
|
||||||
|
|
@ -166,8 +164,10 @@
|
||||||
|
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#article-table',
|
elem: '#article-table',
|
||||||
url: '/article/list',
|
url: article_list_url,
|
||||||
headers: {token: localStorage.getItem("token")},
|
headers: {
|
||||||
|
access_token: access_token
|
||||||
|
},
|
||||||
page: true,
|
page: true,
|
||||||
cols: cols,
|
cols: cols,
|
||||||
skin: 'line',
|
skin: 'line',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.zhangmeng.api.service.blog;
|
||||||
|
|
||||||
|
import com.zhangmeng.model.entity.Article;
|
||||||
|
import com.zhangmeng.model.vo.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Api(tags = "文章管理")
|
||||||
|
public interface ArticleControllerApi {
|
||||||
|
|
||||||
|
@ApiOperation("文章保存")
|
||||||
|
public Result save(@RequestParam @RequestBody Map<String, Object> parms);
|
||||||
|
|
||||||
|
@ApiOperation("文章列表")
|
||||||
|
public Result list(Integer pageNum, Integer pageSize, String startTime, String endTime, String title,Long categoryId);
|
||||||
|
|
||||||
|
@ApiOperation("批量删除文章")
|
||||||
|
public Result batchRemove( String ids);
|
||||||
|
|
||||||
|
@ApiOperation("文章统计")
|
||||||
|
public Integer selectCountEq(boolean deleteStatus);
|
||||||
|
|
||||||
|
@ApiOperation("分天统计文章数")
|
||||||
|
public List<Integer> selectCountByDayOfPass(@RequestBody @RequestParam(value = "x_date") List<String> x_date);
|
||||||
|
|
||||||
|
@ApiOperation("查询文章")
|
||||||
|
public List<Article> findByCondition();
|
||||||
|
|
||||||
|
@ApiOperation("根据id查询")
|
||||||
|
public Article findById(@RequestParam Long articleId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.zhangmeng.api.service.blog;
|
||||||
|
|
||||||
|
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||||
|
import com.zhangmeng.model.entity.Category;
|
||||||
|
import com.zhangmeng.model.vo.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Api(tags = "分类管理")
|
||||||
|
public interface CategoryControllerApi {
|
||||||
|
|
||||||
|
@ApiOperation("分类保存")
|
||||||
|
public Result save(@RequestParam @RequestBody Map<String,Object> map);
|
||||||
|
|
||||||
|
@ApiOperation("分类列表")
|
||||||
|
public Result list(Integer pageNum, Integer pageSize ,String categoryName);
|
||||||
|
|
||||||
|
@ApiOperation("删除分类")
|
||||||
|
public Result delete(String categoryId);
|
||||||
|
|
||||||
|
@ApiOperation("分类批量删除")
|
||||||
|
public Result batchRemove(String ids) ;
|
||||||
|
|
||||||
|
@ApiOperation("查询所有分类")
|
||||||
|
public List<Category> findAll();
|
||||||
|
|
||||||
|
@ApiOperation("根据id查询")
|
||||||
|
public Category findById(@RequestParam long categoryId);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zhangmeng.blog.controller;
|
package com.zhangmeng.blog.controller;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.zhangmeng.api.service.blog.ArticleControllerApi;
|
||||||
import com.zhangmeng.blog.feign.UserFeign;
|
import com.zhangmeng.blog.feign.UserFeign;
|
||||||
import com.zhangmeng.blog.service.ArticleService;
|
import com.zhangmeng.blog.service.ArticleService;
|
||||||
import com.zhangmeng.blog.service.CategoryService;
|
import com.zhangmeng.blog.service.CategoryService;
|
||||||
|
|
@ -26,10 +27,10 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(tags = "文章管理")
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/article")
|
@RequestMapping("/article")
|
||||||
public class ArticleController extends BaseController {
|
public class ArticleController extends BaseController implements ArticleControllerApi {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
|
@ -40,7 +41,7 @@ public class ArticleController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserFeign userFeign;
|
private UserFeign userFeign;
|
||||||
|
|
||||||
@ApiOperation("文章保存")
|
@Override
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public Result save(@RequestParam @RequestBody Map<String, Object> parms) {
|
public Result save(@RequestParam @RequestBody Map<String, Object> parms) {
|
||||||
String articleId = CommonUtil.map_get_value(parms, "articleId");
|
String articleId = CommonUtil.map_get_value(parms, "articleId");
|
||||||
|
|
@ -116,7 +117,7 @@ public class ArticleController extends BaseController {
|
||||||
return this.success("保存成功");
|
return this.success("保存成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("文章列表")
|
@Override
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result list(Integer pageNum, Integer pageSize, String startTime, String endTime, String title,Long categoryId) {
|
public Result list(Integer pageNum, Integer pageSize, String startTime, String endTime, String title,Long categoryId) {
|
||||||
Condition condition = new Condition(Article.class);
|
Condition condition = new Condition(Article.class);
|
||||||
|
|
@ -145,7 +146,7 @@ public class ArticleController extends BaseController {
|
||||||
return new Result(true,StatusCode.OK,"删除成功");
|
return new Result(true,StatusCode.OK,"删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("批量删除文章")
|
@Override
|
||||||
@PostMapping("/batchRemove")
|
@PostMapping("/batchRemove")
|
||||||
public Result batchRemove( String ids) {
|
public Result batchRemove( String ids) {
|
||||||
String id_s = CommonUtil.firstLastComma(ids);
|
String id_s = CommonUtil.firstLastComma(ids);
|
||||||
|
|
@ -158,18 +159,26 @@ public class ArticleController extends BaseController {
|
||||||
return new Result(true,StatusCode.OK,"删除成功");
|
return new Result(true,StatusCode.OK,"删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@GetMapping("/selectCountEq")
|
@GetMapping("/selectCountEq")
|
||||||
public Integer selectCountEq(boolean deleteStatus){
|
public Integer selectCountEq(boolean deleteStatus){
|
||||||
return this.articleService.selectCountEq("deleteStatus",deleteStatus);
|
return this.articleService.selectCountEq("deleteStatus",deleteStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@GetMapping("/selectCountByDayOfPass")
|
@GetMapping("/selectCountByDayOfPass")
|
||||||
public List<Integer> selectCountByDayOfPass(@RequestBody @RequestParam(value = "x_date") List<String> x_date){
|
public List<Integer> selectCountByDayOfPass(@RequestBody @RequestParam(value = "x_date") List<String> x_date){
|
||||||
return this.articleService.selectCountByDayOfPass(x_date);
|
return this.articleService.selectCountByDayOfPass(x_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@GetMapping("/findByCondition")
|
@GetMapping("/findByCondition")
|
||||||
public List<Article> findByCondition(){
|
public List<Article> findByCondition(){
|
||||||
return this.articleService.findByCondition(new QueryParams(new Condition(Article.class)));
|
return this.articleService.findByCondition(new QueryParams(new Condition(Article.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/findById")
|
||||||
|
public Article findById(@RequestParam Long articleId){
|
||||||
|
return this.articleService.findById(articleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.zhangmeng.blog.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.zhangmeng.api.service.blog.CategoryControllerApi;
|
||||||
|
import com.zhangmeng.blog.feign.UserFeign;
|
||||||
|
import com.zhangmeng.blog.service.CategoryService;
|
||||||
|
import com.zhangmeng.model.base.baseController.BaseController;
|
||||||
|
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||||
|
import com.zhangmeng.model.dto.query.QueryParams;
|
||||||
|
import com.zhangmeng.model.entity.Article;
|
||||||
|
import com.zhangmeng.model.entity.Category;
|
||||||
|
import com.zhangmeng.model.vo.Result;
|
||||||
|
import com.zhangmeng.model.vo.StatusCode;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
import tk.mybatis.mapper.entity.Condition;
|
||||||
|
import tk.mybatis.mapper.entity.Example;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/category")
|
||||||
|
public class CategoryController extends BaseController implements CategoryControllerApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserFeign userFeign;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Result save(@RequestParam @RequestBody Map<String,Object> map){
|
||||||
|
Category category = null;
|
||||||
|
String categoryId = CommonUtil.map_get_value(map,"categoryId");
|
||||||
|
boolean flag = false;
|
||||||
|
if (categoryId == null || categoryId.equals("")){
|
||||||
|
category = new Category();
|
||||||
|
category.setAddTime(new Date());
|
||||||
|
category.setUpdateTime(new Date());
|
||||||
|
category.setDeleteStatus(false);
|
||||||
|
flag = true;
|
||||||
|
}else {
|
||||||
|
category = this.categoryService.findById(Long.parseLong(categoryId));
|
||||||
|
}
|
||||||
|
String categoryName = CommonUtil.map_get_value(map,"categoryName") ;
|
||||||
|
if (CommonUtil.isNotNull(categoryName)){
|
||||||
|
category.setCategoryName(categoryName);
|
||||||
|
}
|
||||||
|
String description = CommonUtil.map_get_value(map,"description");
|
||||||
|
if (CommonUtil.isNotNull(description)){
|
||||||
|
category.setDescription(description);
|
||||||
|
}
|
||||||
|
category.setCreateUserId(Objects.requireNonNull(userFeign.getCurrentUser()).getId());
|
||||||
|
String categoryType = CommonUtil.map_get_value(map,"categoryType");
|
||||||
|
if (categoryType != null && !categoryType.equals("")){
|
||||||
|
Category.Type type = CommonUtil.getEnum(categoryType,Category.Type.class);
|
||||||
|
category.setType(type);
|
||||||
|
}
|
||||||
|
String message = null;
|
||||||
|
if (flag){
|
||||||
|
message = "保存成功";
|
||||||
|
this.categoryService.save(category);
|
||||||
|
}else {
|
||||||
|
message = "修改成功";
|
||||||
|
this.categoryService.update(category);
|
||||||
|
}
|
||||||
|
return success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result list(Integer pageNum, Integer pageSize ,String categoryName){
|
||||||
|
Condition condition = new Condition(Category.class);
|
||||||
|
Example.Criteria criteria = condition.createCriteria();
|
||||||
|
if (categoryName != null && !categoryName.equals("")){
|
||||||
|
criteria.andLike("categoryName","%"+ categoryName + "%");
|
||||||
|
}
|
||||||
|
PageInfo<Category> pageInfo = this.categoryService.findByCondition(new QueryParams(pageNum, pageSize, condition),true);
|
||||||
|
return new Result(true, StatusCode.OK,"查询成功",pageInfo.getTotal(),pageInfo.getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public Result delete(String categoryId){
|
||||||
|
if (categoryId != null && !categoryId.equals("")){
|
||||||
|
this.categoryService.deleteById(Long.parseLong(categoryId));
|
||||||
|
}
|
||||||
|
return new Result(true, StatusCode.OK, "删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostMapping("/batchRemove")
|
||||||
|
public Result batchRemove(String ids) {
|
||||||
|
if (CommonUtil.isNotNull(ids)) {
|
||||||
|
this.categoryService.deleteByIds(CommonUtil.firstLastComma(ids));
|
||||||
|
}
|
||||||
|
return this.success("批量删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/findAll")
|
||||||
|
public List<Category> findAll(){
|
||||||
|
return this.categoryService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/category/findById")
|
||||||
|
public Category findById(@RequestParam long categoryId){
|
||||||
|
return this.categoryService.findById(categoryId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -46,5 +46,11 @@ spring:
|
||||||
uri: lb://mystyle-cloud-admin-manager
|
uri: lb://mystyle-cloud-admin-manager
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/mystyle-cloud-admin-manager/**
|
- Path=/mystyle-cloud-admin-manager/**
|
||||||
|
filters:
|
||||||
|
- StripPrefix=1
|
||||||
|
- id: mystyle-cloud-blog
|
||||||
|
uri: lb://mystyle-cloud-blog
|
||||||
|
predicates:
|
||||||
|
- Path=/mystyle-cloud-blog/**
|
||||||
filters:
|
filters:
|
||||||
- StripPrefix=1
|
- StripPrefix=1
|
||||||
Loading…
Reference in New Issue