Ver Fonte

fix 批量修改文章分类

zwhui há 2 anos atrás
pai
commit
5191369dc9

+ 6 - 8
netflix-web/src/main/java/com/cyksj/web/controller/manage/information/CmsInformationController.java

@@ -136,8 +136,9 @@ public class CmsInformationController {
      * 保存文章类型
      */
     @PostMapping("/post/category")
-    public Result<String> saveInformationCategory(@RequestBody InformationCategory informationCategory) {
-        informationCategoryService.save(informationCategory);
+    public Result<String> saveInformationCategory(@RequestBody List<InformationCategory> informationCategorys) {
+        log.info("保存文章类型 categorys:{}",informationCategorys);
+        informationCategoryService.saveBatch(informationCategorys);
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
@@ -145,11 +146,8 @@ public class CmsInformationController {
      * 修改文章类型
      */
     @PutMapping("/put/category")
-    public Result<String> updateInformationCategory(@RequestBody InformationCategory informationCategory) {
-        if (informationCategory.getId() == null) {
-            throw BusinessRuntimeException.getInstance("请指定要修改的文章类型");
-        }
-        informationCategoryService.updateById(informationCategory);
+    public Result<String> updateInformationCategory(@RequestBody List<InformationCategory> informationCategorys) {
+        informationCategoryService.updateBatchById(informationCategorys);
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
@@ -166,7 +164,7 @@ public class CmsInformationController {
      */
     @DeleteMapping("/del/category/{id}")
     public Result<String> delCategoryById(@PathVariable Long id) {
-        int count = informationService.count(Wrappers.lambdaQuery(Information.class).eq(Information::getDeleted, true));
+        int count = informationService.count(Wrappers.lambdaQuery(Information.class).apply("JSON_CONTAINS(category_id,'\"" + id + "\"')").eq(Information::getDeleted, true));
         if (count > 0){
             throw BusinessRuntimeException.getInstance("该类型下存在文章,无法删除");
         }