mirror of https://gitee.com/y_project/RuoYi-Vue
代码生成新增配置是否允许文件覆盖到本地
This commit is contained in:
parent
3b2704c181
commit
9a51563144
|
@ -21,12 +21,15 @@ public class GenConfig
|
|||
/** 生成包路径 */
|
||||
public static String packageName;
|
||||
|
||||
/** 自动去除表前缀,默认是false */
|
||||
/** 自动去除表前缀 */
|
||||
public static boolean autoRemovePre;
|
||||
|
||||
/** 表前缀(类名不会包含表前缀) */
|
||||
/** 表前缀 */
|
||||
public static String tablePrefix;
|
||||
|
||||
/** 是否允许生成文件覆盖到本地(自定义路径) */
|
||||
public static boolean allowOverwrite;
|
||||
|
||||
public static String getAuthor()
|
||||
{
|
||||
return author;
|
||||
|
@ -70,4 +73,15 @@ public class GenConfig
|
|||
{
|
||||
GenConfig.tablePrefix = tablePrefix;
|
||||
}
|
||||
|
||||
public static boolean isAllowOverwrite()
|
||||
{
|
||||
return allowOverwrite;
|
||||
}
|
||||
|
||||
@Value("${allowOverwrite}")
|
||||
public void setAllowOverwrite(boolean allowOverwrite)
|
||||
{
|
||||
GenConfig.allowOverwrite = allowOverwrite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.ruoyi.common.core.text.Convert;
|
|||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||
import com.ruoyi.generator.config.GenConfig;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import com.ruoyi.generator.service.IGenTableColumnService;
|
||||
|
@ -213,6 +214,10 @@ public class GenController extends BaseController
|
|||
@GetMapping("/genCode/{tableName}")
|
||||
public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
||||
{
|
||||
if (!GenConfig.isAllowOverwrite())
|
||||
{
|
||||
return AjaxResult.error("【系统预设】不允许生成文件覆盖到本地");
|
||||
}
|
||||
genTableService.generatorCode(tableName);
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -8,3 +8,5 @@ gen:
|
|||
autoRemovePre: false
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
# 是否允许生成文件覆盖到本地(自定义路径),默认不允许
|
||||
allowOverwrite: false
|
Loading…
Reference in New Issue