Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projectArtifacture
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
0
Merge Requests
0
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
yangzhaojun
projectArtifacture
Commits
1f23c68a
Commit
1f23c68a
authored
Jan 19, 2018
by
李丛阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善 idEntity
parent
f1cb4d43
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
1 deletion
+86
-1
CodeServiceImpl.java
...n/java/org/rcisoft/code/service/impl/CodeServiceImpl.java
+9
-1
DbTableModel.java
src/main/java/org/rcisoft/common/model/DbTableModel.java
+2
-0
IdNotDataEntity.java
src/main/java/org/rcisoft/core/entity/IdNotDataEntity.java
+42
-0
entityNotCommon.ftl
src/main/resources/templates/codeftl/entityNotCommon.ftl
+33
-0
No files found.
src/main/java/org/rcisoft/code/service/impl/CodeServiceImpl.java
View file @
1f23c68a
...
...
@@ -102,8 +102,12 @@ public class CodeServiceImpl extends BaseService implements CodeService {
//column
rs
=
(
ResultSet
)
dbmd
.
getColumns
(
null
,
codeSchema
.
getDbName
(),
table
.
toLowerCase
(),
null
);
dbmd
.
getPrimaryKeys
(
null
,
null
,
tables
[
0
].
toLowerCase
());
boolean
flag
=
false
;
while
(
rs
.
next
())
{
model
=
new
DbColumnModel
();
/* 根据 CREATE_BY 判断是否存在7个字段 */
if
(
"CREATE_BY"
.
equals
(
rs
.
getString
(
"COLUMN_NAME"
).
toUpperCase
()))
flag
=
true
;
model
.
copyColumnFromSqlResult
(
rs
);
models
.
add
(
model
);
}
...
...
@@ -117,6 +121,7 @@ public class CodeServiceImpl extends BaseService implements CodeService {
}
}
}
tableModel
.
setIdEntity
(
flag
);
//table -> column
tableModel
.
setColumnModels
(
models
);
tableModels
.
add
(
tableModel
);
...
...
@@ -252,7 +257,10 @@ public class CodeServiceImpl extends BaseService implements CodeService {
try
{
out
=
new
FileWriter
(
file
);
//fileList.add(file);
temp
=
freeMarkerConfiguration
.
getTemplate
(
"codeftl"
+
File
.
separator
+
suffix
.
toLowerCase
()+
".ftl"
);
if
(
suffix
.
equals
(
"Entity"
)
&&
!
dbTableModel
.
isIdEntity
())
temp
=
freeMarkerConfiguration
.
getTemplate
(
"codeftl"
+
File
.
separator
+
suffix
.
toLowerCase
()
+
"NotCommon"
+
".ftl"
);
else
temp
=
freeMarkerConfiguration
.
getTemplate
(
"codeftl"
+
File
.
separator
+
suffix
.
toLowerCase
()+
".ftl"
);
temp
.
process
(
root
,
out
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
...
...
src/main/java/org/rcisoft/common/model/DbTableModel.java
View file @
1f23c68a
...
...
@@ -34,6 +34,8 @@ public class DbTableModel implements Serializable{
private
String
entityName
;
private
boolean
isIdEntity
;
//是否都存在 create_by update_by .. 7个字段
public
String
getEntityName
()
{
StringBuffer
simpleEntity
=
new
StringBuffer
();
boolean
upPower
=
true
;
...
...
src/main/java/org/rcisoft/core/entity/IdNotDataEntity.java
0 → 100644
View file @
1f23c68a
package
org
.
rcisoft
.
core
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.rcisoft.core.util.IdGen
;
import
javax.persistence.Id
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Transient
;
import
java.io.Serializable
;
/**
* Created with family.
* author: cy
* Date: 16/6/2
* Time: 上午9:15
* description: id entity
*/
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
@Data
public
abstract
class
IdNotDataEntity
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
2L
;
@Id
protected
String
businessId
;
// 编号
@Transient
protected
String
token
;
/**
* 通用设置ID
*/
public
void
setCommonBusinessId
(){
this
.
setBusinessId
(
IdGen
.
uuid
());
}
}
\ No newline at end of file
src/main/resources/templates/codeftl/entityNotCommon.ftl
0 → 100644
View file @
1f23c68a
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
;
import
lombok
.*;
import
org
.
rcisoft
.
core
.
entity
.
IdNotDataEntity
;
import
javax
.
persistence
.*;
import
java
.
math
.
BigDecimal
;
import
java
.
math
.
BigInteger
;
import
java
.
io
.
Serializable
;
import
java
.
util
.
Date
;
import
java
.
util
.
List
;
/**
*
Created
with
${
author
}
on
${.
now
}.
*/
@
Entity
@
Data
@
NoArgsConstructor
@
AllArgsConstructor
@
Table
(
name
=
"${table.tableName}"
)
public
class
${
table
.
entityName
}
extends
IdNotDataEntity
<${
table
.
entityName
}>
{
<#
list
table
.
columnModels
as
item
>
<#
if
item
.
columnNameLowerCamel
!='businessId'>
private
${
item
.
javaType
}
${
item
.
columnNameLowerCamel
};
</#
if
>
</#
list
>
}
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