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