Browse Source

1.资源上传时过滤.json材质描述文件

hellohaidie 5 months ago
parent
commit
01a3c7ab96

+ 3 - 5
src/main/java/com/lqkj/link/module/zone/service/ResourceService.java

@@ -1,19 +1,17 @@
1
 package com.lqkj.link.module.zone.service;
1
 package com.lqkj.link.module.zone.service;
2
 
2
 
3
 import com.lqkj.link.module.authority.repository.UserInfoRepository;
3
 import com.lqkj.link.module.authority.repository.UserInfoRepository;
4
-import com.lqkj.link.module.config.domain.ConfigInfo;
5
-import com.lqkj.link.module.config.repository.ConfigInfoRepository;
6
 import com.lqkj.link.module.zone.domain.ModelCategory;
4
 import com.lqkj.link.module.zone.domain.ModelCategory;
7
 import com.lqkj.link.module.zone.domain.ModelInfo;
5
 import com.lqkj.link.module.zone.domain.ModelInfo;
8
 import com.lqkj.link.module.zone.repository.ModelCategoryRepository;
6
 import com.lqkj.link.module.zone.repository.ModelCategoryRepository;
9
 import com.lqkj.link.module.zone.repository.ModelInfoRepository;
7
 import com.lqkj.link.module.zone.repository.ModelInfoRepository;
10
 import com.lqkj.link.util.Unzipper;
8
 import com.lqkj.link.util.Unzipper;
11
-import org.springframework.transaction.annotation.Transactional;
12
 import org.apache.commons.compress.archivers.ArchiveException;
9
 import org.apache.commons.compress.archivers.ArchiveException;
13
 import org.springframework.data.domain.Page;
10
 import org.springframework.data.domain.Page;
14
 import org.springframework.data.domain.PageRequest;
11
 import org.springframework.data.domain.PageRequest;
15
 import org.springframework.data.domain.Pageable;
12
 import org.springframework.data.domain.Pageable;
16
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
17
 
15
 
18
 import java.io.File;
16
 import java.io.File;
19
 import java.io.IOException;
17
 import java.io.IOException;
@@ -74,10 +72,10 @@ public class ResourceService {
74
                 File[] models = modelFolder.listFiles();
72
                 File[] models = modelFolder.listFiles();
75
                 assert models != null;
73
                 assert models != null;
76
                 for (File model : models) {
74
                 for (File model : models) {
77
-                    if (model.isFile()) {
75
+                    if (model.isFile() && model.getName().endsWith(".fbx")) {
78
                         String modelFileName = model.getName();
76
                         String modelFileName = model.getName();
79
                         String modelPath = "/upload/resource/" + category.getCategoryId() + "/model/";
77
                         String modelPath = "/upload/resource/" + category.getCategoryId() + "/model/";
80
-                        if (modelFileName.matches(".*[\u4e00-\u9fa5]+.*")) {
78
+                        if (modelFileName.matches(".*[一-龥]+.*")) {
81
                             // 如果包含中文,重命名
79
                             // 如果包含中文,重命名
82
                             String newFileName = UUID.randomUUID() + ".fbx";
80
                             String newFileName = UUID.randomUUID() + ".fbx";
83
                             modelPath += newFileName;
81
                             modelPath += newFileName;