浏览代码

1.增加视频资源批量修改分类功能

jzp 1 天之前
父节点
当前提交
2ca352becc
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      fs-admin/src/main/java/com/fs/course/controller/FsVideoResourceController.java

+ 38 - 0
fs-admin/src/main/java/com/fs/course/controller/FsVideoResourceController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 资源库管理
@@ -102,6 +103,43 @@ public class FsVideoResourceController extends BaseController {
         return AjaxResult.success();
     }
 
+    /**
+     * 批量修改视频分类
+     * @param typeId
+     * @param typeSubId
+     * @param ids
+     * @return
+     */
+    @PreAuthorize("@ss.hasPermi('course:videoResource:batchUpdateClass')")
+    @Log(title = "视频素材库", businessType = BusinessType.UPDATE)
+    @PostMapping("/batchUpdateClass")
+    public AjaxResult batchUpdateClass(@RequestParam("typeId") Long typeId,
+                                       @RequestParam("typeSubId") Long typeSubId,
+                                       @RequestParam("ids") String ids) {
+        if(typeId == null || typeId <= 0){
+            return AjaxResult.error("请选择分类");
+        }
+        if(typeSubId == null || typeSubId <= 0){
+            return AjaxResult.error("请选择子分类");
+        }
+        if(ids == null || ids.isEmpty()){
+            return AjaxResult.error("请选择要修改的分类");
+        }
+
+        // 将ids字符串分割为ID列表
+        List<String> idList = Arrays.asList(ids.split(","));
+
+        // 创建更新条件
+        Wrapper<FsVideoResource> updateWrapper = Wrappers.<FsVideoResource>lambdaUpdate()
+                .set(FsVideoResource::getTypeId, typeId)
+                .set(FsVideoResource::getTypeSubId, typeSubId)
+                .in(FsVideoResource::getId, idList.stream().map(Long::valueOf).collect(Collectors.toList()));
+
+        // 执行批量更新
+        fsVideoResourceService.update(updateWrapper);
+        return AjaxResult.success();
+    }
+
     @PreAuthorize("@ss.hasPermi('course:videoResource:batchAdd')")
     @Log(title = "视频素材库", businessType = BusinessType.INSERT)
     @PostMapping("/batchAddVideoResource")