Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
7bd44234
Commit
7bd44234
authored
Jun 11, 2019
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复代码生成的一处bug
parent
cbd69429
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
guns-vip-gen/src/main/java/cn/stylefeng/guns/generator/core/engine/GunsMpVelocityTemplateEngine.java
+2
-1
guns-vip-gen/src/main/java/cn/stylefeng/guns/generator/core/util/FieldUtil.java
+10
-3
guns-vip-gen/src/main/resources/mpTemplates/mapper.xml.vm
+9
-9
No files found.
guns-vip-gen/src/main/java/cn/stylefeng/guns/generator/core/engine/GunsMpVelocityTemplateEngine.java
View file @
7bd44234
...
@@ -104,8 +104,9 @@ public class GunsMpVelocityTemplateEngine extends VelocityTemplateEngine {
...
@@ -104,8 +104,9 @@ public class GunsMpVelocityTemplateEngine extends VelocityTemplateEngine {
if
(
customMap
!=
null
&&
customMap
.
containsKey
(
tableInfo
.
getName
()))
{
if
(
customMap
!=
null
&&
customMap
.
containsKey
(
tableInfo
.
getName
()))
{
//将字段转化成驼峰式的属性
//将字段转化成驼峰式的属性
List
<
String
>
camelFields
=
FieldUtil
.
getCamelFields
(
customMap
.
get
(
tableInfo
.
getName
()),
tableInfo
.
getFields
());
List
<
Map
<
String
,
Object
>>
camelFields
=
FieldUtil
.
getCamelFieldsUnderLine
(
customMap
.
get
(
tableInfo
.
getName
()),
tableInfo
.
getFields
());
objectMap
.
put
(
"mapperConditions"
,
camelFields
);
objectMap
.
put
(
"mapperConditions"
,
camelFields
);
}
}
return
objectMap
;
return
objectMap
;
...
...
guns-vip-gen/src/main/java/cn/stylefeng/guns/generator/core/util/FieldUtil.java
View file @
7bd44234
...
@@ -3,7 +3,9 @@ package cn.stylefeng.guns.generator.core.util;
...
@@ -3,7 +3,9 @@ package cn.stylefeng.guns.generator.core.util;
import
com.baomidou.mybatisplus.generator.config.po.TableField
;
import
com.baomidou.mybatisplus.generator.config.po.TableField
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 字段转化工具类
* 字段转化工具类
...
@@ -21,9 +23,9 @@ public class FieldUtil {
...
@@ -21,9 +23,9 @@ public class FieldUtil {
* @author fengshuonan
* @author fengshuonan
* @Date 2019/5/7 22:14
* @Date 2019/5/7 22:14
*/
*/
public
static
List
<
String
>
getCamelFields
(
String
[]
underlineFields
,
List
<
TableField
>
tableFields
)
{
public
static
List
<
Map
<
String
,
Object
>>
getCamelFieldsUnderLine
(
String
[]
underlineFields
,
List
<
TableField
>
tableFields
)
{
ArrayList
<
String
>
newFields
=
new
ArrayList
<>();
ArrayList
<
Map
<
String
,
Object
>
>
newFields
=
new
ArrayList
<>();
if
(
underlineFields
.
length
<=
0
||
tableFields
==
null
)
{
if
(
underlineFields
.
length
<=
0
||
tableFields
==
null
)
{
return
newFields
;
return
newFields
;
...
@@ -31,7 +33,12 @@ public class FieldUtil {
...
@@ -31,7 +33,12 @@ public class FieldUtil {
for
(
String
underlineField
:
underlineFields
)
{
for
(
String
underlineField
:
underlineFields
)
{
for
(
TableField
tableField
:
tableFields
)
{
for
(
TableField
tableField
:
tableFields
)
{
if
(
underlineField
.
equals
(
tableField
.
getName
()))
{
if
(
underlineField
.
equals
(
tableField
.
getName
()))
{
newFields
.
add
(
tableField
.
getPropertyName
());
HashMap
<
String
,
Object
>
field
=
new
HashMap
<>();
field
.
put
(
"fieldUnderline"
,
underlineField
);
field
.
put
(
"fieldCamel"
,
tableField
.
getPropertyName
());
newFields
.
add
(
field
);
}
}
}
}
}
}
...
...
guns-vip-gen/src/main/resources/mpTemplates/mapper.xml.vm
View file @
7bd44234
...
@@ -39,8 +39,8 @@
...
@@ -39,8 +39,8 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from ${table.name} where 1 = 1
from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions})
#foreach($field in ${mapperConditions})
<if
test=
"paramCondition.${field
} != null and paramCondition.${field
} != ''"
>
<if
test=
"paramCondition.${field
.fieldCamel} != null and paramCondition.${field.fieldCamel
} != ''"
>
and ${field
} like CONCAT('%',#{paramCondition.${field
}},'%')
and ${field
.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel
}},'%')
</if>
</if>
#end
#end
</select>
</select>
...
@@ -50,8 +50,8 @@
...
@@ -50,8 +50,8 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from ${table.name} where 1 = 1
from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions})
#foreach($field in ${mapperConditions})
<if
test=
"paramCondition.${field
} != null and paramCondition.${field
} != ''"
>
<if
test=
"paramCondition.${field
.fieldCamel} != null and paramCondition.${field.fieldCamel
} != ''"
>
and ${field
} like CONCAT('%',#{paramCondition.${field
}},'%')
and ${field
.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel
}},'%')
</if>
</if>
#end
#end
</select>
</select>
...
@@ -61,9 +61,9 @@
...
@@ -61,9 +61,9 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from ${table.name} where 1 = 1
from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions})
#foreach($field in ${mapperConditions})
<if
test=
"paramCondition.${field} != null and paramCondition.${field
} != ''"
>
<if
test=
"paramCondition.${field.fieldCamel} != null and paramCondition.${field.fieldCamel
} != ''"
>
and ${field} like CONCAT('%',#{paramCondition.${field
}},'%')
and ${field.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel
}},'%')
</if>
</if>
#end
#end
</select>
</select>
...
@@ -72,8 +72,8 @@
...
@@ -72,8 +72,8 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from ${table.name} where 1 = 1
from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions})
#foreach($field in ${mapperConditions})
<if
test=
"paramCondition.${field
} != null and paramCondition.${field
} != ''"
>
<if
test=
"paramCondition.${field
.fieldCamel} != null and paramCondition.${field.fieldCamel
} != ''"
>
and ${field
} like CONCAT('%',#{paramCondition.${field
}},'%')
and ${field
.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel
}},'%')
</if>
</if>
#end
#end
</select>
</select>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment