소스 검색

代码生成新增配置是否允许文件覆盖到本地

RuoYi 1 년 전
부모
커밋
adaa3e1db8

+ 15 - 2
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/config/GenConfig.java

@@ -18,12 +18,15 @@ public class GenConfig
18 18
     /** 生成包路径 */
19 19
     public static String packageName;
20 20
 
21
-    /** 自动去除表前缀,默认是false */
21
+    /** 自动去除表前缀 */
22 22
     public static boolean autoRemovePre;
23 23
 
24
-    /** 表前缀(类名不会包含表前缀) */
24
+    /** 表前缀 */
25 25
     public static String tablePrefix;
26 26
 
27
+    /** 是否允许生成文件覆盖到本地(自定义路径) */
28
+    public static boolean allowOverwrite;
29
+
27 30
     public static String getAuthor()
28 31
     {
29 32
         return author;
@@ -63,4 +66,14 @@ public class GenConfig
63 66
     {
64 67
         GenConfig.tablePrefix = tablePrefix;
65 68
     }
69
+
70
+    public static boolean isAllowOverwrite()
71
+    {
72
+        return allowOverwrite;
73
+    }
74
+
75
+    public void setAllowOverwrite(boolean allowOverwrite)
76
+    {
77
+        GenConfig.allowOverwrite = allowOverwrite;
78
+    }
66 79
 }

+ 5 - 0
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/controller/GenController.java

@@ -23,6 +23,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
23 23
 import com.ruoyi.common.log.annotation.Log;
24 24
 import com.ruoyi.common.log.enums.BusinessType;
25 25
 import com.ruoyi.common.security.annotation.RequiresPermissions;
26
+import com.ruoyi.gen.config.GenConfig;
26 27
 import com.ruoyi.gen.domain.GenTable;
27 28
 import com.ruoyi.gen.domain.GenTableColumn;
28 29
 import com.ruoyi.gen.service.IGenTableColumnService;
@@ -168,6 +169,10 @@ public class GenController extends BaseController
168 169
     @GetMapping("/genCode/{tableName}")
169 170
     public AjaxResult genCode(@PathVariable("tableName") String tableName)
170 171
     {
172
+        if (!GenConfig.isAllowOverwrite())
173
+        {
174
+            return AjaxResult.error("【系统预设】不允许生成文件覆盖到本地");
175
+        }
171 176
         genTableService.generatorCode(tableName);
172 177
         return success();
173 178
     }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
sql/ry_config_20240902.sql