Merge branch 'master' into qiuqiu
This commit is contained in:
@@ -61,14 +61,6 @@ public class CategoryManagerController {
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加商品分类")
|
||||
public ResultMessage<Category> saveCategory(@Valid Category category) {
|
||||
|
||||
//不能添加重复的分类名称
|
||||
Category category1 = new Category();
|
||||
category1.setName(category.getName());
|
||||
List<Category> list = categoryService.findByAllBySortOrder(category1);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
//非顶级分类
|
||||
if (category.getParentId() != null && !category.getParentId().equals("0")) {
|
||||
Category parent = categoryService.getById(category.getParentId());
|
||||
@@ -90,15 +82,7 @@ public class CategoryManagerController {
|
||||
public ResultMessage<Category> updateCategory(@Valid CategoryVO category) {
|
||||
Category catTemp = categoryService.getById(category.getId());
|
||||
if (catTemp == null) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_PARENT_NOT_EXIST);
|
||||
}
|
||||
//不能添加重复的分类名称
|
||||
Category category1 = new Category();
|
||||
category1.setName(category.getName());
|
||||
category1.setId(category.getId());
|
||||
List<Category> list = categoryService.findByAllBySortOrder(category1);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_NAME_IS_EXIST);
|
||||
throw new ServiceException(ResultCode.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
|
||||
categoryService.updateCategory(category);
|
||||
|
||||
@@ -53,8 +53,8 @@ public class ArticleManagerController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加文章")
|
||||
@PostMapping
|
||||
public ResultMessage<Article> save(@Valid Article article) {
|
||||
@PostMapping(consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<Article> save(@RequestBody Article article) {
|
||||
article.setType(ArticleEnum.OTHER.name());
|
||||
articleService.save(article);
|
||||
return ResultUtil.data(article);
|
||||
@@ -62,8 +62,8 @@ public class ArticleManagerController {
|
||||
|
||||
@ApiOperation(value = "修改文章")
|
||||
@ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path")
|
||||
@PutMapping("update/{id}")
|
||||
public ResultMessage<Article> update(@Valid Article article, @PathVariable("id") String id) {
|
||||
@PutMapping(value = "update/{id}", consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<Article> update(@RequestBody Article article, @PathVariable("id") String id) {
|
||||
article.setId(id);
|
||||
return ResultUtil.data(articleService.updateArticle(article));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user