Browse Source

修改审核管理bug,调整材质管理

liaoyitao 2 months ago
parent
commit
668532112e

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
10
     </parent>
10
     </parent>
11
     <groupId>com.lqkj</groupId>
11
     <groupId>com.lqkj</groupId>
12
     <artifactId>link</artifactId>
12
     <artifactId>link</artifactId>
13
-    <version>2.0.0</version>
13
+    <version>1.1.0</version>
14
     <name>LINK-SERVER</name>
14
     <name>LINK-SERVER</name>
15
     <description>LINK-SERVER</description>
15
     <description>LINK-SERVER</description>
16
     <properties>
16
     <properties>

+ 2 - 2
src/main/java/com/lqkj/link/module/audit/controller/AuditRecordController.java

@@ -61,8 +61,8 @@ public class AuditRecordController {
61
     )
61
     )
62
     @PostMapping("/manage/delete")
62
     @PostMapping("/manage/delete")
63
     public MessageBean delete(@RequestParam List<Integer> recordIds) {
63
     public MessageBean delete(@RequestParam List<Integer> recordIds) {
64
-        auditRecordService.delete(recordIds);
65
-        return MessageBean.ok(null, "审核记录删除接口");
64
+        String delete = auditRecordService.delete(recordIds);
65
+        return MessageBean.ok(null, delete);
66
     }
66
     }
67
 
67
 
68
     @Operation(
68
     @Operation(

+ 21 - 1
src/main/java/com/lqkj/link/module/audit/service/AuditRecordService.java

@@ -16,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
16
 import java.util.Date;
16
 import java.util.Date;
17
 import java.util.List;
17
 import java.util.List;
18
 import java.util.Map;
18
 import java.util.Map;
19
+import java.util.concurrent.atomic.AtomicBoolean;
20
+import java.util.concurrent.atomic.AtomicReference;
19
 
21
 
20
 @Service
22
 @Service
21
 public class AuditRecordService {
23
 public class AuditRecordService {
@@ -37,8 +39,26 @@ public class AuditRecordService {
37
     }
39
     }
38
 
40
 
39
     @Transactional
41
     @Transactional
40
-    public void delete(List<Integer> recordIds) {
42
+    public String delete(List<Integer> recordIds) {
43
+        List<AuditRecord> allById = auditRecordRepository.findAllById(recordIds);
44
+        AtomicBoolean status = new AtomicBoolean(false);
45
+        StringBuffer zoneName = new StringBuffer();
46
+        allById.forEach(auditRecord -> {
47
+            Integer zoneId = auditRecord.getZoneId();
48
+            ZoneInfo zoneInfo = zoneInfoRepository.findById(zoneId).get();
49
+            if (zoneInfo.getAuthStatus() == 1) {
50
+               status.set(true);
51
+               recordIds.remove(auditRecord.getRecordId());
52
+               zoneName.append(zoneInfo.getZoneName());
53
+               zoneName.append(",");
54
+            }
55
+
56
+        });
41
         auditRecordRepository.batchDelete(recordIds);
57
         auditRecordRepository.batchDelete(recordIds);
58
+        if (!status.get()){
59
+            return "删除成功!";
60
+        }
61
+        return "作品" + zoneName + "正处于审核中,删除失败!";
42
     }
62
     }
43
 
63
 
44
     @Transactional
64
     @Transactional

+ 1 - 1
src/main/java/com/lqkj/link/module/authority/service/DatabaseUserDetailService.java

@@ -87,7 +87,7 @@ public class DatabaseUserDetailService implements UserDetailsService {
87
                 return "账号已被冻结,请稍后重试";
87
                 return "账号已被冻结,请稍后重试";
88
             }
88
             }
89
             userInfoRepository.save(userInfo);
89
             userInfoRepository.save(userInfo);
90
-            return "账号、密码或授权码输入错误," + (4 - loginErrorCount) +"次错误后,账号将会冻结1小时";
90
+            return "账号或密码输入错误," + (4 - loginErrorCount) +"次错误后,账号将会冻结1小时";
91
         }
91
         }
92
     }
92
     }
93
 
93
 

+ 8 - 1
src/main/java/com/lqkj/link/module/zone/domain/MaterialInfo.java

@@ -1,12 +1,16 @@
1
 package com.lqkj.link.module.zone.domain;
1
 package com.lqkj.link.module.zone.domain;
2
 
2
 
3
+import com.alibaba.fastjson2.JSONObject;
3
 import com.fasterxml.jackson.annotation.JsonFormat;
4
 import com.fasterxml.jackson.annotation.JsonFormat;
5
+import com.fasterxml.jackson.annotation.JsonIgnore;
6
+import io.hypersistence.utils.hibernate.type.json.JsonType;
4
 import io.swagger.v3.oas.annotations.media.Schema;
7
 import io.swagger.v3.oas.annotations.media.Schema;
5
 import jakarta.persistence.*;
8
 import jakarta.persistence.*;
6
 import lombok.AllArgsConstructor;
9
 import lombok.AllArgsConstructor;
7
 import lombok.Getter;
10
 import lombok.Getter;
8
 import lombok.NoArgsConstructor;
11
 import lombok.NoArgsConstructor;
9
 import lombok.Setter;
12
 import lombok.Setter;
13
+import org.hibernate.annotations.Type;
10
 
14
 
11
 import java.util.Date;
15
 import java.util.Date;
12
 
16
 
@@ -60,8 +64,11 @@ public class MaterialInfo {
60
     @Transient
64
     @Transient
61
     private String name;
65
     private String name;
62
 
66
 
67
+    @Type(JsonType.class)
68
+    @Column(name = "json_value", columnDefinition = "jsonb")
69
+    private JSONObject jsonValue;
70
+
63
     public String getName() {
71
     public String getName() {
64
         return materialId.toString();
72
         return materialId.toString();
65
     }
73
     }
66
-
67
 }
74
 }

+ 50 - 53
src/main/java/com/lqkj/link/module/zone/service/impl/MaterialInfoServiceImpl.java

@@ -30,9 +30,6 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
30
     @Transactional
30
     @Transactional
31
     @Override
31
     @Override
32
     public void sava(MaterialInfo materialInfo) {
32
     public void sava(MaterialInfo materialInfo) {
33
-        if (materialInfo.getCompressFileName() != null) {
34
-            materialInfo.setMaterialName(StringUtils.split(materialInfo.getCompressFileName(), ".")[0]);
35
-        }
36
         if ((Objects.nonNull(materialInfo.getMaterialId()) && materialInfoRepository.hasSameNameWithoutOne(materialInfo.getMaterialId(), materialInfo.getMaterialName()))
33
         if ((Objects.nonNull(materialInfo.getMaterialId()) && materialInfoRepository.hasSameNameWithoutOne(materialInfo.getMaterialId(), materialInfo.getMaterialName()))
37
             || (Objects.isNull(materialInfo.getMaterialId()) && materialInfoRepository.hasSameName(materialInfo.getMaterialName()))) {
34
             || (Objects.isNull(materialInfo.getMaterialId()) && materialInfoRepository.hasSameName(materialInfo.getMaterialName()))) {
38
             throw new RuntimeException("材质名称不能重复!");
35
             throw new RuntimeException("材质名称不能重复!");
@@ -61,56 +58,56 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
61
     @Override
58
     @Override
62
     public void batchAdd(String compressFilePath) {
59
     public void batchAdd(String compressFilePath) {
63
 
60
 
64
-        try {
65
-            String unzipPath = "./upload/resource/material" + RandomUtil.randomNumbers(5) + "/";
66
-            Unzipper.unZipFiles(new File("." + compressFilePath), unzipPath);
67
-            Map<String, MaterialInfo> materialMap = materialInfoRepository.findAll().stream().collect(Collectors.toMap(MaterialInfo::getMaterialName, materialInfo -> materialInfo));
68
-
69
-            String modelFolderPath = unzipPath + "model";
70
-            File materialModelDir = new File(modelFolderPath);
71
-            if (materialModelDir.isDirectory()){
72
-                List<MaterialInfo> materialInfoList = new ArrayList<>();
73
-                File[] jsonFiles = materialModelDir.listFiles();
74
-                assert jsonFiles != null;
75
-                for (File jsonFile : jsonFiles) {
76
-                    if (jsonFile.isFile() && jsonFile.getName().endsWith(".json")) {
77
-                        String modelFileName = jsonFile.getName();
78
-                        String modelPath = unzipPath + "model/";
79
-                        if (modelFileName.matches(".*[一-龥]+.*")) {
80
-                            // 如果包含中文,重命名
81
-                            String newFileName = UUID.randomUUID() + ".json";
82
-                            modelPath += newFileName;
83
-                            boolean rename = jsonFile.renameTo(new File(modelPath));
84
-                            System.out.println(rename);
85
-                            // 材质图标也要重命名
86
-                            File oldIconFile = new File(unzipPath + "icon/" + modelFileName.replace(".json", ".png"));
87
-                            if (oldIconFile.exists()) {
88
-                                File newIconFile = new File(unzipPath + "icon/" + newFileName.replace(".json", ".png"));
89
-                                rename = oldIconFile.renameTo(newIconFile);
90
-                                System.out.println(rename);
91
-                            }
92
-                        } else {
93
-                            modelPath += modelFileName;
94
-                        }
95
-                        if (!materialMap.containsKey(modelFileName.substring(0, modelFileName.lastIndexOf(".")))) {
96
-                            materialInfoList.add(new MaterialInfo(null, modelFileName.substring(0, modelFileName.lastIndexOf(".")), modelPath.substring(1),
97
-                                    modelPath.replace("model", "icon").replace("json", "png").substring(1), modelFileName, 1, new Date(), null, null));
98
-                        } else {
99
-                            MaterialInfo materialInfo = materialMap.get(modelFileName.substring(0, modelFileName.lastIndexOf(".")));
100
-                            materialInfo.setMaterialIcon(modelPath.replace("model", "icon").replace("json", "png").substring(1));
101
-                            materialInfo.setCompressFileName(modelFileName.substring(1));
102
-                            materialInfo.setJsonPath(modelPath);
103
-                            materialInfo.setUpdateTime(new Date());
104
-                            materialInfoList.add(materialInfo);
105
-                        }
106
-                    }
107
-                }
108
-                materialInfoRepository.saveAll(materialInfoList);
109
-            }
110
-            userInfoRepository.updateRefreshStatus();
111
-        } catch (IOException e) {
112
-            throw new RuntimeException(e);
113
-        }
61
+//        try {
62
+//            String unzipPath = "./upload/resource/material" + RandomUtil.randomNumbers(5) + "/";
63
+//            Unzipper.unZipFiles(new File("." + compressFilePath), unzipPath);
64
+//            Map<String, MaterialInfo> materialMap = materialInfoRepository.findAll().stream().collect(Collectors.toMap(MaterialInfo::getMaterialName, materialInfo -> materialInfo));
65
+//
66
+//            String modelFolderPath = unzipPath + "model";
67
+//            File materialModelDir = new File(modelFolderPath);
68
+//            if (materialModelDir.isDirectory()){
69
+//                List<MaterialInfo> materialInfoList = new ArrayList<>();
70
+//                File[] jsonFiles = materialModelDir.listFiles();
71
+//                assert jsonFiles != null;
72
+//                for (File jsonFile : jsonFiles) {
73
+//                    if (jsonFile.isFile() && jsonFile.getName().endsWith(".json")) {
74
+//                        String modelFileName = jsonFile.getName();
75
+//                        String modelPath = unzipPath + "model/";
76
+//                        if (modelFileName.matches(".*[一-龥]+.*")) {
77
+//                            // 如果包含中文,重命名
78
+//                            String newFileName = UUID.randomUUID() + ".json";
79
+//                            modelPath += newFileName;
80
+//                            boolean rename = jsonFile.renameTo(new File(modelPath));
81
+//                            System.out.println(rename);
82
+//                            // 材质图标也要重命名
83
+//                            File oldIconFile = new File(unzipPath + "icon/" + modelFileName.replace(".json", ".png"));
84
+//                            if (oldIconFile.exists()) {
85
+//                                File newIconFile = new File(unzipPath + "icon/" + newFileName.replace(".json", ".png"));
86
+//                                rename = oldIconFile.renameTo(newIconFile);
87
+//                                System.out.println(rename);
88
+//                            }
89
+//                        } else {
90
+//                            modelPath += modelFileName;
91
+//                        }
92
+//                        if (!materialMap.containsKey(modelFileName.substring(0, modelFileName.lastIndexOf(".")))) {
93
+//                            materialInfoList.add(new MaterialInfo(null, modelFileName.substring(0, modelFileName.lastIndexOf(".")), modelPath.substring(1),
94
+//                                    modelPath.replace("model", "icon").replace("json", "png").substring(1), modelFileName, 1, new Date(), null, null, ));
95
+//                        } else {
96
+//                            MaterialInfo materialInfo = materialMap.get(modelFileName.substring(0, modelFileName.lastIndexOf(".")));
97
+//                            materialInfo.setMaterialIcon(modelPath.replace("model", "icon").replace("json", "png").substring(1));
98
+//                            materialInfo.setCompressFileName(modelFileName.substring(1));
99
+//                            materialInfo.setJsonPath(modelPath);
100
+//                            materialInfo.setUpdateTime(new Date());
101
+//                            materialInfoList.add(materialInfo);
102
+//                        }
103
+//                    }
104
+//                }
105
+//                materialInfoRepository.saveAll(materialInfoList);
106
+//            }
107
+//            userInfoRepository.updateRefreshStatus();
108
+//        } catch (IOException e) {
109
+//            throw new RuntimeException(e);
110
+//        }
114
     }
111
     }
115
 
112
 
116
     @Override
113
     @Override

+ 4 - 0
src/main/resources/db/migration/V12__2.0.7.sql

@@ -0,0 +1,4 @@
1
+ALTER TABLE material_info
2
+    add COLUMN if not exists json_value jsonb;
3
+comment on column material_info.json_value is 'json文件内容';
4
+