Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pig_冷冷
Pig
提交
850ef630
Pig
项目概览
pig_冷冷
/
Pig
上一次同步 12 个月
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Pig
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
850ef630
编写于
7月 31, 2021
作者:
L
lbw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎨
Improving structure / format of the code.
上级
1aa9e1d4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
20 deletion
+27
-20
pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java
...n/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java
+27
-20
未找到文件。
pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java
浏览文件 @
850ef630
...
...
@@ -86,7 +86,6 @@ public class CodeGenKits {
/**
* 配置
*
* @param config
* @return
*/
...
...
@@ -104,7 +103,8 @@ public class CodeGenKits {
if
(
StyleTypeEnum
.
AVUE
.
getStyle
().
equals
(
config
.
getStyle
()))
{
templates
.
add
(
"template/avue/index.vue.vm"
);
templates
.
add
(
"template/avue/crud.js.vm"
);
}
else
{
}
else
{
templates
.
add
(
"template/element/index.vue.vm"
);
templates
.
add
(
"template/element/form.vue.vm"
);
}
...
...
@@ -114,12 +114,11 @@ public class CodeGenKits {
/**
* 生成代码
*
* @return
*/
@SneakyThrows
public
Map
<
String
,
String
>
generatorCode
(
GenConfig
genConfig
,
Map
<
String
,
String
>
table
,
List
<
Map
<
String
,
String
>>
columns
,
ZipOutputStream
zip
,
GenFormConf
formConf
)
{
List
<
Map
<
String
,
String
>>
columns
,
ZipOutputStream
zip
,
GenFormConf
formConf
)
{
// 配置信息
Configuration
config
=
getConfig
();
boolean
hasBigDecimal
=
false
;
...
...
@@ -129,14 +128,16 @@ public class CodeGenKits {
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getComments
()))
{
tableEntity
.
setComments
(
genConfig
.
getComments
());
}
else
{
}
else
{
tableEntity
.
setComments
(
table
.
get
(
"tableComment"
));
}
String
tablePrefix
;
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getTablePrefix
()))
{
tablePrefix
=
genConfig
.
getTablePrefix
();
}
else
{
}
else
{
tablePrefix
=
config
.
getString
(
"tablePrefix"
);
}
...
...
@@ -158,7 +159,8 @@ public class CodeGenKits {
// 隐藏不需要的在接口文档中展示的字段
if
(
hiddenColumns
.
contains
(
column
.
get
(
"columnName"
)))
{
columnEntity
.
setHidden
(
Boolean
.
TRUE
);
}
else
{
}
else
{
columnEntity
.
setHidden
(
Boolean
.
FALSE
);
}
// 列名转换成Java属性名
...
...
@@ -170,7 +172,8 @@ public class CodeGenKits {
if
(
StrUtil
.
isNotBlank
(
column
.
get
(
"comments"
)))
{
// 注意去除换行符号
columnEntity
.
setComments
(
StrUtil
.
removeAllLineBreaks
(
column
.
get
(
"comments"
)));
}
else
{
}
else
{
columnEntity
.
setComments
(
columnEntity
.
getLowerAttrName
());
}
...
...
@@ -208,26 +211,30 @@ public class CodeGenKits {
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getComments
()))
{
map
.
put
(
"comments"
,
genConfig
.
getComments
());
}
else
{
}
else
{
map
.
put
(
"comments"
,
tableEntity
.
getComments
());
}
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getAuthor
()))
{
map
.
put
(
"author"
,
genConfig
.
getAuthor
());
}
else
{
}
else
{
map
.
put
(
"author"
,
config
.
getString
(
"author"
));
}
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getModuleName
()))
{
map
.
put
(
"moduleName"
,
genConfig
.
getModuleName
());
}
else
{
}
else
{
map
.
put
(
"moduleName"
,
config
.
getString
(
"moduleName"
));
}
if
(
StrUtil
.
isNotBlank
(
genConfig
.
getPackageName
()))
{
map
.
put
(
"package"
,
genConfig
.
getPackageName
());
map
.
put
(
"mainPath"
,
genConfig
.
getPackageName
());
}
else
{
}
else
{
map
.
put
(
"package"
,
config
.
getString
(
"package"
));
map
.
put
(
"mainPath"
,
config
.
getString
(
"mainPath"
));
}
...
...
@@ -238,17 +245,16 @@ public class CodeGenKits {
/**
* 渲染数据
*
* @param genConfig 配置信息
* @param zip 流 (为空,直接返回Map)
* @param formConf 表单信息
* @param genConfig 配置信息
* @param zip 流 (为空,直接返回Map)
* @param formConf 表单信息
* @param tableEntity 表基本信息
* @param map
模板参数
* @param map 模板参数
* @return map key-filename value-contents
* @throws IOException
*/
private
Map
<
String
,
String
>
renderData
(
GenConfig
genConfig
,
ZipOutputStream
zip
,
GenFormConf
formConf
,
TableEntity
tableEntity
,
Map
<
String
,
Object
>
map
)
throws
IOException
{
TableEntity
tableEntity
,
Map
<
String
,
Object
>
map
)
throws
IOException
{
// 设置velocity资源加载器
Properties
prop
=
new
Properties
();
prop
.
put
(
"file.resource.loader.class"
,
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"
);
...
...
@@ -302,7 +308,7 @@ public class CodeGenKits {
* 列名转换成Java属性名
*/
public
String
columnToJava
(
String
columnName
)
{
return
WordUtils
.
capitalizeFully
(
columnName
,
new
char
[]
{
'_'
}).
replace
(
"_"
,
""
);
return
WordUtils
.
capitalizeFully
(
columnName
,
new
char
[]
{
'_'
}).
replace
(
"_"
,
""
);
}
/**
...
...
@@ -321,7 +327,8 @@ public class CodeGenKits {
public
Configuration
getConfig
()
{
try
{
return
new
PropertiesConfiguration
(
"generator.properties"
);
}
catch
(
ConfigurationException
e
)
{
}
catch
(
ConfigurationException
e
)
{
throw
new
CheckedException
(
"获取配置文件失败,"
,
e
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录