Browse Source

bugfix:
1、内容管理-文件资源-上传资源时选择“分类”无效,默认为“广告”分类

lihao16 5 tháng trước cách đây
mục cha
commit
70b8237b22

+ 5 - 3
smsb-modules/smsb-source/src/main/java/com/inspur/source/controller/SmsbMinioDataController.java

@@ -116,15 +116,17 @@ public class SmsbMinioDataController extends BaseController {
             @RequestParam("totalChunks") Integer totalChunks,
             @RequestParam("fileSize") Long fileSize,
             @RequestParam("fileType") String fileType,
-            @RequestParam("uploadId") String uploadId
+            @RequestParam("uploadId") String uploadId,
+            @RequestParam("tag") Integer tag,
+            @RequestParam("sourceTreeIds") List<Long> sourceTreeIds
     ) {
         // 参数校验
         if (file == null || file.isEmpty()) {
             return R.fail("分片文件不能为空");
         }
         SmsbFileUploadMsgVo msg = smsbMinioDataService.handleUpload(file, uploadId, filename, chunkIndex, totalChunks,
-                                                                fileSize,
-                                                                fileType, tempDir, uploadDir);
+                                                                fileSize, fileType, tempDir, uploadDir,
+                                                                tag,sourceTreeIds);
 
         if (msg.getSuccess() != null && msg.getSuccess()) {
             return R.ok(msg);

+ 2 - 2
smsb-modules/smsb-source/src/main/java/com/inspur/source/service/ISmsbMinioDataService.java

@@ -73,8 +73,8 @@ public interface ISmsbMinioDataService {
      * @return 上传结果消息
      */
     SmsbFileUploadMsgVo handleUpload(MultipartFile file, String uploadId, String filename, int chunkIndex,
-                                            int totalChunks, long fileSize, String fileType, String tempDir,
-                                            String uploadDir);
+                                     int totalChunks, long fileSize, String fileType, String tempDir,
+                                     String uploadDir, Integer tag, List<Long> sourceTreeIds);
 
     /**
      * 校验并批量删除文件资源信息

+ 10 - 4
smsb-modules/smsb-source/src/main/java/com/inspur/source/service/impl/SmsbMinioDataServiceImpl.java

@@ -217,7 +217,7 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
         smsbMinioDataBo.setFileUrl(sysOssVo.getUrl());
         Integer boType = switch (fileExtension.toLowerCase()) {
             case ".jpg", ".jpeg", ".png" -> 1;
-            case ".mp4", ".mkv" -> 2;
+            case ".mp4", ".avi" -> 2;
             case ".mp3", ".wav" -> 3;
             default -> 3;
         };
@@ -329,6 +329,7 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
             SysOssVo sysOssVo = sysOssMapper.selectVoById(ossId);
             // 创建minioData
             SmsbMinioData minioData = createSaveMinioData(sysOssVo);
+            minioData.setTag(add.getTag());
             boolean flag = baseMapper.insert(minioData) > 0;
             if (flag) {
                 bo.setId(minioData.getId());
@@ -540,7 +541,7 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
      */
     public SmsbFileUploadMsgVo handleUpload(MultipartFile file, String uploadId, String filename, int chunkIndex,
                                             int totalChunks, long fileSize, String fileType, String tempDir,
-                                            String uploadDir) {
+                                            String uploadDir,Integer tag,List<Long> sourceTreeIds) {
         try {
             // Validate parameters (basic example)
             if (uploadId == null || uploadId.isEmpty() || chunkIndex < 0 || chunkIndex >= totalChunks) {
@@ -572,12 +573,17 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
                                                 filename);
                 if (sysOssVo != null) {
                     SmsbMinioDataBo smsbMinioDataBo = createSmsbMinioDataBo(filename, sysOssVo, fileExtension);
+                    smsbMinioDataBo.setTag(Long.valueOf(tag));
+                    smsbMinioDataBo.setSourceTreeIds(sourceTreeIds);
                     // 其他字段按你的业务补充
                     insertByBo(smsbMinioDataBo);
                 }
+                Map<String,String> rspData = new HashMap<>();
+                rspData.put("uploadId",uploadId);
+                rspData.put("fileUrl",sysOssVo.getUrl());
+                rspData.put("ossId",sysOssVo.getOssId().toString());
                 return new SmsbFileUploadMsgVo(Boolean.TRUE,
-                                               "File uploaded successfully",
-                                               Map.of("uploadId", uploadId, "fileUrl", sysOssVo.getUrl()));
+                                               "File uploaded successfully", rspData);
             }
         } catch (IOException e) {
             return new SmsbFileUploadMsgVo(Boolean.FALSE, "Upload failed", e.getMessage());

+ 2 - 1
smsb-modules/smsb-source/src/main/resources/mapper/SmsbMinioDataMapper.xml

@@ -44,7 +44,8 @@
         <if test="bo.tag != null and bo.tag != ''">
             AND md.tag = #{bo.tag}
         </if>
-        <if test="bo.params.beginCreateTime != '' and bo.params.endCreateTime != ''">
+        <if test="bo.params.beginCreateTime != '' and bo.params.beginCreateTime != null
+                  and bo.params.endCreateTime != '' and bo.params.endCreateTime != null">
             AND md.create_time between #{bo.params.beginCreateTime} and #{bo.params.endCreateTime}
         </if>
     </select>

+ 6 - 2
smsb-plus-ui/src/views/smsb/minioData/index.vue

@@ -158,7 +158,7 @@
       :style="{ maxWidth: '90vw', maxHeight: '90vh' }">
       <el-row :gutter="20" style="display: flex">
         <el-col :span="10" style="height: 100%; overflow: auto; border-right: 1px solid #eee; padding-right: 10px">
-          <el-tree ref="sourceTreeRef" :data="sourceTreeOptions" show-checkbox node-key="id"
+          <el-tree ref="sourceTreeRef" :data="sourceTreeOptions" :model="form.sourceTreeIds" show-checkbox node-key="id"
             :props="{ value: 'id', label: 'name', children: 'children' }" :check-strictly="true"
             :default-expand-all="true" @check="handleTreeCheck" style="height: 100%"></el-tree>
         </el-col>
@@ -457,6 +457,7 @@ const handleAdd = () => {
   reset();
   dialog.visible = true;
   dialog.title = '添加文件资源';
+  form.value.sourceTreeIds = null;
 };
 
 const handleTrans = () => {
@@ -492,7 +493,10 @@ const submitForm = () => {
       // 调用文件上传逻辑(不关闭dialog)
       console.log('[submitForm] 尝试调用handleUpload', fileUploaderRef.value);
       if (fileUploaderRef.value && typeof fileUploaderRef.value.handleUpload === 'function') {
-        await fileUploaderRef.value.handleUpload();
+        if (form.value.sourceTreeIds == undefined || form.value.sourceTreeIds == null) {
+          form.value.sourceTreeIds = [0];
+        }
+        await fileUploaderRef.value.handleUpload(form.value.tag,form.value.sourceTreeIds);
         console.log('[submitForm] handleUpload已调用');
       }
       // 下面的逻辑可以根据需要决定是否保留