Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mysql-generator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙长纪
mysql-generator
Commits
da023b59
Commit
da023b59
authored
May 23, 2023
by
刘凯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加remote remoteImpl等生成文件
parent
d6a7578c
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
128 additions
and
17 deletions
+128
-17
gradle.xml
.idea/gradle.xml
+3
-1
Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+19
-4
build.gradle
build.gradle
+1
-1
java_dao.ftl
src/main/resources/tpls/java_dao.ftl
+7
-0
java_dao_impl.ftl
src/main/resources/tpls/java_dao_impl.ftl
+15
-0
java_remote_service.ftl
src/main/resources/tpls/java_remote_service.ftl
+7
-0
java_remote_service.impl.ftl
src/main/resources/tpls/java_remote_service.impl.ftl
+12
-2
java_service.ftl
src/main/resources/tpls/java_service.ftl
+6
-0
java_service.impl.ftl
src/main/resources/tpls/java_service.impl.ftl
+26
-4
sql_xml.ftl
src/main/resources/tpls/sql_xml.ftl
+27
-0
CodeGeneratorTest.java
.../java/cn/com/duiba/mysql/generator/CodeGeneratorTest.java
+5
-5
No files found.
.idea/gradle.xml
View file @
da023b59
...
@@ -4,9 +4,11 @@
...
@@ -4,9 +4,11 @@
<component
name=
"GradleSettings"
>
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<GradleProjectSettings>
<option
name=
"delegatedBuild"
value=
"false"
/>
<option
name=
"testRunner"
value=
"PLATFORM"
/>
<option
name=
"distributionType"
value=
"LOCAL"
/>
<option
name=
"distributionType"
value=
"LOCAL"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"gradleHome"
value=
"$USER_HOME$/
software/gradle-4.6
"
/>
<option
name=
"gradleHome"
value=
"$USER_HOME$/
Downloads/jar/gradle-6.6.1
"
/>
<option
name=
"gradleJvm"
value=
"1.8"
/>
<option
name=
"gradleJvm"
value=
"1.8"
/>
<option
name=
"modules"
>
<option
name=
"modules"
>
<set>
<set>
...
...
.idea/inspectionProfiles/Project_Default.xml
View file @
da023b59
...
@@ -3,7 +3,13 @@
...
@@ -3,7 +3,13 @@
<option
name=
"myName"
value=
"Project Default"
/>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"ComparatorNotSerializable"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"ComparatorNotSerializable"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"ExternalizableWithSerializationMethods"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"ExternalizableWithSerializationMethods"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableFieldInSerializableClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableFieldInSerializableClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignorableAnnotations"
>
<value
/>
</option>
<option
name=
"ignoreAnonymousInnerClasses"
value=
"false"
/>
<option
name=
"superClassString"
value=
"java.awt.Component"
/>
</inspection_tool>
<inspection_tool
class=
"NonSerializableObjectBoundToHttpSession"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableObjectBoundToHttpSession"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableObjectPassedToObjectStream"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableObjectPassedToObjectStream"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableWithSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonSerializableWithSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
...
@@ -14,9 +20,18 @@
...
@@ -14,9 +20,18 @@
<inspection_tool
class=
"SerialPersistentFieldsWithWrongSignature"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerialPersistentFieldsWithWrongSignature"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerialVersionUIDNotStaticFinal"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerialVersionUIDNotStaticFinal"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableHasSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableHasSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableHasSerializationMethods"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableHasSerializationMethods"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<inspection_tool
class=
"SerializableInnerClassHasSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<option
name=
"ignoreAnonymousInnerClasses"
value=
"false"
/>
<inspection_tool
class=
"SerializableInnerClassWithNonSerializableOuterClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<option
name=
"superClassString"
value=
"java.io.Externalizable,java.awt.Component"
/>
</inspection_tool>
<inspection_tool
class=
"SerializableInnerClassHasSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignoreAnonymousInnerClasses"
value=
"false"
/>
<option
name=
"superClassString"
value=
"java.awt.Component"
/>
</inspection_tool>
<inspection_tool
class=
"SerializableInnerClassWithNonSerializableOuterClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignoreAnonymousInnerClasses"
value=
"false"
/>
<option
name=
"superClassString"
value=
"java.awt.Component"
/>
</inspection_tool>
<inspection_tool
class=
"SerializableStoresNonSerializable"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableStoresNonSerializable"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableWithUnconstructableAncestor"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"SerializableWithUnconstructableAncestor"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"TransientFieldInNonSerializableClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"TransientFieldInNonSerializableClass"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
...
...
build.gradle
View file @
da023b59
...
@@ -18,7 +18,7 @@ apply plugin: "idea"
...
@@ -18,7 +18,7 @@ apply plugin: "idea"
apply
plugin:
"eclipse"
apply
plugin:
"eclipse"
group
=
"cn.com.duiba"
group
=
"cn.com.duiba"
version
=
"0.2.1
0
"
version
=
"0.2.1
2
"
sourceCompatibility
=
1.8
sourceCompatibility
=
1.8
targetCompatibility
=
1.8
targetCompatibility
=
1.8
...
...
src/main/resources/tpls/java_dao.ftl
View file @
da023b59
...
@@ -2,6 +2,9 @@ package ${daoPackage};
...
@@ -2,6 +2,9 @@ package ${daoPackage};
import
${
entityPackage
}.${
table
.
className
}
Entity
;
import
${
entityPackage
}.${
table
.
className
}
Entity
;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
import
java
.
util
.
Map
;
public
interface
${
table
.
className
}
Dao
{
public
interface
${
table
.
className
}
Dao
{
...
@@ -18,6 +21,10 @@ public interface ${table.className}Dao {
...
@@ -18,6 +21,10 @@ public interface ${table.className}Dao {
List
<${
table
.
className
}
Entity
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
);
List
<${
table
.
className
}
Entity
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
);
Integer
findCountByCondition
(@
Param
(
"dataMap"
)
Map
<
String
,
Object
>
paramMap
);
List
<${
table
.
className
}
Entity
>
findByCondition
(@
Param
(
"dataMap"
)
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
);
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
${
table
.
className
}
Entity
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>);
${
table
.
className
}
Entity
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>);
...
...
src/main/resources/tpls/java_dao_impl.ftl
View file @
da023b59
...
@@ -9,6 +9,8 @@ import cn.com.duiba.developer.center.common.dao.DatabaseSchema;
...
@@ -9,6 +9,8 @@ import cn.com.duiba.developer.center.common.dao.DatabaseSchema;
import
javax
.
annotation
.
PostConstruct
;
import
javax
.
annotation
.
PostConstruct
;
import
java
.
util
.
Map
;
import
java
.
util
.
Map
;
import
com
.
google
.
common
.
collect
.
Maps
;
import
com
.
google
.
common
.
collect
.
Maps
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
@
Repository
@
Repository
...
@@ -59,6 +61,19 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
...
@@ -59,6 +61,19 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
return
selectList
(
"listBy${pk.attrName}s"
,
data
);
return
selectList
(
"listBy${pk.attrName}s"
,
data
);
}
}
@
Override
public
Integer
findCountByCondition
(
Map
<
String
,
Object
>
paramMap
){
return
selectList
(
"findCountByCondition"
,
paramMap
);
}
@
Override
public
List
<${
table
.
className
}
Entity
>
findByCondition
(
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
){
paramMap
.
put
(
"offset"
,
pageQuery
.
getPageSize
()
*
pageQuery
.
getPageNo
());
paramMap
.
put
(
"pageSize"
,
pageQuery
.
getPageSize
());
return
selectList
(
"findByCondition"
,
paramMap
);
}
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
@
Override
@
Override
...
...
src/main/resources/tpls/java_remote_service.ftl
View file @
da023b59
...
@@ -4,6 +4,10 @@ import ${dtoPackage}.${table.className}Dto;
...
@@ -4,6 +4,10 @@ import ${dtoPackage}.${table.className}Dto;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
cn
.
com
.
duiba
.
boot
.
exception
.
BizException
;
import
cn
.
com
.
duiba
.
boot
.
exception
.
BizException
;
import
cn
.
com
.
duiba
.
boot
.
netflix
.
feign
.
AdvancedFeignClient
;
import
cn
.
com
.
duiba
.
boot
.
netflix
.
feign
.
AdvancedFeignClient
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
import
java
.
util
.
Map
;
@
AdvancedFeignClient
@
AdvancedFeignClient
public
interface
Remote
${
table
.
className
}
Service
{
public
interface
Remote
${
table
.
className
}
Service
{
...
@@ -21,6 +25,9 @@ public interface Remote${table.className}Service {
...
@@ -21,6 +25,9 @@ public interface Remote${table.className}Service {
List
<${
table
.
className
}
Dto
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
)
throws
BizException
;
List
<${
table
.
className
}
Dto
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
)
throws
BizException
;
Page
<${
table
.
className
}
Dto
>
findByPage
(
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
)
throws
BizException
;
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>)
throws
BizException
;
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>)
throws
BizException
;
...
...
src/main/resources/tpls/java_remote_service.impl.ftl
View file @
da023b59
...
@@ -8,6 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -8,6 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
org
.
slf4j
.
Logger
;
import
org
.
slf4j
.
Logger
;
import
org
.
slf4j
.
LoggerFactory
;
import
org
.
slf4j
.
LoggerFactory
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
import
java
.
util
.
Map
;
import
java
.
util
.
Date
;
@
RestController
@
RestController
public
class
Remote
${
table
.
className
}
ServiceImpl
implements
Remote
${
table
.
className
}
Service
{
public
class
Remote
${
table
.
className
}
ServiceImpl
implements
Remote
${
table
.
className
}
Service
{
...
@@ -49,16 +54,21 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN
...
@@ -49,16 +54,21 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN
return
${
table
.
classname
}
Service
.
listBy
${
pk
.
attrName
}
s
(${
pk
.
attrname
}
s
);
return
${
table
.
classname
}
Service
.
listBy
${
pk
.
attrName
}
s
(${
pk
.
attrname
}
s
);
}
}
@
Override
Page
<${
table
.
className
}
Dto
>
findByPage
(
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
)
throws
BizException
{
return
${
table
.
classname
}
Service
.
findByPage
(
paramMap
,
page
);
}
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
@
Override
@
Override
public
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
public
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
return
${
table
.
classN
classnameame
}
Service
.
getBy
${
key
}(${
uk
.
attrname
}
);
return
${
table
.
classN
ame
}
Service
.
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>)
);
}
}
@
Override
@
Override
public
List
<${
table
.
className
}
Dto
>
listBy
${
key
}
s
(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
List
<${
uk
.
attrType
}>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
public
List
<${
table
.
className
}
Dto
>
listBy
${
key
}
s
(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
List
<${
uk
.
attrType
}>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
return
${
table
.
classname
}
Service
.
listBy
${
key
}
s
(${
uk
.
attrname
}
s
);
return
${
table
.
classname
}
Service
.
listBy
${
key
}
(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>
);
}
}
</#
list
>
</#
list
>
...
...
src/main/resources/tpls/java_service.ftl
View file @
da023b59
...
@@ -2,6 +2,10 @@ package ${serviceLocation};
...
@@ -2,6 +2,10 @@ package ${serviceLocation};
import
${
dtoPackage
}.${
table
.
className
}
Dto
;
import
${
dtoPackage
}.${
table
.
className
}
Dto
;
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
import
java
.
util
.
Map
;
public
interface
${
table
.
className
}
Service
{
public
interface
${
table
.
className
}
Service
{
...
@@ -19,6 +23,8 @@ public interface ${table.className}Service {
...
@@ -19,6 +23,8 @@ public interface ${table.className}Service {
List
<${
table
.
className
}
Dto
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
);
List
<${
table
.
className
}
Dto
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
);
Page
<${
table
.
className
}
Dto
>
findByPage
(
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
);
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>);
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>);
...
...
src/main/resources/tpls/java_service.impl.ftl
View file @
da023b59
...
@@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org
.
springframework
.
stereotype
.
Service
;
import
org
.
springframework
.
stereotype
.
Service
;
import
org
.
springframework
.
transaction
.
annotation
.
Transactional
;
import
org
.
springframework
.
transaction
.
annotation
.
Transactional
;
import
cn
.
com
.
duiba
.
wolf
.
utils
.
BeanUtils
;
import
cn
.
com
.
duiba
.
wolf
.
utils
.
BeanUtils
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
Page
;
import
cn
.
com
.
duiba
.
api
.
bo
.
page
.
PageQuery
;
import
java
.
util
.
Map
;
import
java
.
util
.
Date
;
@
Service
@
Service
public
class
${
table
.
className
}
ServiceImpl
implements
${
table
.
className
}
Service
{
public
class
${
table
.
className
}
ServiceImpl
implements
${
table
.
className
}
Service
{
...
@@ -49,20 +54,37 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{
...
@@ -49,20 +54,37 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{
}
}
@
Override
@
Override
public
List
<${
table
.
className
}
Dto
>
listBy
${
pk
.
attrName
}
s
(
List
<${
pk
.
attrType
}>
${
pk
.
attrname
}
s
){
public
Page
<${
table
.
className
}
Dto
>
findByPage
(
Map
<
String
,
Object
>
paramMap
,
PageQuery
page
)
{
return
BeanUtils
.
copyList
(${
table
.
classname
}
Dao
.
listBy
${
pk
.
attrName
}
s
(${
pk
.
attrname
}
s
),
${
table
.
className
}
Dto
.
class
);
Integer
totalTotal
=
${
table
.
classname
}
Dao
.
findCountByCondition
(
paramMap
);
Page
<${
table
.
className
}
Dto
>
result
=
new
Page
<>();
result
.
setPageNo
(
pageQuery
.
getPageNo
());
result
.
setPageSize
(
pageQuery
.
getPageSize
());
if
(
totalTotal
==
0
){
result
.
setTotalCount
(
0
);
result
.
setTotalPages
(
0
);
result
.
setList
(
Lists
.
newArrayList
());
return
result
;
}
List
<${
table
.
className
}
Dto
>
data
=
BeanUtils
.
copyList
(${
table
.
classname
}
Dao
.
findByCondition
(
paramMap
,
pageQuery
),
${
table
.
className
}
Dto
.
class
);
int
totalPages
=
count
%
pageQuery
.
getPageSize
()
>
0
?
count
/
pageQuery
.
getPageSize
()
+
1
:
count
/
pageQuery
.
getPageSize
();
result
.
setTotalCount
(
count
);
result
.
setTotalPages
(
totalPages
);
result
.
setList
(
data
);
return
result
;
}
}
</#
if
>
</#
if
>
<#
list
uks
?
keys
as
key
>
<#
list
uks
?
keys
as
key
>
@
Override
@
Override
public
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
public
${
table
.
className
}
Dto
getBy
${
key
}(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>${
uk
.
attrType
}
${
uk
.
attrname
}<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
return
BeanUtils
.
copy
(${
table
.
classname
}
Dao
.
getBy
${
key
}(
${
uk
.
attrname
}),
${
table
.
className
}
Dto
.
class
);
return
BeanUtils
.
copy
(${
table
.
classname
}
Dao
.
getBy
${
key
}(
<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>)
);
}
}
@
Override
@
Override
public
List
<${
table
.
className
}
Dto
>
listBy
${
key
}
s
(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
List
<${
uk
.
attrType
}>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
public
List
<${
table
.
className
}
Dto
>
listBy
${
key
}
s
(<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
List
<${
uk
.
attrType
}>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>){
return
BeanUtils
.
copyList
(${
table
.
classname
}
Dao
.
listBy
${
key
}
s
(
${
uk
.
attrname
}
s
),
${
table
.
className
}
Dto
.
class
);
return
BeanUtils
.
copyList
(${
table
.
classname
}
Dao
.
listBy
${
key
}
s
(
<#
assign
idx
=
0
><#
list
uks
[
key
]
as
uk
>
${
uk
.
attrname
}
s
<#
assign
idx
=
idx
+
1
><#
if
(
idx
<
uks
[
key
]?
size
)>,</#
if
></#
list
>)
);
}
}
</#
list
>
</#
list
>
...
...
src/main/resources/tpls/sql_xml.ftl
View file @
da023b59
...
@@ -61,6 +61,33 @@
...
@@ -61,6 +61,33 @@
</foreach>
</foreach>
</select>
</select>
<select
id=
"findCountByCondition"
resultMap=
"${table.classname}Map"
parameterType=
"map"
>
SELECT
<include
refid=
"columns"
/>
FROM ${table.tableSchema}.${table.tableName}
<where>
<foreach
item=
"value"
index=
"key"
collection=
"dataMap"
separator=
";"
>
<if
test=
"key != null and key != 'offset' and key != 'pageSize'"
>
and ${r"#{key}"} = ${r"#{value}"}
</if>
</foreach>
</where>
</select>
<select
id=
"findByCondition"
resultMap=
"${table.classname}Map"
parameterType=
"map"
>
SELECT
<include
refid=
"columns"
/>
FROM ${table.tableSchema}.${table.tableName}
<where>
<foreach
item=
"value"
index=
"key"
collection=
"dataMap"
separator=
";"
>
<if
test=
"key != null and key != 'offset' and key != 'pageSize'"
>
and ${r"#{key}"} = ${r"#{value}"}
</if>
</foreach>
</where>
LIMIT ${r"#{offset}"},${r"#{pageSize}"}
</select>
<
#list uks?keys as key>
<
#list uks?keys as key>
<select
id=
"getBy${key}"
resultMap=
"${table.classname}Map"
>
<select
id=
"getBy${key}"
resultMap=
"${table.classname}Map"
>
...
...
src/test/java/cn/com/duiba/mysql/generator/CodeGeneratorTest.java
View file @
da023b59
...
@@ -6,9 +6,9 @@ public class CodeGeneratorTest {
...
@@ -6,9 +6,9 @@ public class CodeGeneratorTest {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
DB_URL
=
"jdbc:mysql://
43.142.41.164:3307/ad_projec
t?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&connectTimeout=5000&socketTimeout=60000"
;
String
DB_URL
=
"jdbc:mysql://
localhost:3306/tes
t?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&connectTimeout=5000&socketTimeout=60000"
;
String
user
=
"root"
;
String
user
=
"root"
;
String
pwd
=
"
liukai6651
"
;
String
pwd
=
"
1234567890
"
;
GeneratorConfig
config
=
new
GeneratorConfig
(
DB_URL
,
user
,
pwd
);
GeneratorConfig
config
=
new
GeneratorConfig
(
DB_URL
,
user
,
pwd
);
config
.
setDaoPackage
(
"cn.com.duiba.mysql.generator.test.dao"
);
config
.
setDaoPackage
(
"cn.com.duiba.mysql.generator.test.dao"
);
...
@@ -19,11 +19,11 @@ public class CodeGeneratorTest {
...
@@ -19,11 +19,11 @@ public class CodeGeneratorTest {
config
.
setServiceImplLocation
(
"cn.com.duiba.mysql.generator.test.service.impl"
);
config
.
setServiceImplLocation
(
"cn.com.duiba.mysql.generator.test.service.impl"
);
config
.
setDtoPackage
(
"cn.com.duiba.mysql.generator.test.dto"
);
config
.
setDtoPackage
(
"cn.com.duiba.mysql.generator.test.dto"
);
config
.
setRemotePackage
(
"cn.com.duiba.mysql.generator.test.remote"
);
config
.
setRemotePackage
(
"cn.com.duiba.mysql.generator.test.remote"
);
config
.
setRemoteImplLocation
(
"cn.com.duiba.mysql.generator.test.remote
I
mpl"
);
config
.
setRemoteImplLocation
(
"cn.com.duiba.mysql.generator.test.remote
i
mpl"
);
config
.
setVoLocation
(
"cn.com.duiba.mysql.generator.test.vo"
);
config
.
setVoLocation
(
"cn.com.duiba.mysql.generator.test.vo"
);
config
.
setTableSchema
(
"
ad_projec
t"
);
config
.
setTableSchema
(
"
tes
t"
);
config
.
setTableName
(
"
ad_account_of_facebook
"
);
config
.
setTableName
(
"
tb_test
"
);
config
.
setTablePrefix
(
"tb"
);
config
.
setTablePrefix
(
"tb"
);
config
.
setModuleName
(
""
);
config
.
setModuleName
(
""
);
...
...
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