lyhzzz 5 달 전
부모
커밋
645f341236

+ 3 - 1
src/main/java/com/fdkankan/manage/constant/FileTypeEnum.java

@@ -10,10 +10,12 @@ public enum FileTypeEnum {
     IMAGE(0,"图片", Arrays.asList("jpg","png","jpeg")),
     VIDEO(1,"视频",Arrays.asList("mp4")),
     MUSIC(2,"音频",Arrays.asList("wav","mp3")),
-    MODEL(3,"模型",Arrays.asList("obj","osgb","b3dm","ply","las","laz")),
+    MODEL(3,"模型",Arrays.asList("obj","osgb","b3dm","ply","las","laz","glb")),
     OTHER(4,"其他",Arrays.asList("shp")),
     DOC(5,"文档",Arrays.asList("doc","docx","pdf")),
 
+    //AC_MODEL(7,"动画模型",Arrays.asList("obj","glb")),
+
     ;
     int code;
     String msg;

+ 52 - 0
src/main/java/com/fdkankan/manage/controller/JyUserFileController.java

@@ -0,0 +1,52 @@
+package com.fdkankan.manage.controller;
+
+
+import com.fdkankan.manage.common.ResultCode;
+import com.fdkankan.manage.common.ResultData;
+import com.fdkankan.manage.entity.JyUserFile;
+import com.fdkankan.manage.exception.BusinessException;
+import com.fdkankan.manage.service.IJyUserFileService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2025-04-10
+ */
+@RestController
+@RequestMapping("/service/manage/userFile")
+public class JyUserFileController {
+
+
+    @Autowired
+    IJyUserFileService jyUserFileService;
+
+    @GetMapping("/info")
+    public ResultData info(@RequestParam(required = false,defaultValue = "0")Integer imgType){
+
+        return ResultData.ok(jyUserFileService.getByType(imgType));
+    }
+
+
+    @PostMapping("/addOrUpdate")
+    public ResultData addOrUpdate(@RequestBody JyUserFile jyUserFile){
+        if(StringUtils.isBlank(jyUserFile.getFileUrl()) || jyUserFile.getImgType() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if(jyUserFile.getId() == null){
+            List<JyUserFile> byType = jyUserFileService.getByType(jyUserFile.getImgType());
+            if(byType != null && !byType.isEmpty()){
+                jyUserFile.setId(byType.get(0).getId());
+            }
+        }
+        return ResultData.ok(jyUserFileService.saveOrUpdate(jyUserFile));
+    }
+}
+

+ 57 - 0
src/main/java/com/fdkankan/manage/entity/JyUserFile.java

@@ -0,0 +1,57 @@
+package com.fdkankan.manage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2025-04-10
+ */
+@Getter
+@Setter
+@TableName("jy_user_file")
+public class JyUserFile implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @TableField("sys_user_id")
+    private Integer sysUserId;
+
+    @TableField("file_url")
+    private String fileUrl;
+
+    @TableField("file_title")
+    private String fileTitle;
+
+    @TableField("img_type")
+    private Integer imgType;
+
+    @TableField("content")
+    private String content;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/manage/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"manage", getTables(new String[]{
-                "t_scene_build_process_log","t_build_log"
+                "jy_user_file"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/manage/mapper/IJyUserFileMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.manage.mapper;
+
+import com.fdkankan.manage.entity.JyUserFile;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2025-04-10
+ */
+@Mapper
+public interface IJyUserFileMapper extends BaseMapper<JyUserFile> {
+
+}

+ 19 - 0
src/main/java/com/fdkankan/manage/service/IJyUserFileService.java

@@ -0,0 +1,19 @@
+package com.fdkankan.manage.service;
+
+import com.fdkankan.manage.entity.JyUserFile;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2025-04-10
+ */
+public interface IJyUserFileService extends IService<JyUserFile> {
+
+    List<JyUserFile> getByType(Integer imgType);
+}

+ 35 - 5
src/main/java/com/fdkankan/manage/service/impl/CommonServiceImpl.java

@@ -13,6 +13,7 @@ import com.fdkankan.common.util.DateExtUtil;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.manage.constant.FileTypeEnum;
 import com.fdkankan.manage.entity.CommonUpload;
+import com.fdkankan.manage.entity.Dict;
 import com.fdkankan.manage.entity.DictFile;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.service.ICommonService;
@@ -22,6 +23,7 @@ import java.util.*;
 
 import com.fdkankan.manage.service.ICommonUploadService;
 import com.fdkankan.manage.service.IDictFileService;
+import com.fdkankan.manage.service.IDictService;
 import com.fdkankan.manage.util.FileWriterUtil;
 import com.fdkankan.manage.util.OBJToGLBUtil;
 import com.fdkankan.manage.util.ShellUtil;
@@ -85,6 +87,8 @@ public class CommonServiceImpl implements ICommonService {
     ICommonUploadService commonUploadService;
     @Autowired
     IDictFileService dictFileService;
+    @Autowired
+    IDictService dictService;
 
     @Override
     public ResultData uploadFileNew(MultipartFile file,Integer dictId) {
@@ -96,6 +100,18 @@ public class CommonServiceImpl implements ICommonService {
             String uuid = UUID.randomUUID().toString().replace("-","");
             String originalFilename = file.getOriginalFilename();
             String extName = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
+
+            if(dictId != null){
+                Dict dict = dictService.getById(dictId);
+                if(dict == null ){
+                    throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+                }
+                if("animation".equals(dict.getUseType()) && !(extName.equalsIgnoreCase(".zip") || extName.equalsIgnoreCase(".glb"))){
+                    throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
+                }
+
+            }
+
             String ossPath = String.format(OssPath.MANAGE_MODEL_FILE_PATH, uuid + extName);
 
             tempFile = new File(OssPath.localPath + ossPath);
@@ -141,6 +157,23 @@ public class CommonServiceImpl implements ICommonService {
             throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
         }
         File modelFile = fileList.get(0);
+        String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
+
+        FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
+        if(fileTypeEnum == null){
+            throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
+        }
+
+        if(dictId != null){
+            Dict dict = dictService.getById(dictId);
+            if(dict == null ){
+                throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+            }
+            if("animation".equals(dict.getUseType()) && !(modelFileFormat.equals("glb") || modelFileFormat.equals("obj"))){
+                throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
+            }
+
+        }
 
         if(FileWriterUtil.isChinese(modelFile.getName())){
             throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
@@ -148,12 +181,12 @@ public class CommonServiceImpl implements ICommonService {
         if(FileWriterUtil.isChinese(modelFile.getPath())){
             throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
         }
-        String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
         String url = null;
         String resultFormat = modelFileFormat;
         switch (modelFileFormat){
             case "obj" :  resultFormat = "glb";
                           url = uploadObjOss(unzipPath,modelFile);break;
+            case "glb" :   url = uploadOss(unzipPath,modelFile);break;
             case "laz" :    url = uploadLazOss(unzipPath,modelFile); break;
             case "shp" :   url = uploadOss(unzipPath,modelFile); break;
             case "b3dm" :  url = uploadB3dm(unzipPath,modelFile); break;
@@ -163,10 +196,7 @@ public class CommonServiceImpl implements ICommonService {
                            uploadOsgb(unzipPath,modelFile) ;break;
             default: break;
         }
-        FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
-        if(fileTypeEnum == null){
-            throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
-        }
+
         Integer status = StringUtils.isNotBlank(url) ?1:-1;
         CommonUpload commonUpload = commonUploadService.add(oldName,url, String.valueOf(tempFile.length()),
                 null, fileTypeEnum, modelFileFormat,resultFormat,status,unzipPath,dictId);

+ 32 - 0
src/main/java/com/fdkankan/manage/service/impl/JyUserFileServiceImpl.java

@@ -0,0 +1,32 @@
+package com.fdkankan.manage.service.impl;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.manage.entity.JyUserFile;
+import com.fdkankan.manage.mapper.IJyUserFileMapper;
+import com.fdkankan.manage.service.IJyUserFileService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2025-04-10
+ */
+@Service
+public class JyUserFileServiceImpl extends ServiceImpl<IJyUserFileMapper, JyUserFile> implements IJyUserFileService {
+
+
+    @Override
+    public List<JyUserFile> getByType(Integer imgType) {
+        LambdaQueryWrapper<JyUserFile> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(JyUserFile::getSysUserId,StpUtil.getLoginId());
+        wrapper.eq(JyUserFile::getImgType,imgType);
+        return this.list(wrapper);
+    }
+}

+ 5 - 0
src/main/resources/mapper/manage/JyUserFileMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.manage.mapper.IJyUserFileMapper">
+
+</mapper>