|
@@ -4,7 +4,6 @@ import com.my.bigevent.pojo.Category;
|
|
import com.my.bigevent.pojo.Result;
|
|
import com.my.bigevent.pojo.Result;
|
|
import com.my.bigevent.service.CategoryService;
|
|
import com.my.bigevent.service.CategoryService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -22,7 +21,7 @@ public class CategoryController
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@PostMapping
|
|
@PostMapping
|
|
- public Result add(@RequestBody @Validated Category category)
|
|
|
|
|
|
+ public Result add(@RequestBody Category category)
|
|
{
|
|
{
|
|
return categoryService.add(category);
|
|
return categoryService.add(category);
|
|
}
|
|
}
|
|
@@ -44,8 +43,18 @@ public class CategoryController
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@PutMapping //指定分组校验中的 Update.class 分组进行校验
|
|
@PutMapping //指定分组校验中的 Update.class 分组进行校验
|
|
- public Result update(@RequestBody @Validated(Category.Update.class) Category category)
|
|
|
|
|
|
+ public Result update(@RequestBody Category category)
|
|
{
|
|
{
|
|
|
|
+ if(null==category.getCategoryName()||category.getCategoryName().isEmpty()){
|
|
|
|
+ return Result.error("分类名称不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(null==category.getCategoryAlias()||category.getCategoryAlias().isEmpty()){
|
|
|
|
+ return Result.error("分类别名不能为空");
|
|
|
|
+ }
|
|
|
|
+ Integer count=categoryService.selectCountByNameWithoutSelf(category);
|
|
|
|
+ if(count>0){
|
|
|
|
+ return Result.error("标签名称重复");
|
|
|
|
+ }
|
|
categoryService.update(category);
|
|
categoryService.update(category);
|
|
return Result.success("更新文章分类成功!");
|
|
return Result.success("更新文章分类成功!");
|
|
}
|
|
}
|