Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloudV3.0
Commits
d5ba54ba
Commit
d5ba54ba
authored
Nov 12, 2018
by
Huang
Browse files
no commit message
parent
da9d3b1b
Changes
399
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 399+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenTemplateDao.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenTemplate
;
@Mapper
public
interface
GenTemplateDao
extends
InterfaceBaseDao
<
GenTemplate
>
{}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenCategory.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:43
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenCategory.java
package
com.jeespring.modules.gen.entity
;
import
com.jeespring.modules.sys.entity.Dict
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"category"
)
public
class
GenCategory
extends
Dict
{
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
String
>
template
;
private
List
<
String
>
childTableTemplate
;
public
static
String
CATEGORY_REF
=
"category-ref:"
;
@XmlElement
(
name
=
"template"
)
public
List
<
String
>
getTemplate
()
{
return
this
.
template
;
}
public
void
setTemplate
(
List
<
String
>
template
)
{
this
.
template
=
template
;
}
@XmlElementWrapper
(
name
=
"childTable"
)
@XmlElement
(
name
=
"template"
)
public
List
<
String
>
getChildTableTemplate
()
{
return
this
.
childTableTemplate
;
}
public
void
setChildTableTemplate
(
List
<
String
>
childTableTemplate
)
{
this
.
childTableTemplate
=
childTableTemplate
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenConfig.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:48
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenConfig.java
package
com.jeespring.modules.gen.entity
;
import
java.io.Serializable
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
com.jeespring.modules.sys.entity.Dict
;
@XmlRootElement
(
name
=
"config"
)
public
class
GenConfig
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
GenCategory
>
categoryList
;
private
List
<
Dict
>
javaTypeList
;
private
List
<
Dict
>
queryTypeList
;
private
List
<
Dict
>
showTypeList
;
@XmlElementWrapper
(
name
=
"category"
)
@XmlElement
(
name
=
"category"
)
public
List
<
GenCategory
>
getCategoryList
()
{
return
this
.
categoryList
;
}
public
void
setCategoryList
(
List
<
GenCategory
>
categoryList
)
{
this
.
categoryList
=
categoryList
;
}
@XmlElementWrapper
(
name
=
"javaType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getJavaTypeList
()
{
return
this
.
javaTypeList
;
}
public
void
setJavaTypeList
(
List
<
Dict
>
javaTypeList
)
{
this
.
javaTypeList
=
javaTypeList
;
}
@XmlElementWrapper
(
name
=
"queryType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getQueryTypeList
()
{
return
this
.
queryTypeList
;
}
public
void
setQueryTypeList
(
List
<
Dict
>
queryTypeList
)
{
this
.
queryTypeList
=
queryTypeList
;
}
@XmlElementWrapper
(
name
=
"showType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getShowTypeList
()
{
return
this
.
showTypeList
;
}
public
void
setShowTypeList
(
List
<
Dict
>
showTypeList
)
{
this
.
showTypeList
=
showTypeList
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenScheme.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:53
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenScheme.java
package
com.jeespring.modules.gen.entity
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenScheme
extends
AbstractBaseEntity
<
GenScheme
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
category
;
private
String
packageName
;
private
String
moduleName
;
private
String
subModuleName
;
private
String
functionName
;
private
String
functionNameSimple
;
private
String
functionAuthor
;
private
GenTable
genTable
;
private
String
flag
;
private
Boolean
replaceFile
;
public
GenScheme
()
{}
public
GenScheme
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
this
.
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPackageName
()
{
return
this
.
packageName
;
}
public
void
setPackageName
(
String
packageName
)
{
this
.
packageName
=
packageName
;
}
public
String
getModuleName
()
{
return
this
.
moduleName
;
}
public
void
setModuleName
(
String
moduleName
)
{
this
.
moduleName
=
moduleName
;
}
public
String
getSubModuleName
()
{
return
this
.
subModuleName
;
}
public
void
setSubModuleName
(
String
subModuleName
)
{
this
.
subModuleName
=
subModuleName
;
}
public
String
getCategory
()
{
return
this
.
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
String
getFunctionName
()
{
return
this
.
functionName
;
}
public
void
setFunctionName
(
String
functionName
)
{
this
.
functionName
=
functionName
;
}
public
String
getFunctionNameSimple
()
{
return
this
.
functionNameSimple
;
}
public
void
setFunctionNameSimple
(
String
functionNameSimple
)
{
this
.
functionNameSimple
=
functionNameSimple
;
}
public
String
getFunctionAuthor
()
{
return
this
.
functionAuthor
;
}
public
void
setFunctionAuthor
(
String
functionAuthor
)
{
this
.
functionAuthor
=
functionAuthor
;
}
public
GenTable
getGenTable
()
{
return
this
.
genTable
;
}
public
void
setGenTable
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
public
String
getFlag
()
{
return
this
.
flag
;
}
public
void
setFlag
(
String
flag
)
{
this
.
flag
=
flag
;
}
public
Boolean
getReplaceFile
()
{
return
this
.
replaceFile
;
}
public
void
setReplaceFile
(
Boolean
replaceFile
)
{
this
.
replaceFile
=
replaceFile
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTable.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:58
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTable.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenTable
extends
AbstractBaseEntity
<
GenTable
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
pk
;
private
String
comments
;
private
String
tableType
;
private
String
className
;
private
String
parentTable
;
private
String
parentTableFk
;
private
String
isSync
;
private
List
<
GenTableColumn
>
columnList
=
(
List
)
Lists
.
newArrayList
();
private
String
nameLike
;
private
List
<
String
>
pkList
;
private
GenTable
parent
;
private
List
<
GenTable
>
childList
=
(
List
)
Lists
.
newArrayList
();
public
GenTable
()
{}
public
GenTable
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
StringUtils
.
lowerCase
(
this
.
name
);
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPk
()
{
if
(
this
.
pk
==
""
||
this
.
pk
==
null
)
{
this
.
pk
=
"id"
;
}
return
this
.
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getComments
()
{
return
this
.
comments
;
}
public
void
setComments
(
String
comments
)
{
this
.
comments
=
comments
;
}
public
String
getClassName
()
{
return
this
.
className
;
}
public
void
setClassName
(
String
className
)
{
this
.
className
=
className
;
}
public
String
getParentTable
()
{
return
StringUtils
.
lowerCase
(
this
.
parentTable
);
}
public
void
setParentTable
(
String
parentTable
)
{
this
.
parentTable
=
parentTable
;
}
public
String
getParentTableFk
()
{
return
StringUtils
.
lowerCase
(
this
.
parentTableFk
);
}
public
void
setParentTableFk
(
String
parentTableFk
)
{
this
.
parentTableFk
=
parentTableFk
;
}
public
List
<
String
>
getPkList
()
{
return
this
.
pkList
;
}
public
void
setPkList
(
List
<
String
>
pkList
)
{
this
.
pkList
=
pkList
;
if
(
this
.
pkList
.
size
()>=
1
){
this
.
pk
=
this
.
pkList
.
get
(
0
);
}
}
public
String
getNameLike
()
{
return
this
.
nameLike
;
}
public
void
setNameLike
(
String
nameLike
)
{
this
.
nameLike
=
nameLike
;
}
public
GenTable
getParent
()
{
return
this
.
parent
;
}
public
void
setParent
(
GenTable
parent
)
{
this
.
parent
=
parent
;
}
public
List
<
GenTableColumn
>
getColumnList
()
{
return
this
.
columnList
;
}
public
void
setColumnList
(
List
<
GenTableColumn
>
columnList
)
{
this
.
columnList
=
columnList
;
}
public
List
<
GenTable
>
getChildList
()
{
return
this
.
childList
;
}
public
void
setChildList
(
List
<
GenTable
>
childList
)
{
this
.
childList
=
childList
;
}
public
String
getNameAndComments
()
{
return
getName
()
+
(
this
.
comments
==
null
?
""
:
new
StringBuilder
(
" : "
).
append
(
this
.
comments
).
toString
());
}
public
List
<
String
>
getImportList
()
{
List
importList
=
Lists
.
newArrayList
();
for
(
Iterator
iterator
=
getColumnList
().
iterator
();
iterator
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator
.
next
();
if
((
column
.
getIsNotBaseField
().
booleanValue
()
||
"1"
.
equals
(
column
.
getIsQuery
())
&&
"between"
.
equals
(
column
.
getQueryType
())
&&
(
"createDate"
.
equals
(
column
.
getSimpleJavaField
())
||
"updateDate"
.
equals
(
column
.
getSimpleJavaField
())))
&&
StringUtils
.
indexOf
(
column
.
getJavaType
(),
"."
)
!=
-
1
&&
!
importList
.
contains
(
column
.
getJavaType
()))
{
importList
.
add
(
column
.
getJavaType
());
}
if
(
column
.
getIsNotBaseField
().
booleanValue
())
{
for
(
Iterator
iterator1
=
column
.
getAnnotationList
().
iterator
();
iterator1
.
hasNext
();)
{
String
ann
=
(
String
)
iterator1
.
next
();
if
(!
importList
.
contains
(
StringUtils
.
substringBeforeLast
(
ann
,
"("
)))
{
importList
.
add
(
StringUtils
.
substringBeforeLast
(
ann
,
"("
));
}
}
}
}
if
(
getChildList
()
!=
null
&&
getChildList
().
size
()
>
0
)
{
if
(!
importList
.
contains
(
"java.util.List"
))
{
importList
.
add
(
"java.util.List"
);
}
if
(!
importList
.
contains
(
"com.google.common.collect.Lists"
))
{
importList
.
add
(
"com.google.common.collect.Lists"
);
}
}
return
importList
;
}
public
Boolean
getParentExists
()
{
if
((
this
.
parent
!=
null
)
&&
(
StringUtils
.
isNotBlank
(
this
.
parentTable
))
&&
(
StringUtils
.
isNotBlank
(
this
.
parentTableFk
)))
{
return
Boolean
.
valueOf
(
true
);
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getCreateDateExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"create_date"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getUpdateDateExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"update_date"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getDelFlagExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"del_flag"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
void
setIsSync
(
String
isSync
)
{
this
.
isSync
=
isSync
;
}
public
String
getIsSync
()
{
return
this
.
isSync
;
}
public
void
setTableType
(
String
tableType
)
{
this
.
tableType
=
tableType
;
}
public
String
getTableType
()
{
return
this
.
tableType
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTableColumn.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:24:02
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTableColumn.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.List
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenTableColumn
extends
AbstractBaseEntity
<
GenTableColumn
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
GenTable
genTable
;
private
String
name
;
private
String
comments
;
private
String
jdbcType
;
private
String
javaType
;
private
String
javaField
;
private
String
isPk
;
private
String
isNull
;
private
String
isInsert
;
private
String
isEdit
;
private
String
isList
;
private
String
isQuery
;
private
String
queryType
;
private
String
showType
;
private
String
dictType
;
private
Integer
sort
;
private
String
autoIncrement
;
public
GenTableColumn
()
{}
public
GenTableColumn
(
String
id
)
{
super
(
id
);
}
public
GenTableColumn
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
public
GenTable
getGenTable
()
{
return
this
.
genTable
;
}
public
void
setGenTable
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
StringUtils
.
lowerCase
(
this
.
name
);
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getComments
()
{
return
this
.
comments
;
}
public
void
setComments
(
String
comments
)
{
this
.
comments
=
comments
;
}
public
String
getJdbcType
()
{
return
StringUtils
.
lowerCase
(
this
.
jdbcType
);
}
public
void
setJdbcType
(
String
jdbcType
)
{
this
.
jdbcType
=
jdbcType
;
}
public
String
getJavaType
()
{
return
this
.
javaType
;
}
public
void
setJavaType
(
String
javaType
)
{
this
.
javaType
=
javaType
;
}
public
String
getJavaField
()
{
return
this
.
javaField
;
}
public
void
setJavaField
(
String
javaField
)
{
this
.
javaField
=
javaField
;
}
public
String
getIsPk
()
{
return
this
.
isPk
;
}
public
void
setIsPk
(
String
isPk
)
{
this
.
isPk
=
isPk
;
}
public
String
getIsNull
()
{
return
this
.
isNull
;
}
public
void
setIsNull
(
String
isNull
)
{
this
.
isNull
=
isNull
;
}
public
String
getIsInsert
()
{
return
this
.
isInsert
;
}
public
void
setIsInsert
(
String
isInsert
)
{
this
.
isInsert
=
isInsert
;
}
public
String
getIsEdit
()
{
return
this
.
isEdit
;
}
public
void
setIsEdit
(
String
isEdit
)
{
this
.
isEdit
=
isEdit
;
}
public
String
getIsList
()
{
return
this
.
isList
;
}
public
void
setIsList
(
String
isList
)
{
this
.
isList
=
isList
;
}
public
String
getIsQuery
()
{
return
this
.
isQuery
;
}
public
void
setIsQuery
(
String
isQuery
)
{
this
.
isQuery
=
isQuery
;
}
public
String
getQueryType
()
{
return
this
.
queryType
;
}
public
void
setQueryType
(
String
queryType
)
{
this
.
queryType
=
queryType
;
}
public
String
getShowType
()
{
return
this
.
showType
;
}
public
void
setShowType
(
String
showType
)
{
this
.
showType
=
showType
;
}
public
String
getDictType
()
{
return
this
.
dictType
==
null
?
""
:
this
.
dictType
;
}
public
void
setDictType
(
String
dictType
)
{
this
.
dictType
=
dictType
;
}
public
Integer
getSort
()
{
return
this
.
sort
;
}
public
void
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
}
public
String
getNameAndComments
()
{
return
getName
()
+
(
this
.
comments
==
null
?
""
:
new
StringBuilder
(
" : "
).
append
(
this
.
comments
).
toString
());
}
public
String
getDataLength
()
{
String
[]
ss
=
StringUtils
.
split
(
StringUtils
.
substringBetween
(
getJdbcType
(),
"("
,
")"
),
","
);
if
((
ss
!=
null
)
&&
(
ss
.
length
==
1
))
{
return
ss
[
0
];
}
return
"0"
;
}
public
String
getSimpleJavaType
()
{
if
(
"This"
.
equals
(
getJavaType
()))
{
return
StringUtils
.
capitalize
(
this
.
genTable
.
getClassName
());
}
return
StringUtils
.
indexOf
(
getJavaType
(),
"."
)
!=
-
1
?
StringUtils
.
substringAfterLast
(
getJavaType
(),
"."
)
:
getJavaType
();
}
public
String
getSimpleJavaField
()
{
return
StringUtils
.
substringBefore
(
getJavaField
(),
"."
);
}
public
String
getJavaFieldId
()
{
return
StringUtils
.
substringBefore
(
getJavaField
(),
"|"
);
}
public
String
getJavaFieldName
()
{
String
[][]
ss
=
getJavaFieldAttrs
();
return
ss
.
length
>
0
?
getSimpleJavaField
()
+
"."
+
ss
[
0
][
0
]
:
""
;
}
public
String
[][]
getJavaFieldAttrs
()
{
String
[]
ss
=
StringUtils
.
split
(
StringUtils
.
substringAfter
(
getJavaField
(),
"|"
),
"|"
);
String
[][]
sss
=
new
String
[
ss
.
length
][
2
];
if
(
ss
!=
null
)
{
for
(
int
i
=
0
;
i
<
ss
.
length
;
i
++)
{
sss
[
i
][
0
]
=
ss
[
i
];
sss
[
i
][
1
]
=
StringUtils
.
toUnderScoreCase
(
ss
[
i
]);
}
}
return
sss
;
}
public
List
<
String
>
getAnnotationList
()
{
List
<
String
>
list
=
Lists
.
newArrayList
();
if
(
"This"
.
equals
(
getJavaType
()))
{
list
.
add
(
"com.fasterxml.jackson.annotation.JsonBackReference"
);
}
if
(
"java.util.Date"
.
equals
(
getJavaType
()))
{
list
.
add
(
"com.fasterxml.jackson.annotation.JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")"
);
}
if
((!
"1"
.
equals
(
getIsNull
()))
&&
(!
"String"
.
equals
(
getJavaType
())))
{
list
.
add
(
"javax.validation.constraints.NotNull(message=\""
+
getComments
()
+
"不能为空\")"
);
}
else
if
((!
"1"
.
equals
(
getIsNull
()))
&&
(
"String"
.
equals
(
getJavaType
()))
&&
(!
"0"
.
equals
(
getDataLength
())))
{
list
.
add
(
"org.hibernate.validator.constraints.Length(min=1, max="
+
getDataLength
()
+
", message=\""
+
getComments
()
+
"长度必须介于 1 和 "
+
getDataLength
()
+
" 之间\")"
);
}
else
if
((
"String"
.
equals
(
getJavaType
()))
&&
(!
"0"
.
equals
(
getDataLength
())))
{
list
.
add
(
"org.hibernate.validator.constraints.Length(min=0, max="
+
getDataLength
()
+
", message=\""
+
getComments
()
+
"长度必须介于 0 和 "
+
getDataLength
()
+
" 之间\")"
);
}
return
list
;
}
public
List
<
String
>
getSimpleAnnotationList
()
{
List
<
String
>
list
=
Lists
.
newArrayList
();
for
(
String
ann
:
getAnnotationList
())
{
list
.
add
(
StringUtils
.
substringAfterLast
(
ann
,
"."
));
}
return
list
;
}
public
Boolean
getIsNotBaseField
()
{
if
((!
StringUtils
.
equals
(
getSimpleJavaField
(),
"id"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"remarks"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"createBy"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"createDate"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"updateBy"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"updateDate"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"delFlag"
)))
{
return
Boolean
.
valueOf
(
true
);
}
return
Boolean
.
valueOf
(
false
);
}
public
String
getAutoIncrement
()
{
return
this
.
autoIncrement
;
}
public
void
setAutoIncrement
(
String
autoIncrement
)
{
this
.
autoIncrement
=
autoIncrement
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTemplate.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:24:06
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTemplate.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlTransient
;
import
org.hibernate.validator.constraints.Length
;
@XmlRootElement
(
name
=
"template"
)
public
class
GenTemplate
extends
AbstractBaseEntity
<
GenTemplate
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
category
;
private
String
filePath
;
private
String
fileName
;
private
String
content
;
public
GenTemplate
()
{}
public
GenTemplate
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
this
.
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getFileName
()
{
return
this
.
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getFilePath
()
{
return
this
.
filePath
;
}
public
void
setFilePath
(
String
filePath
)
{
this
.
filePath
=
filePath
;
}
public
String
getContent
()
{
return
this
.
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getCategory
()
{
return
this
.
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
@XmlTransient
public
List
<
String
>
getCategoryList
()
{
if
(
this
.
category
==
null
)
{
return
(
List
)
Lists
.
newArrayList
();
}
return
Lists
.
newArrayList
(
StringUtils
.
split
(
this
.
category
,
","
));
}
public
void
setCategoryList
(
List
<
String
>
categoryList
)
{
if
(
categoryList
==
null
)
{
this
.
category
=
""
;
}
else
{
this
.
category
=
(
","
+
StringUtils
.
join
(
categoryList
,
","
)
+
","
);
}
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/CgAutoListService.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:22
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: CgAutoListService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.*
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.gen.template.FreemarkerHelper
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
CgAutoListService
extends
AbstractService
{
public
CgAutoListService
()
{
}
public
GenTable
get
(
String
id
)
{
GenTable
genTable
=
genTableDao
.
get
(
id
);
GenTableColumn
genTableColumn
=
new
GenTableColumn
();
genTableColumn
.
setGenTable
(
new
GenTable
(
genTable
.
getId
()));
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
genTableColumn
));
return
genTable
;
}
public
Page
find
(
Page
page
,
GenTable
genTable
)
{
genTable
.
setPage
(
page
);
page
.
setList
(
genTableDao
.
findList
(
genTable
));
return
page
;
}
public
List
findAll
()
{
return
genTableDao
.
findAllList
(
new
GenTable
());
}
public
List
findTableListFormDb
(
GenTable
genTable
)
{
return
genDataBaseDictDao
.
findTableList
(
genTable
);
}
public
boolean
checkTableName
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
{
return
true
;
}
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genTableDao
.
findList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
boolean
checkTableNameFromDB
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
{
return
true
;
}
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genDataBaseDictDao
.
findTableList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
String
generateCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
com
.
jeespring
.
modules
.
gen
.
entity
.
GenConfig
config
=
GenUtils
.
getConfig
();
genScheme
.
setGenTable
(
genTable
);
java
.
util
.
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
FreemarkerHelper
viewEngine
=
new
FreemarkerHelper
();
String
html
=
viewEngine
.
parseTemplate
(
"/com/jeespring/modules/gen/template/viewList.ftl"
,
model
);
return
html
;
}
public
String
generateListCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
com
.
jeespring
.
modules
.
gen
.
entity
.
GenConfig
config
=
GenUtils
.
getConfig
();
genScheme
.
setGenTable
(
genTable
);
java
.
util
.
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
FreemarkerHelper
viewEngine
=
new
FreemarkerHelper
();
String
html
=
viewEngine
.
parseTemplate
(
"/com/jeespring/modules/gen/template/findList.ftl"
,
model
);
return
html
;
}
@Autowired
private
GenTableDao
genTableDao
;
@Autowired
private
GenTableColumnDao
genTableColumnDao
;
@Autowired
private
GenDataBaseDictDao
genDataBaseDictDao
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/GenSchemeService.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:26
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenSchemeService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.*
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.util.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
GenSchemeService
extends
AbstractService
{
public
GenSchemeService
()
{
}
public
GenScheme
get
(
String
id
)
{
return
genSchemeDao
.
get
(
id
);
}
public
Page
find
(
Page
page
,
GenScheme
genScheme
)
{
GenUtils
.
getTemplatePath
();
genScheme
.
setPage
(
page
);
page
.
setList
(
genSchemeDao
.
findList
(
genScheme
));
return
page
;
}
@Transactional
(
readOnly
=
false
)
public
String
save
(
GenScheme
genScheme
)
{
if
(
StringUtils
.
isBlank
(
genScheme
.
getId
()))
{
genScheme
.
preInsert
();
genSchemeDao
.
insert
(
genScheme
);
}
else
{
genScheme
.
preUpdate
();
genSchemeDao
.
update
(
genScheme
);
}
return
generateCode
(
genScheme
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
GenScheme
genScheme
)
{
genSchemeDao
.
delete
(
genScheme
);
}
private
String
generateCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
GenConfig
config
=
GenUtils
.
getConfig
();
List
templateList
=
GenUtils
.
getTemplateList
(
config
,
genScheme
.
getCategory
(),
false
);
List
childTableTemplateList
=
GenUtils
.
getTemplateList
(
config
,
genScheme
.
getCategory
(),
true
);
if
(
childTableTemplateList
.
size
()
>
0
)
{
GenTable
parentTable
=
new
GenTable
();
parentTable
.
setParentTable
(
genTable
.
getName
());
genTable
.
setChildList
(
genTableDao
.
findList
(
parentTable
));
}
for
(
Iterator
iterator
=
genTable
.
getChildList
().
iterator
();
iterator
.
hasNext
();)
{
GenTable
childTable
=
(
GenTable
)
iterator
.
next
();
childTable
.
setParent
(
genTable
);
childTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
childTable
.
getId
()))));
genScheme
.
setGenTable
(
childTable
);
Map
childTableModel
=
GenUtils
.
getDataModel
(
genScheme
);
GenTemplate
tpl
;
for
(
Iterator
iterator2
=
childTableTemplateList
.
iterator
();
iterator2
.
hasNext
();
result
.
append
(
GenUtils
.
generateToFile
(
tpl
,
childTableModel
,
true
)))
{
tpl
=
(
GenTemplate
)
iterator2
.
next
();
}
}
genScheme
.
setGenTable
(
genTable
);
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
GenTemplate
tpl
;
for
(
Iterator
iterator1
=
templateList
.
iterator
();
iterator1
.
hasNext
();
result
.
append
(
GenUtils
.
generateToFile
(
tpl
,
model
,
true
)))
{
tpl
=
(
GenTemplate
)
iterator1
.
next
();
}
return
result
.
toString
();
}
public
GenScheme
findUniqueByProperty
(
String
propertyName
,
String
value
)
{
return
genSchemeDao
.
findUniqueByProperty
(
propertyName
,
value
);
}
@Autowired
private
GenSchemeDao
genSchemeDao
;
@Autowired
private
GenTableDao
genTableDao
;
@Autowired
private
GenTableColumnDao
genTableColumnDao
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/GenTableService.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:30
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTableService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.*
;
import
com.jeespring.modules.gen.entity.GenTable
;
import
com.jeespring.modules.gen.entity.GenTableColumn
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.util.Iterator
;
import
java.util.List
;
import
com.jeespring.modules.sys.dao.DictDao
;
import
com.jeespring.modules.sys.entity.Dict
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
GenTableService
extends
AbstractService
{
public
GenTableService
()
{
}
public
GenTable
get
(
String
id
)
{
GenTable
genTable
=
genTableDao
.
get
(
id
);
GenTableColumn
genTableColumn
=
new
GenTableColumn
();
genTableColumn
.
setGenTable
(
new
GenTable
(
genTable
.
getId
()));
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
genTableColumn
));
return
genTable
;
}
public
Page
find
(
Page
page
,
GenTable
genTable
)
{
genTable
.
setPage
(
page
);
page
.
setList
(
genTableDao
.
findList
(
genTable
));
return
page
;
}
public
List
findAll
()
{
return
genTableDao
.
findAllList
(
new
GenTable
());
}
public
List
findTableListFormDb
(
GenTable
genTable
)
{
return
genDataBaseDictDao
.
findTableList
(
genTable
);
}
public
boolean
checkTableName
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
{
return
true
;
}
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genTableDao
.
findList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
boolean
checkTableNameFromDB
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
{
return
true
;
}
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genDataBaseDictDao
.
findTableList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
GenTable
getTableFormDb
(
GenTable
genTable
)
{
if
(
StringUtils
.
isNotBlank
(
genTable
.
getName
()))
{
List
list
=
genDataBaseDictDao
.
findTableList
(
genTable
);
if
(
list
.
size
()
>
0
)
{
if
(
StringUtils
.
isBlank
(
genTable
.
getId
()))
{
genTable
=
(
GenTable
)
list
.
get
(
0
);
if
(
StringUtils
.
isBlank
(
genTable
.
getComments
()))
{
genTable
.
setComments
(
genTable
.
getName
());
}
genTable
.
setClassName
(
StringUtils
.
toCapitalizeCamelCase
(
genTable
.
getName
()));
}
List
columnList
=
genDataBaseDictDao
.
findTableColumnList
(
genTable
);
for
(
Iterator
iterator
=
columnList
.
iterator
();
iterator
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator
.
next
();
boolean
b
=
false
;
for
(
Iterator
iterator2
=
genTable
.
getColumnList
().
iterator
();
iterator2
.
hasNext
();)
{
GenTableColumn
e
=
(
GenTableColumn
)
iterator2
.
next
();
if
(
e
.
getName
()
!=
null
&&
e
.
getName
().
equals
(
column
.
getName
()))
{
b
=
true
;
}
}
if
(!
b
)
{
genTable
.
getColumnList
().
add
(
column
);
}
}
for
(
Iterator
iterator1
=
genTable
.
getColumnList
().
iterator
();
iterator1
.
hasNext
();)
{
GenTableColumn
e
=
(
GenTableColumn
)
iterator1
.
next
();
boolean
b
=
false
;
for
(
Iterator
iterator3
=
columnList
.
iterator
();
iterator3
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator3
.
next
();
if
(
column
.
getName
().
equals
(
e
.
getName
()))
{
b
=
true
;
}
}
if
(!
b
)
{
e
.
setDelFlag
(
"1"
);
}
}
genTable
.
setPkList
(
genDataBaseDictDao
.
findTablePK
(
genTable
));
GenUtils
.
initColumnField
(
genTable
,
dictDao
.
findTypeList
(
new
Dict
()));
}
}
return
genTable
;
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
GenTable
genTable
)
{
boolean
isSync
=
true
;
if
(
StringUtils
.
isBlank
(
genTable
.
getId
()))
{
isSync
=
false
;
}
else
{
GenTable
oldTable
=
get
(
genTable
.
getId
());
if
(
oldTable
.
getColumnList
().
size
()
!=
genTable
.
getColumnList
().
size
()
||
!
oldTable
.
getName
().
equals
(
genTable
.
getName
())
||
!
oldTable
.
getComments
().
equals
(
genTable
.
getComments
()))
{
isSync
=
false
;
}
else
{
for
(
Iterator
iterator1
=
genTable
.
getColumnList
().
iterator
();
iterator1
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator1
.
next
();
if
(
StringUtils
.
isBlank
(
column
.
getId
()))
{
isSync
=
false
;
}
else
{
GenTableColumn
oldColumn
=
genTableColumnDao
.
get
(
column
.
getId
());
if
(!
oldColumn
.
getName
().
equals
(
column
.
getName
())
||
!
oldColumn
.
getJdbcType
().
equals
(
column
.
getJdbcType
())
||
!
oldColumn
.
getIsPk
().
equals
(
column
.
getIsPk
())
||
!
oldColumn
.
getComments
().
equals
(
column
.
getComments
()))
{
isSync
=
false
;
}
}
}
}
}
if
(!
isSync
)
{
genTable
.
setIsSync
(
"0"
);
}
if
(
StringUtils
.
isBlank
(
genTable
.
getId
()))
{
genTable
.
preInsert
();
genTableDao
.
insert
(
genTable
);
}
else
{
genTable
.
preUpdate
();
genTableDao
.
update
(
genTable
);
}
genTableColumnDao
.
deleteByGenTable
(
genTable
);
GenTableColumn
column
;
for
(
Iterator
iterator
=
genTable
.
getColumnList
().
iterator
();
iterator
.
hasNext
();
genTableColumnDao
.
insert
(
column
))
{
column
=
(
GenTableColumn
)
iterator
.
next
();
column
.
setGenTable
(
genTable
);
column
.
setId
(
null
);
column
.
preInsert
();
}
}
@Transactional
(
readOnly
=
false
)
public
void
syncSave
(
GenTable
genTable
)
{
genTable
.
setIsSync
(
"1"
);
genTableDao
.
update
(
genTable
);
}
@Transactional
(
readOnly
=
false
)
public
void
saveFromDB
(
GenTable
genTable
)
{
genTable
.
preInsert
();
genTableDao
.
insert
(
genTable
);
GenTableColumn
column
;
for
(
Iterator
iterator
=
genTable
.
getColumnList
().
iterator
();
iterator
.
hasNext
();
genTableColumnDao
.
insert
(
column
))
{
column
=
(
GenTableColumn
)
iterator
.
next
();
column
.
setGenTable
(
genTable
);
column
.
setId
(
null
);
column
.
preInsert
();
}
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
GenTable
genTable
)
{
genTableDao
.
delete
(
genTable
);
genTableColumnDao
.
deleteByGenTable
(
genTable
);
}
@Transactional
(
readOnly
=
false
)
public
void
buildTable
(
String
sql
)
{
genTableDao
.
buildTable
(
sql
);
}
@Autowired
private
GenTableDao
genTableDao
;
@Autowired
private
GenTableColumnDao
genTableColumnDao
;
@Autowired
private
GenDataBaseDictDao
genDataBaseDictDao
;
@Autowired
private
DictDao
dictDao
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/GenTemplateService.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:35
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTemplateService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.GenTemplateDao
;
import
com.jeespring.modules.gen.entity.GenTemplate
;
import
org.apache.commons.lang3.StringEscapeUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
GenTemplateService
extends
AbstractService
{
public
GenTemplateService
()
{
}
public
GenTemplate
get
(
String
id
)
{
return
genTemplateDao
.
get
(
id
);
}
public
Page
find
(
Page
page
,
GenTemplate
genTemplate
)
{
genTemplate
.
setPage
(
page
);
page
.
setList
(
genTemplateDao
.
findList
(
genTemplate
));
return
page
;
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
GenTemplate
genTemplate
)
{
if
(
genTemplate
.
getContent
()
!=
null
)
{
genTemplate
.
setContent
(
StringEscapeUtils
.
unescapeHtml4
(
genTemplate
.
getContent
()));
}
if
(
StringUtils
.
isBlank
(
genTemplate
.
getId
()))
{
genTemplate
.
preInsert
();
genTemplateDao
.
insert
(
genTemplate
);
}
else
{
genTemplate
.
preUpdate
();
genTemplateDao
.
update
(
genTemplate
);
}
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
GenTemplate
genTemplate
)
{
genTemplateDao
.
delete
(
genTemplate
);
}
@Autowired
private
GenTemplateDao
genTemplateDao
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/template/FreemarkerHelper.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:12
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: FreemarkerHelper.java
package
com.jeespring.modules.gen.template
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
java.io.StringWriter
;
import
java.util.Map
;
public
class
FreemarkerHelper
{
public
FreemarkerHelper
()
{
}
public
String
parseTemplate
(
String
tplName
,
String
encoding
,
Map
paras
)
{
try
{
StringWriter
swriter
=
new
StringWriter
();
Template
mytpl
=
null
;
mytpl
=
_tplConfig
.
getTemplate
(
tplName
,
encoding
);
mytpl
.
process
(
paras
,
swriter
);
return
swriter
.
toString
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
e
.
toString
();
}
}
public
String
parseTemplate
(
String
tplName
,
Map
paras
)
{
return
parseTemplate
(
tplName
,
"utf-8"
,
paras
);
}
private
static
Configuration
_tplConfig
;
static
{
_tplConfig
=
new
Configuration
();
_tplConfig
.
setClassForTemplateLoading
(
FreemarkerHelper
.
class
,
"/"
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/template/findList.ftl
0 → 100644
View file @
d5ba54ba
SELECT
<#assign columnField>
<#list table.columnList as c>
a.$
{
c
.name
}
AS "$
{
c
.javaFieldId
}
",
</#list>
<#list table.columnList as c>
<#if c.showType?? && c.showType == "userselect">
<#list c.javaFieldAttrs as a>
u$
{
c_index
+
1
}
.$
{
a
[
1
]}
AS "$
{
c
.simpleJavaField
}
.$
{
a
[
0
]}
",
</#list>
<#elseif c.showType?? && c.showType == "officeselect">
<#list c.javaFieldAttrs as a>
o$
{
c_index
+
1
}
.$
{
a
[
1
]}
AS "$
{
c
.simpleJavaField
}
.$
{
a
[
0
]}
",
</#list>
<#elseif c.showType?? && c.showType == "areaselect">
<#list c.javaFieldAttrs as a>
a$
{
c_index
+
1
}
.$
{
a
[
1
]}
AS "$
{
c
.simpleJavaField
}
.$
{
a
[
0
]}
",
</#list>
</#if>
<#-- 父表关联字段 -->
<#if table.parentExists && table.parentTableFk == c.name>
<#list c.javaFieldAttrs as a>
b.$
{
a
[
1
]}
AS "$
{
c
.simpleJavaField
}
.$
{
a
[
0
]}
",
</#list>
</#if>
</#list>
</#assign>
${
columnField
?
substring
(0,
columnField?last_index_of(","))
}
FROM $
{
table
.name
}
a
<#-- 关联父表 -->
<#if table.parentExists>
LEFT JOIN $
{
table
.parent.name
}
b ON b.id = a.$
{
table
.parentTableFk
}
</#if>
<#-- 关联系统表 -->
<#list table.columnList as c>
<#if c.showType?? && c.showType == "userselect">
LEFT JOIN sys_user u$
{
c_index
+
1
}
ON u$
{
c_index
+
1
}
.id = a.$
{
c
.name
}
<#elseif c.showType?? && c.showType == "officeselect">
LEFT JOIN sys_office o$
{
c_index
+
1
}
ON o$
{
c_index
+
1
}
.id = a.$
{
c
.name
}
<#elseif c.showType?? && c.showType == "areaselect">
LEFT JOIN sys_area a$
{
c_index
+
1
}
ON a$
{
c_index
+
1
}
.id = a.$
{
c
.name
}
</#if>
</#list>
<where>
<#if table.delFlagExists>a.del_flag = $
{
"#"
}{
DEL
_
FLAG
_
NORMAL
}
</#if>
<#list table.columnList as c>
<#if (c.isQuery?? && c.isQuery == "1") || (table.parentExists && table.parentTableFk == c.name)>
<#if c.queryType ?? && c.queryType == 'between'>
<if test="begin$
{
c
.simpleJavaField
?
cap_first
}
!= null and end$
{
c
.simpleJavaField
?
cap_first
}
!= null <#if c.simpleJavaField != c.javaFieldId>and begin$
{
c
.javaFieldId
?
cap_first
}
!= null and end$
{
c
.javaFieldId
?
cap_first
}
!= null </#if>and begin$
{
c
.javaFieldId
?
cap_first
}
!= '' and end$
{
c
.javaFieldId
?
cap_first
}
!= ''">
<#else>
<if test="$
{
c
.simpleJavaField
}
!= null<#if c.simpleJavaField != c.javaFieldId> and $
{
c
.javaFieldId
}
!= null</#if> and $
{
c
.javaFieldId
}
!= ''">
</#if>
<#if c.queryType ?? && c.queryType == 'between'>
AND a.$
{
c
.name
}
BETWEEN $
{
"#"
}{
begin
$
{
c
.simpleJavaField
?
cap_first
}}
AND $
{
"#"
}{
end
$
{
c
.simpleJavaField
?
cap_first
}}
<#elseif c.queryType ?? && c.queryType == 'like'>
AND a.$
{
c
.name
}
LIKE
<if test="dbName == 'oracle'">'%'||$
{
"#"
}{
$
{
c
.javaFieldId
}}
||'%'</if>
<if test="dbName == 'mssql'">'%'+$
{
"#"
}{
$
{
c
.javaFieldId
}}
+'%'</if>
<if test="dbName == 'mysql'">concat('%',$
{
"#"
}{
$
{
c
.javaFieldId
}}
,'%')</if>
<#elseif c.queryType ?? && c.queryType == 'left_like'>
AND a.$
{
c
.name
}
LIKE
<if test="dbName == 'oracle'">'%'||$
{
"#"
}{
$
{
c
.javaFieldId
}}
</if>
<if test="dbName == 'mssql'">'%'+$
{
"#"
}{
$
{
c
.javaFieldId
}}
</if>
<if test="dbName == 'mysql'">concat('%',$
{
"#"
}{
$
{
c
.javaFieldId
}}
)</if>
<#elseif c.queryType ?? && c.queryType == 'right_like'>
AND a.$
{
c
.name
}
LIKE
<if test="dbName == 'oracle'">$
{
"#"
}{
$
{
c
.javaFieldId
}}
||'%'</if>
<if test="dbName == 'mssql'">$
{
"#"
}{
$
{
c
.javaFieldId
}}
+'%'</if>
<if test="dbName == 'mysql'">concat($
{
"#"
}{
$
{
c
.javaFieldId
}}
,'%')</if>
<#else>
AND a.$
{
c
.name
}
$
{
c
.queryType
}
$
{
"#"
}{
$
{
c
.javaFieldId
}}
</#if>
</if>
</#if>
</#list>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY $
{
"$"
}{
page
.orderBy
}
</when>
<otherwise>
<#if table.parentExists>
<#if table.createDateExists>
ORDER BY a.create_date ASC
</#if>
<#else>
<#if table.updateDateExists>
ORDER BY a.update_date DESC
</#if>
</#if>
</otherwise>
</choose>
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/template/mapper.xml
0 → 100644
View file @
d5ba54ba
<?xml version="1.0" encoding="utf-8"?>
<template>
<name>
mapper
</name>
<filePath>
src/main/resources/mappings/${lastPackageName}/${moduleName}/${subModuleName}
</filePath>
<fileName>
${ClassName}Dao.xml
</fileName>
<content>
<![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${packageName}.${moduleName}.dao<#if subModuleName != "
"
>
.${subModuleName}
<
/#if>.${ClassName}Dao">
<
#-- 输出字段列 -->
<sql
id=
"${className}Columns"
>
<
#assign columnField>
<
#list table.columnList as c>
a.${c.name} AS "${c.javaFieldId}",
<
/#list>
<
#list table.columnList as c>
<
#if c.showType??
&&
c.showType == "userselect">
<
#list c.javaFieldAttrs as a>
u${c_index + 1}.${a[1]} AS "${c.simpleJavaField}.${a[0]}",
<
/#list>
<
#elseif c.showType??
&&
c.showType == "officeselect">
<
#list c.javaFieldAttrs as a>
o${c_index + 1}.${a[1]} AS "${c.simpleJavaField}.${a[0]}",
<
/#list>
<
#elseif c.showType??
&&
c.showType == "areaselect">
<
#list c.javaFieldAttrs as a>
a${c_index + 1}.${a[1]} AS "${c.simpleJavaField}.${a[0]}",
<
/#list>
<
/#if>
<
#-- 父表关联字段 -->
<
#if table.parentExists
&&
table.parentTableFk == c.name>
<
#list c.javaFieldAttrs as a>
b.${a[1]} AS "${c.simpleJavaField}.${a[0]}",
<
/#list>
<
/#if>
<
/#list>
<
/#assign>
${columnField?substring(0, columnField?last_index_of(","))}
</sql>
<
#-- 输出字段关联表 -->
<sql
id=
"${className}Joins"
>
<
#-- 关联父表 -->
<
#if table.parentExists>
LEFT JOIN ${table.parent.name} b ON b.id = a.${table.parentTableFk}
<
/#if>
<
#-- 关联系统表 -->
<
#list table.columnList as c>
<
#if c.showType??
&&
c.showType == "userselect">
LEFT JOIN sys_user u${c_index + 1} ON u${c_index + 1}.id = a.${c.name}
<
#elseif c.showType??
&&
c.showType == "officeselect">
LEFT JOIN sys_office o${c_index + 1} ON o${c_index + 1}.id = a.${c.name}
<
#elseif c.showType??
&&
c.showType == "areaselect">
LEFT JOIN sys_area a${c_index + 1} ON a${c_index + 1}.id = a.${c.name}
<
/#if>
<
/#list>
</sql>
<select
id=
"get"
resultType=
"${ClassName}"
>
SELECT
<include
refid=
"${className}Columns"
/>
FROM ${table.name} a
<include
refid=
"${className}Joins"
/>
WHERE a.id = ${"#"}{id}
</select>
<select
id=
"findList"
resultType=
"${ClassName}"
>
SELECT
<include
refid=
"${className}Columns"
/>
FROM ${table.name} a
<include
refid=
"${className}Joins"
/>
<where>
<
#if table.delFlagExists>a.del_flag = ${"#"}{DEL_FLAG_NORMAL}
<
/#if>
<
#list table.columnList as c>
<
#if (c.isQuery??
&&
c.isQuery == "1") || (table.parentExists
&&
table.parentTableFk == c.name)>
<
#if c.queryType ??
&&
c.queryType == 'between'>
<if
test=
"begin${c.simpleJavaField?cap_first} != null and end${c.simpleJavaField?cap_first} != null <#if c.simpleJavaField != c.javaFieldId>and begin${c.javaFieldId?cap_first} != null and end${c.javaFieldId?cap_first} != null </#if>and begin${c.javaFieldId?cap_first} != '' and end${c.javaFieldId?cap_first} != ''"
>
<
#else>
<if
test=
"${c.simpleJavaField} != null<#if c.simpleJavaField != c.javaFieldId> and ${c.javaFieldId} != null</#if> and ${c.javaFieldId} != ''"
>
<
/#if>
<
#if c.queryType ??
&&
c.queryType == 'between'>
AND a.${c.name} BETWEEN ${"#"}{begin${c.simpleJavaField?cap_first}} AND ${"#"}{end${c.simpleJavaField?cap_first}}
<
#elseif c.queryType ??
&&
c.queryType == 'like'>
AND a.${c.name} LIKE
<if
test=
"dbName == 'oracle'"
>
'%'||${"#"}{${c.javaFieldId}}||'%'
</if>
<if
test=
"dbName == 'mssql'"
>
'%'+${"#"}{${c.javaFieldId}}+'%'
</if>
<if
test=
"dbName == 'mysql'"
>
concat('%',${"#"}{${c.javaFieldId}},'%')
</if>
<
#elseif c.queryType ??
&&
c.queryType == 'left_like'>
AND a.${c.name} LIKE
<if
test=
"dbName == 'oracle'"
>
'%'||${"#"}{${c.javaFieldId}}
</if>
<if
test=
"dbName == 'mssql'"
>
'%'+${"#"}{${c.javaFieldId}}
</if>
<if
test=
"dbName == 'mysql'"
>
concat('%',${"#"}{${c.javaFieldId}})
</if>
<
#elseif c.queryType ??
&&
c.queryType == 'right_like'>
AND a.${c.name} LIKE
<if
test=
"dbName == 'oracle'"
>
${"#"}{${c.javaFieldId}}||'%'
</if>
<if
test=
"dbName == 'mssql'"
>
${"#"}{${c.javaFieldId}}+'%'
</if>
<if
test=
"dbName == 'mysql'"
>
concat(${"#"}{${c.javaFieldId}},'%')
</if>
<
#else>
AND a.${c.name} ${c.queryType} ${"#"}{${c.javaFieldId}}
<
/#if>
</if>
<
/#if>
<
/#list>
</where>
<choose>
<when
test=
"page !=null and page.orderBy != null and page.orderBy != ''"
>
ORDER BY ${"$"}{page.orderBy}
</when>
<otherwise>
<
#if table.parentExists>
<
#if table.createDateExists>
ORDER BY a.create_date ASC
<
/#if>
<
#else>
<
#if table.updateDateExists>
ORDER BY a.update_date DESC
<
/#if>
<
/#if>
</otherwise>
</choose>
</select>
<select
id=
"findAllList"
resultType=
"${ClassName}"
>
SELECT
<include
refid=
"${className}Columns"
/>
FROM ${table.name} a
<include
refid=
"${className}Joins"
/>
<where>
<
#if table.delFlagExists>a.del_flag = ${"#"}{DEL_FLAG_NORMAL}
<
/#if>
</where>
<choose>
<when
test=
"page !=null and page.orderBy != null and page.orderBy != ''"
>
ORDER BY ${"$"}{page.orderBy}
</when>
<otherwise>
<
#if table.parentExists>
<
#if table.createDateExists>
ORDER BY a.create_date ASC
<
/#if>
<
#else>
<
#if table.updateDateExists>
ORDER BY a.update_date DESC
<
/#if>
<
/#if>
</otherwise>
</choose>
</select>
<insert
id=
"insert"
>
INSERT INTO ${table.name}(
<
#assign insertField>
<
#list table.columnList as c>
<
#if c.isInsert??
&&
c.isInsert == "1">
${c.name},
<
/#if>
<
/#list>
<
/#assign>
${insertField?substring(0, insertField?last_index_of(","))}
) VALUES (
<
#assign insertJavaField>
<
#list table.columnList as c>
<
#if c.isInsert??
&&
c.isInsert == "1">
${"#"}{${c.javaFieldId}},
<
/#if>
<
/#list>
<
/#assign>
${insertJavaField?substring(0, insertJavaField?last_index_of(","))}
)
</insert>
<update
id=
"update"
>
UPDATE ${table.name} SET
<
#assign updateField>
<
#list table.columnList as c>
<
#if c.isEdit??
&&
c.isEdit == "1">
${c.name} = ${"#"}{${c.javaFieldId}},
<
/#if>
<
/#list>
<
/#assign>
${updateField?substring(0, updateField?last_index_of(","))}
WHERE id = ${"#"}{id}
</update>
<update
id=
"delete"
>
<
#if table.delFlagExists>
UPDATE ${table.name} SET
del_flag = ${"#"}{DEL_FLAG_DELETE}
<
#else>
DELETE FROM ${table.name}
<
/#if>
<
#if table.parentExists>
<
#list table.columnList as c>
<
#if table.parentTableFk == c.name>
<choose>
<when
test=
"id !=null and id != ''"
>
WHERE id = ${"#"}{id}
</when>
<otherwise>
WHERE ${table.parentTableFk} = ${"#"}{${c.javaFieldId}}
</otherwise>
</choose>
<
/#if>
<
/#list>
<
#else>
WHERE id = ${"#"}{id}
<
/#if>
</update>
</mapper>
]]>
</content>
</template>
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/template/viewList.ftl
0 → 100644
View file @
d5ba54ba
<%@
page contentType="text/html;charset=UTF-8" %>
<%@
include file="/webpage/include/taglib.jsp"%>
<
html
>
<
head
>
<title>$
{
functionNameSimple
}
管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function()
{
<#
list
table
.columnList
as
c
>
<#
if
c
.isQuery
??
&&
c
.isQuery
==
"1"
>
<#
if
c
.showType
==
"dateselect"
&&
c
.queryType
==
"between"
>
laydate
({
elem
:
'#
begin
$
{
c
.simpleJavaField
?
cap_first
}
'
,
//目标元素。由于
laydate
.js
封装了一个轻量级的选择器引擎,因此
elem
还允许你传入
class
、
tag
但必须按照这种方式
'#
id
.class
'
event
:
'
focus
'
//响应事件。如果没有传入
event
,则按照默认的
click
})
;
laydate
({
elem
:
'#
end
$
{
c
.simpleJavaField
?
cap_first
}
'
,
//目标元素。由于
laydate
.js
封装了一个轻量级的选择器引擎,因此
elem
还允许你传入
class
、
tag
但必须按照这种方式
'#
id
.class
'
event
:
'
focus
'
//响应事件。如果没有传入
event
,则按照默认的
click
})
;
<#
elseif
c
.showType
==
"dateselect"
>
laydate
({
elem
:
'#$
{
c
.javaFieldId
}
'
,
//目标元素。由于
laydate
.js
封装了一个轻量级的选择器引擎,因此
elem
还允许你传入
class
、
tag
但必须按照这种方式
'#
id
.class
'
event
:
'
focus
'
//响应事件。如果没有传入
event
,则按照默认的
click
})
;
</#
if
>
</#
if
>
</#
list
>
}
);
function page(n,s)
{
$
(
"#pageNo"
)
.val
(
n
)
;
$
(
"#pageSize"
)
.val
(
s
)
;
$
(
"#searchForm"
)
.submit
()
;
return
false
;
}
</script>
</
head
>
<
body
>
<ul class="nav nav-tabs">
<li class="active"><a href="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/">$
{
functionNameSimple
}
列表</a></li>
<shiro:hasPermission name="$
{
permissionPrefix
}
:edit"><li><a href="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/form">$
{
functionNameSimple
}
添加</a></li></shiro:hasPermission>
</ul>
<div class="wrapper wrapper-content">
<sys:message content="$
{
r
"${message}"
}
"/>
<div class="row">
<div class="col-sm-12">
<div style="float:right">
<form id="searchForm" modelAttribute="$
{
className
}
" action="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/" method="post" class="form-inline">
<input id="pageNo" name="pageNo" type="hidden" value="$
{
r
"${page.pageNo}"
}
"/>
<input id="pageSize" name="pageSize" type="hidden" value="$
{
r
"${page.pageSize}"
}
"/>
<div class="form-group">
<#list table.columnList as c>
<#if c.isQuery?? && c.isQuery == "1">
<span>$
{
c
.comments
}
:</span>
<#if c.showType == "input" || c.showType == "textarea">
<input id="$
{
c
.javaFieldId
}
" name="$
{
c
.javaFieldId
}
" type="text" <#if c.dataLength != "0"> maxlength="$
{
c
.dataLength
}
"</#if> class=" form-control input-sm"/>
<#elseif c.showType == "select">
<form:select path="$
{
c
.javaFieldId
}
" class="form-control m-b">
<form:option value="" label=""/>
<form:options items="$
{
"$"
}{
fns
:
getDictList
(
'$
{
c
.dictType
}
'
)}
" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
<#elseif c.showType == "checkbox">
<form:checkboxes path="$
{
c
.javaFieldId
}
" items="$
{
"$"
}{
fns
:
getDictList
(
'$
{
c
.dictType
}
'
)}
" itemLabel="label" itemValue="value" htmlEscape="false"/>
<#elseif c.showType == "radiobox">
<form:radiobuttons class="i-checks" path="$
{
c
.javaFieldId
}
" items="$
{
"$"
}{
fns
:
getDictList
(
'$
{
c
.dictType
}
'
)}
" itemLabel="label" itemValue="value" htmlEscape="false"/>
<#elseif c.showType == "dateselect" && c.queryType == "between">
<input id="begin$
{
c
.simpleJavaField
?
cap_first
}
" name="begin$
{
c
.simpleJavaField
?
cap_first
}
" type="text" maxlength="20" class="laydate-icon form-control layer-date input-sm"
value="<fmt:formatDate value="$
{
"$"
}{
$
{
className
}
.begin
$
{
c
.simpleJavaField
?
cap_first
}}
" pattern="yyyy-MM-dd HH:mm:ss"/>"/> -
<input id="end$
{
c
.simpleJavaField
?
cap_first
}
" name="end$
{
c
.simpleJavaField
?
cap_first
}
" type="text" maxlength="20" class="laydate-icon form-control layer-date input-sm"
value="<fmt:formatDate value="$
{
"$"
}{
$
{
className
}
.end
$
{
c
.simpleJavaField
?
cap_first
}}
" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
<#elseif c.showType == "dateselect">
<input id="$
{
c
.javaFieldId
}
" name="$
{
c
.javaFieldId
}
" type="text" maxlength="20" class="laydate-icon form-control layer-date input-sm"
value="<fmt:formatDate value="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
<#elseif c.showType == "userselect">
<sys:treeselect id="$
{
c
.simpleJavaField
}
" name="$
{
c
.javaFieldId
}
" value="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
" labelName="$
{
c
.javaFieldName
}
" labelValue="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldName
}}
"
title="用户" url="/sys/office/treeData?type=3" cssClass="form-control input-sm" allowClear="true" notAllowSelectParent="true"/>
<#elseif c.showType == "officeselect">
<sys:treeselect id="$
{
c
.simpleJavaField
}
" name="$
{
c
.javaFieldId
}
" value="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
" labelName="$
{
c
.javaFieldName
}
" labelValue="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldName
}}
"
title="部门" url="/sys/office/treeData?type=2" cssClass="form-control input-sm" allowClear="true" notAllowSelectParent="true"/>
<#elseif c.showType == "areaselect">
<sys:treeselect id="$
{
c
.simpleJavaField
}
" name="$
{
c
.javaFieldId
}
" value="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
" labelName="$
{
c
.javaFieldName
}
" labelValue="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldName
}}
"
title="区域" url="/sys/area/treeData" cssClass="form-control input-sm" allowClear="true" notAllowSelectParent="true"/>
</#if>
</#if>
</#list>
<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
</div>
</form>
</div>
</div>
</div>
<table id="contentTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
<thead>
<tr>
<#list table.columnList as c>
<#if c.isList?? && c.isList == "1">
<th>$
{
c
.comments
}
</th>
</#if>
</#list>
<shiro:hasPermission name="$
{
permissionPrefix
}
:edit"><th>操作</th></shiro:hasPermission>
</tr>
</thead>
<tbody>
<c:forEach items="$
{
r
"${page.list}"
}
" var="$
{
className
}
">
<tr>
<#assign firstListField = true>
<#list table.columnList as c>
<#if c.isList?? && c.isList == "1">
<td><#if firstListField><a href="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/form?id=$
{
"${"
+
className
+
".id}"
}
"></#if>
<#if c.simpleJavaType == "Date">
<fmt:formatDate value="$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
" pattern="yyyy-MM-dd HH:mm:ss"/>
<#elseif c.showType == "select" || c.showType == "checkbox" || c.showType == "radiobox">
$
{
"$"
}{
fns
:
getDictLabel
(
$
{
className
}
.$
{
c
.javaFieldId
},
'$
{
c
.dictType
}
'
,
''
)}
<#elseif c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect">
$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldName
}}
<#else>
$
{
"$"
}{
$
{
className
}
.$
{
c
.javaFieldId
}}
</#if>
<#if firstListField></a></#if></td>
<#assign firstListField = false>
</#if>
</#list>
<shiro:hasPermission name="$
{
permissionPrefix
}
:edit"><td>
<a href="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/form?id=$
{
"${"
+
className
+
".id}"
}
" class="btn btn-info btn-xs" ><i class="fa fa-file-text-o"></i> 修改</a>
<a href="$
{
r
"${ctx}"
}
/$
{
urlPrefix
}
/delete?id=$
{
"${"
+
className
+
".id}"
}
" onclick="return confirmx('确认要删除该$
{
functionNameSimple
}
吗?', this.href)" class="btn btn-info btn-xs btn-danger"><i class="fa fa-trash"></i> 删除</a>
</td></shiro:hasPermission>
</tr>
</c:forEach>
</tbody>
</table>
$
{
r
"${page}"
}
</div>
</
body
>
</
html
>
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/util/GenUtils.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:01
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenUtils.java
package
com.jeespring.modules.gen.util
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.*
;
import
com.jeespring.common.mapper.JaxbMapper
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.sys.entity.*
;
import
com.jeespring.modules.sys.service.DictService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
java.io.*
;
import
java.util.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.*
;
public
class
GenUtils
{
public
GenUtils
()
{
}
public
static
void
initColumnField
(
GenTable
genTable
,
List
<
String
>
dictList
)
{
int
i
=
0
;
for
(
Iterator
iterator
=
genTable
.
getColumnList
().
iterator
();
iterator
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator
.
next
();
if
(!
StringUtils
.
isNotBlank
(
column
.
getId
()))
{
if
(
StringUtils
.
isBlank
(
column
.
getComments
()))
{
column
.
setComments
(
column
.
getName
());
}
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"CHAR"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"VARCHAR"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"NARCHAR"
))
{
column
.
setJavaType
(
"String"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"BLOB"
)){
column
.
setJavaType
(
"byte[]"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"DATETIME"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"DATE"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"TIMESTAMP"
))
{
column
.
setJavaType
(
"java.util.Date"
);
column
.
setShowType
(
"dateselect"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"BIGINT"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"NUMBER"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"DECIMAL"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"INT"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"TINYINT"
))
{
String
[]
ss
=
StringUtils
.
split
(
StringUtils
.
substringBetween
(
column
.
getJdbcType
(),
"("
,
")"
),
","
);
if
(
ss
!=
null
&&
ss
.
length
==
2
&&
Integer
.
parseInt
(
ss
[
1
])
>
0
)
{
column
.
setJavaType
(
"Double"
);
}
else
if
(
ss
!=
null
&&
ss
.
length
==
1
&&
Integer
.
parseInt
(
ss
[
0
])
<=
10
)
{
column
.
setJavaType
(
"Integer"
);
}
else
{
column
.
setJavaType
(
"Long"
);
}
}
if
(
column
.
getJavaType
()==
null
||
""
.
equals
(
column
.
getJavaType
())){
column
.
setJavaType
(
"String"
);
}
column
.
setJavaField
(
StringUtils
.
toCamelCase
(
column
.
getName
()));
column
.
setIsPk
(
genTable
.
getPkList
().
contains
(
column
.
getName
())
?
"1"
:
"0"
);
if
(
column
.
getIsPk
()==
"1"
&&
column
.
getName
().
toLowerCase
().
contains
(
"id"
)){
column
.
setJavaField
(
"id"
);
}
column
.
setIsInsert
(
"1"
);
if
(!
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"id"
)
&&
!
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"create_by"
)
&&
!
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"create_date"
)
&&
!
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"del_flag"
))
{
column
.
setIsEdit
(
"1"
);
}
else
{
column
.
setIsEdit
(
"0"
);
}
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"name"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"title"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"remarks"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"update_date"
))
{
column
.
setIsList
(
"1"
);
}
else
{
column
.
setIsList
(
"0"
);
}
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"name"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"title"
))
{
column
.
setIsQuery
(
"1"
);
}
else
{
column
.
setIsQuery
(
"0"
);
}
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"name"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"title"
))
{
column
.
setQueryType
(
"like"
);
}
else
{
column
.
setQueryType
(
"="
);
}
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"DATETIME"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"DATE"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"TIMESTAMP"
))
{
column
.
setQueryType
(
"between"
);
}
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"user_id"
))
{
column
.
setJavaType
(
User
.
class
.
getName
());
column
.
setJavaField
(
column
.
getJavaField
().
replaceAll
(
"Id"
,
".id|name"
));
column
.
setShowType
(
"userselect"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"office_id"
))
{
column
.
setJavaType
(
Office
.
class
.
getName
());
column
.
setJavaField
(
column
.
getJavaField
().
replaceAll
(
"Id"
,
".id|name"
));
column
.
setShowType
(
"officeselect"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"area_id"
))
{
column
.
setJavaType
(
Area
.
class
.
getName
());
column
.
setJavaField
(
column
.
getJavaField
().
replaceAll
(
"Id"
,
".id|name"
));
column
.
setShowType
(
"areaselect"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"create_by"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"update_by"
))
{
column
.
setJavaType
(
User
.
class
.
getName
());
column
.
setJavaField
((
new
StringBuilder
(
String
.
valueOf
(
column
.
getJavaField
()))).
append
(
".id"
).
toString
());
column
.
setShowType
(
"input"
);
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"create_date"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"update_date"
))
{
column
.
setShowType
(
"dateselect"
);
}
else
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"remarks"
)
||
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"content"
))
{
column
.
setShowType
(
"textarea"
);
}
else
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"parent_id"
))
{
column
.
setJavaType
(
"This"
);
column
.
setJavaField
(
"parent.id|name"
);
column
.
setShowType
(
"treeselect"
);
}
else
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"parent_ids"
))
{
column
.
setShowType
(
"input"
);
column
.
setQueryType
(
"like"
);
}
else
if
(
StringUtils
.
equalsIgnoreCase
(
column
.
getName
(),
"del_flag"
))
{
column
.
setShowType
(
"radiobox"
);
column
.
setDictType
(
"del_flag"
);
}
else
{
if
(
column
.
getShowType
()==
""
||
column
.
getShowType
()==
null
)
{
column
.
setShowType
(
"input"
);
}
}
if
(
column
.
getName
().
toLowerCase
().
contains
(
"remark"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"TEXT"
)){
column
.
setShowType
(
"textarea"
);
}
if
(
genTable
.
getTableType
()!=
"2"
&&
(
column
.
getName
().
toLowerCase
().
contains
(
"remark"
)
||
StringUtils
.
startsWithIgnoreCase
(
column
.
getJdbcType
(),
"TEXT"
))){
column
.
setShowType
(
"text"
);
column
.
setQueryType
(
"like"
);
}
if
(
column
.
getName
().
toLowerCase
().
contains
(
"picture"
)){
column
.
setShowType
(
"fileselect"
);
}
if
(
StringUtils
.
startsWithIgnoreCase
(
column
.
getName
(),
"is_"
))
{
column
.
setShowType
(
"radiobox"
);
if
(
dictList
.
contains
(
"is_not"
)){
column
.
setDictType
(
"is_not"
);
}
if
(
dictList
.
contains
(
column
.
getName
())
||
dictList
.
contains
(
StringUtils
.
toCapitalizeCamelCase
(
column
.
getName
()))){
column
.
setDictType
(
column
.
getName
());
}
}
if
(
column
.
getName
().
toLowerCase
().
contains
(
"_type"
)){
column
.
setShowType
(
"select"
);
if
(
dictList
.
contains
(
column
.
getName
())
||
dictList
.
contains
(
StringUtils
.
toCapitalizeCamelCase
(
column
.
getName
()))){
column
.
setDictType
(
column
.
getName
());
}
}
if
(
column
.
getName
().
toLowerCase
().
contains
(
"_state"
)
||
"state"
.
equals
(
column
.
getName
().
toLowerCase
())){
column
.
setShowType
(
"select"
);
if
(
dictList
.
contains
(
column
.
getName
())
||
dictList
.
contains
(
StringUtils
.
toCapitalizeCamelCase
(
column
.
getName
()))){
column
.
setDictType
(
column
.
getName
());
}
}
if
(
column
.
getName
().
toLowerCase
().
contains
(
"name"
)){
column
.
setQueryType
(
"like"
);
}
if
(
"1"
.
equals
(
column
.
getAutoIncrement
())){
column
.
setIsInsert
(
"0"
);
}
if
(
i
>
0
&&
i
<=
8
){
column
.
setIsList
(
"1"
);
}
if
(
i
>
0
&&
i
<=
13
&&
!
column
.
getName
().
toLowerCase
().
contains
(
"picture"
)){
column
.
setIsQuery
(
"1"
);
}
i
++;
}
}
}
public
static
String
getTemplatePath
()
{
try
{
File
file
=
(
new
DefaultResourceLoader
()).
getResource
(
""
).
getFile
();
if
(
file
!=
null
)
{
return
(
new
StringBuilder
(
String
.
valueOf
(
file
.
getAbsolutePath
()))).
append
(
File
.
separator
).
append
(
StringUtils
.
replaceEach
(
GenUtils
.
class
.
getName
(),
new
String
[]{
(
new
StringBuilder
(
"util."
)).
append
(
GenUtils
.
class
.
getSimpleName
()).
toString
(),
"."
},
new
String
[]{
"template"
,
File
.
separator
})).
toString
();
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"{}"
,
e
);
}
return
""
;
}
public
static
Object
fileToObject
(
String
fileName
,
Class
clazz
)
{
try
{
String
pathName
=
(
new
StringBuilder
(
"/templates/modules/gen/"
)).
append
(
fileName
).
toString
();
Resource
resource
=
new
ClassPathResource
(
pathName
);
InputStream
is
=
resource
.
getInputStream
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
StringBuilder
sb
=
new
StringBuilder
();
do
{
String
line
=
br
.
readLine
();
if
(
line
==
null
)
{
break
;
}
sb
.
append
(
line
).
append
(
"\r\n"
);
}
while
(
true
);
if
(
is
!=
null
)
{
is
.
close
();
}
if
(
br
!=
null
)
{
br
.
close
();
}
return
JaxbMapper
.
fromXml
(
sb
.
toString
(),
clazz
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error file convert: {}"
,
e
.
getMessage
());
}
return
null
;
}
public
static
GenConfig
getConfig
()
{
return
(
GenConfig
)
fileToObject
(
"config.xml"
,
GenConfig
.
class
);
}
public
static
List
getTemplateList
(
GenConfig
config
,
String
category
,
boolean
isChildTable
)
{
List
templateList
=
Lists
.
newArrayList
();
if
(
config
!=
null
&&
config
.
getCategoryList
()
!=
null
&&
category
!=
null
)
{
for
(
Iterator
iterator
=
config
.
getCategoryList
().
iterator
();
iterator
.
hasNext
();)
{
GenCategory
e
=
(
GenCategory
)
iterator
.
next
();
if
(
category
.
equals
(
e
.
getValue
()))
{
List
list
=
null
;
if
(!
isChildTable
)
{
list
=
e
.
getTemplate
();
}
else
{
list
=
e
.
getChildTableTemplate
();
}
if
(
list
!=
null
)
{
for
(
Iterator
iterator1
=
list
.
iterator
();
iterator1
.
hasNext
();)
{
String
s
=
(
String
)
iterator1
.
next
();
if
(
StringUtils
.
startsWith
(
s
,
GenCategory
.
CATEGORY_REF
))
{
templateList
.
addAll
(
getTemplateList
(
config
,
StringUtils
.
replace
(
s
,
GenCategory
.
CATEGORY_REF
,
""
),
false
));
}
else
{
GenTemplate
template
=
(
GenTemplate
)
fileToObject
(
s
,
GenTemplate
.
class
);
if
(
template
!=
null
)
{
templateList
.
add
(
template
);
}
}
}
}
break
;
}
}
}
return
templateList
;
}
public
static
Map
getDataModel
(
GenScheme
genScheme
)
{
Map
model
=
Maps
.
newHashMap
();
model
.
put
(
"packageName"
,
StringUtils
.
lowerCase
(
genScheme
.
getPackageName
()));
model
.
put
(
"lastPackageName"
,
StringUtils
.
substringAfterLast
((
String
)
model
.
get
(
"packageName"
),
"."
));
model
.
put
(
"moduleName"
,
StringUtils
.
lowerCase
(
genScheme
.
getModuleName
()));
model
.
put
(
"subModuleName"
,
StringUtils
.
lowerCase
(
genScheme
.
getSubModuleName
()));
model
.
put
(
"className"
,
StringUtils
.
uncapitalize
(
genScheme
.
getGenTable
().
getClassName
()));
model
.
put
(
"ClassName"
,
StringUtils
.
capitalize
(
genScheme
.
getGenTable
().
getClassName
()));
model
.
put
(
"functionName"
,
genScheme
.
getFunctionName
());
model
.
put
(
"functionNameSimple"
,
genScheme
.
getFunctionNameSimple
());
model
.
put
(
"functionAuthor"
,
StringUtils
.
isNotBlank
(
genScheme
.
getFunctionAuthor
())
?
genScheme
.
getFunctionAuthor
()
:
UserUtils
.
getUser
().
getName
());
model
.
put
(
"functionVersion"
,
DateUtils
.
getDate
());
model
.
put
(
"urlPrefix"
,
(
new
StringBuilder
()).
append
(
model
.
get
(
"moduleName"
)).
append
(
StringUtils
.
isNotBlank
(
genScheme
.
getSubModuleName
())
?
(
new
StringBuilder
(
"/"
)).
append
(
StringUtils
.
lowerCase
(
genScheme
.
getSubModuleName
())).
toString
()
:
""
).
append
(
"/"
).
append
(
model
.
get
(
"className"
)).
toString
());
model
.
put
(
"viewPrefix"
,
model
.
get
(
"urlPrefix"
));
model
.
put
(
"permissionPrefix"
,
(
new
StringBuilder
()).
append
(
model
.
get
(
"moduleName"
)).
append
(
StringUtils
.
isNotBlank
(
genScheme
.
getSubModuleName
())
?
(
new
StringBuilder
(
":"
)).
append
(
StringUtils
.
lowerCase
(
genScheme
.
getSubModuleName
())).
toString
()
:
""
).
append
(
":"
).
append
(
model
.
get
(
"className"
)).
toString
());
model
.
put
(
"dbType"
,
Global
.
getConfig
(
"jdbc.type"
));
model
.
put
(
"table"
,
genScheme
.
getGenTable
());
return
model
;
}
public
static
String
generateToFile
(
GenTemplate
tpl
,
Map
model
,
boolean
isReplaceFile
)
{
String
fileName
=
Global
.
getProjectPath
()
+
File
.
separator
+
StringUtils
.
replaceEach
(
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
new
StringBuilder
(
String
.
valueOf
(
tpl
.
getFilePath
())).
append
(
"/"
).
toString
(),
model
),
new
String
[]
{
"//"
,
"/"
,
".."
,
"."
},
new
String
[]
{
File
.
separator
,
File
.
separator
,
"__"
,
File
.
separator
}).
replace
(
"__"
,
".."
)
+
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
tpl
.
getFileName
(),
model
);
logger
.
debug
(
" fileName === "
+
fileName
);
String
content
=
FreeMarkers
.
renderString
(
tpl
.
getFileName
(),
StringUtils
.
trimToEmpty
(
tpl
.
getContent
()),
model
);
logger
.
debug
(
" content === \r\n"
+
content
);
if
(
isReplaceFile
)
{
FileUtils
.
deleteFile
(
fileName
);
}
if
(
FileUtils
.
createFile
(
fileName
))
{
FileUtils
.
writeToFile
(
fileName
,
content
,
true
);
logger
.
debug
(
" file create === "
+
fileName
);
return
"生成成功:"
+
fileName
+
"<br/>"
;
}
logger
.
debug
(
" file extents === "
+
fileName
);
return
"文件已存在:"
+
fileName
+
"<br/>"
;
}
public
static
void
main
(
String
[]
args
)
{
try
{
GenConfig
config
=
getConfig
();
System
.
out
.
println
(
config
);
System
.
out
.
println
(
JaxbMapper
.
toXml
(
config
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GenUtils
.
class
);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/web/CgAutoListController.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:29
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: CgAutoListController.java
package
com.jeespring.modules.gen.web
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.gen.entity.GenScheme
;
import
com.jeespring.modules.gen.service.*
;
import
com.jeespring.modules.gen.template.FreemarkerHelper
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.ModelAndView
;
@Controller
@RequestMapping
(
value
={
"${adminPath}/gen/cgAutoList"
})
public
class
CgAutoListController
extends
AbstractBaseController
{
public
CgAutoListController
()
{
}
@ModelAttribute
public
GenScheme
get
(
@RequestParam
(
required
=
true
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
))
{
return
genSchemeService
.
get
(
id
);
}
else
{
return
new
GenScheme
();
}
}
@RequestMapping
(
value
={
"list"
})
public
void
list
(
GenScheme
genScheme
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
long
start
=
System
.
currentTimeMillis
();
FreemarkerHelper
viewEngine
=
new
FreemarkerHelper
();
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
String
html
=
cgAutoListService
.
generateCode
(
genScheme
);
String
findListSql
=
cgAutoListService
.
generateListCode
(
genScheme
);
try
{
response
.
setContentType
(
"text/html"
);
response
.
setHeader
(
"Cache-Control"
,
"no-store"
);
PrintWriter
writer
=
response
.
getWriter
();
writer
.
println
(
html
);
writer
.
flush
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
long
end
=
System
.
currentTimeMillis
();
log
.
debug
(
"动态列表生成耗时:"
+
(
end
-
start
)
+
" ms"
);
}
@RequestMapping
(
value
={
"test"
,
""
})
public
ModelAndView
list
(
GenScheme
genScheme
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
new
ModelAndView
(
"com/jeespring/modules/gen/template/viewList"
);
}
private
static
Logger
log
=
Logger
.
getLogger
(
CgAutoListController
.
class
);
@Autowired
private
GenSchemeService
genSchemeService
;
@Autowired
private
GenTableService
genTableService
;
@Autowired
private
CgAutoListService
cgAutoListService
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/web/GenSchemeController.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:40
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenSchemeController.java
package
com.jeespring.modules.gen.web
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.gen.entity.GenScheme
;
import
com.jeespring.modules.gen.service.GenSchemeService
;
import
com.jeespring.modules.gen.service.GenTableService
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
@Controller
@RequestMapping
(
value
={
"${adminPath}/gen/genScheme"
})
public
class
GenSchemeController
extends
AbstractBaseController
{
@Autowired
private
SysConfigService
sysConfigService
;
public
GenSchemeController
()
{
}
@ModelAttribute
public
GenScheme
get
(
@RequestParam
(
required
=
true
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
))
{
return
genSchemeService
.
get
(
id
);
}
else
{
return
new
GenScheme
();
}
}
@RequiresPermissions
(
value
={
"gen:genScheme:view"
})
@RequestMapping
(
value
={
"list"
,
""
})
public
String
list
(
GenScheme
genScheme
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(!
user
.
isAdmin
())
{
genScheme
.
setCreateBy
(
user
);
}
Page
page
=
genSchemeService
.
find
(
new
Page
(
request
,
response
),
genScheme
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/gen/genSchemeList"
;
}
@RequiresPermissions
(
value
={
"gen:genScheme:view"
})
@RequestMapping
(
value
={
"form"
})
public
String
form
(
GenScheme
genScheme
,
Model
model
)
{
if
(
StringUtils
.
isBlank
(
genScheme
.
getPackageName
()))
{
genScheme
.
setPackageName
(
"com.jeespring.modules"
);
}
model
.
addAttribute
(
"genScheme"
,
genScheme
);
model
.
addAttribute
(
"config"
,
GenUtils
.
getConfig
());
model
.
addAttribute
(
"tableList"
,
genTableService
.
findAll
());
return
"modules/gen/genSchemeForm"
;
}
@RequiresPermissions
(
value
={
"gen:genScheme:edit"
})
@RequestMapping
(
value
={
"save"
})
public
String
save
(
GenScheme
genScheme
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genScheme/"
;
}
if
(!
beanValidator
(
model
,
genScheme
))
{
return
form
(
genScheme
,
model
);
}
else
{
String
result
=
genSchemeService
.
save
(
genScheme
);
addMessage
(
redirectAttributes
,
"操作生成方案'"
+
genScheme
.
getName
()
+
"'成功<br/>"
+
result
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genScheme/?repage"
;
}
}
@RequiresPermissions
(
value
={
"gen:genScheme:edit"
})
@RequestMapping
(
value
={
"delete"
})
public
String
delete
(
GenScheme
genScheme
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTemplate/"
;
}
this
.
genSchemeService
.
delete
(
genScheme
);
addMessage
(
redirectAttributes
,
"删除生成方案成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genScheme/?repage"
;
}
@Autowired
private
GenSchemeService
genSchemeService
;
@Autowired
private
GenTableService
genTableService
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/web/GenTableController.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:45
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTableController.java
package
com.jeespring.modules.gen.web
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.gen.service.GenSchemeService
;
import
com.jeespring.modules.gen.service.GenTableService
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
com.jeespring.modules.sys.entity.Menu
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
com.jeespring.modules.sys.service.SystemService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
java.util.Iterator
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
@Controller
@RequestMapping
(
value
={
"${adminPath}/gen/genTable"
})
public
class
GenTableController
extends
AbstractBaseController
{
@Autowired
private
SystemService
systemService
;
@Autowired
private
SysConfigService
sysConfigService
;
public
GenTableController
()
{
}
public
GenTable
get
(
GenTable
genTable
)
{
if
(
StringUtils
.
isNotBlank
(
genTable
.
getId
()))
{
return
genTableService
.
get
(
genTable
.
getId
());
}
else
{
return
genTable
;
}
}
@RequiresPermissions
(
value
={
"gen:genTable:list"
})
@RequestMapping
(
value
={
"list"
,
""
})
public
String
list
(
GenTable
genTable
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
genTable
=
get
(
genTable
);
User
user
=
UserUtils
.
getUser
();
if
(!
user
.
isAdmin
())
{
genTable
.
setCreateBy
(
user
);
}
Page
page
=
genTableService
.
find
(
new
Page
(
request
,
response
),
genTable
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/gen/genTableList"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:view"
,
"gen:genTable:add"
,
"gen:genTable:edit"
},
logical
=
org
.
apache
.
shiro
.
authz
.
annotation
.
Logical
.
OR
)
@RequestMapping
(
value
={
"form"
})
public
String
form
(
GenTable
genTable
,
Model
model
)
{
genTable
=
get
(
genTable
);
model
.
addAttribute
(
"genTable"
,
genTable
);
model
.
addAttribute
(
"config"
,
GenUtils
.
getConfig
());
model
.
addAttribute
(
"tableList"
,
genTableService
.
findAll
());
return
"modules/gen/genTableForm"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:add"
,
"gen:genTable:edit"
},
logical
=
org
.
apache
.
shiro
.
authz
.
annotation
.
Logical
.
OR
)
@RequestMapping
(
value
={
"save"
})
public
String
save
(
GenTable
genTable
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
if
(!
beanValidator
(
model
,
genTable
))
{
return
form
(
genTable
,
model
);
}
if
((
StringUtils
.
isBlank
(
genTable
.
getId
()))
&&
(!
this
.
genTableService
.
checkTableName
(
genTable
.
getName
())))
{
addMessage
(
redirectAttributes
,
"添加失败!"
+
genTable
.
getName
()
+
" 记录已存在!"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
if
((
StringUtils
.
isBlank
(
genTable
.
getId
()))
&&
(!
this
.
genTableService
.
checkTableNameFromDB
(
genTable
.
getName
())))
{
addMessage
(
redirectAttributes
,
"添加失败!"
+
genTable
.
getName
()
+
"表已经在数据库中存在,请从数据库导入表单!"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
this
.
genTableService
.
save
(
genTable
);
addMessage
(
redirectAttributes
,
"保存业务表'"
+
genTable
.
getName
()
+
"'成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:importDb"
})
@RequestMapping
(
value
={
"importTableFromDB"
})
public
String
importTableFromDB
(
GenTable
genTable
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
genTable
=
get
(
genTable
);
if
(!
StringUtils
.
isBlank
(
genTable
.
getName
()))
{
if
(!
this
.
genTableService
.
checkTableName
(
genTable
.
getName
()))
{
addMessage
(
redirectAttributes
,
"下一步失败!"
+
genTable
.
getName
()
+
" 表已经添加!"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
genTable
=
this
.
genTableService
.
getTableFormDb
(
genTable
);
genTable
.
setTableType
(
"0"
);
this
.
genTableService
.
saveFromDB
(
genTable
);
addMessage
(
redirectAttributes
,
"数据库导入表单'"
+
genTable
.
getName
()
+
"'成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
List
<
GenTable
>
tableList
=
this
.
genTableService
.
findTableListFormDb
(
new
GenTable
());
model
.
addAttribute
(
"tableList"
,
tableList
);
model
.
addAttribute
(
"config"
,
GenUtils
.
getConfig
());
return
"modules/gen/importTableFromDB"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:del"
})
@RequestMapping
(
value
={
"delete"
})
public
String
delete
(
GenTable
genTable
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()
){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
genTable
=
get
(
genTable
);
this
.
genTableService
.
delete
(
genTable
);
this
.
genSchemeService
.
delete
(
this
.
genSchemeService
.
findUniqueByProperty
(
"gen_table_id"
,
genTable
.
getId
()));
addMessage
(
redirectAttributes
,
"移除业务表记录成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:del"
})
@RequestMapping
(
value
={
"deleteDb"
})
public
String
deleteDb
(
GenTable
genTable
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
genTable
=
get
(
genTable
);
this
.
genTableService
.
delete
(
genTable
);
this
.
genSchemeService
.
delete
(
this
.
genSchemeService
.
findUniqueByProperty
(
"gen_table_id"
,
genTable
.
getId
()));
StringBuffer
sql
=
new
StringBuffer
();
sql
.
append
(
"drop table if exists "
+
genTable
.
getName
()
+
" ;"
);
this
.
genTableService
.
buildTable
(
sql
.
toString
());
addMessage
(
redirectAttributes
,
"删除业务表记录和数据库表成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:del"
})
@RequestMapping
(
value
={
"deleteAll"
})
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
String
[]
idArray
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
)
{
this
.
genTableService
.
delete
(
this
.
genTableService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除业务表成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:synchDb"
})
@RequestMapping
(
value
={
"synchDb"
})
public
String
synchDb
(
GenTable
genTable
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
genTable
=
get
(
genTable
);
StringBuffer
sql
=
new
StringBuffer
();
List
getTableColumnList
=
genTable
.
getColumnList
();
sql
.
append
((
new
StringBuilder
(
"drop table if exists "
)).
append
(
genTable
.
getName
()).
append
(
" ;"
).
toString
());
genTableService
.
buildTable
(
sql
.
toString
());
sql
=
new
StringBuffer
();
sql
.
append
((
new
StringBuilder
(
"create table "
)).
append
(
genTable
.
getName
()).
append
(
" ("
).
toString
());
String
pk
=
""
;
for
(
Iterator
iterator
=
getTableColumnList
.
iterator
();
iterator
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator
.
next
();
if
(
"1"
.
equals
(
column
.
getIsPk
()))
{
sql
.
append
((
new
StringBuilder
(
" "
)).
append
(
column
.
getName
()).
append
(
" "
).
append
(
column
.
getJdbcType
()).
append
(
" comment '"
).
append
(
column
.
getComments
()).
append
(
"',"
).
toString
());
pk
=
(
new
StringBuilder
(
String
.
valueOf
(
pk
))).
append
(
column
.
getName
()).
append
(
","
).
toString
();
}
else
{
sql
.
append
((
new
StringBuilder
(
" "
)).
append
(
column
.
getName
()).
append
(
" "
).
append
(
column
.
getJdbcType
()).
append
(
" comment '"
).
append
(
column
.
getComments
()).
append
(
"',"
).
toString
());
}
}
sql
.
append
(
"primary key ("
+
pk
.
substring
(
0
,
pk
.
length
()
-
1
)
+
") "
);
sql
.
append
(
") comment '"
+
genTable
.
getComments
()
+
"'"
);
this
.
genTableService
.
buildTable
(
sql
.
toString
());
this
.
genTableService
.
syncSave
(
genTable
);
addMessage
(
redirectAttributes
,
"强制同步数据库表成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTable:genCode"
})
@RequestMapping
(
value
={
"genCodeForm"
})
public
String
genCodeForm
(
GenScheme
genScheme
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
StringUtils
.
isBlank
(
genScheme
.
getPackageName
()))
{
genScheme
.
setPackageName
(
"com.company.project.modules"
);
}
GenScheme
oldGenScheme
=
genSchemeService
.
findUniqueByProperty
(
"gen_table_id"
,
genScheme
.
getGenTable
().
getId
());
if
(
oldGenScheme
!=
null
)
{
genScheme
=
oldGenScheme
;
}
model
.
addAttribute
(
"genScheme"
,
genScheme
);
model
.
addAttribute
(
"config"
,
GenUtils
.
getConfig
());
model
.
addAttribute
(
"tableList"
,
genTableService
.
findAll
());
return
"modules/gen/genCodeForm"
;
}
@RequestMapping
(
value
={
"genCode"
})
public
String
genCode
(
GenScheme
genScheme
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
genScheme
.
setGenTable
(
genTableService
.
get
(
genScheme
.
getGenTable
().
getId
()));
if
(
sysConfigService
.
isDemoMode
()){
String
msg
=
"<br>"
+
genScheme
.
getGenTable
().
getName
()
+
"代码和菜单、接口已生成成功;<br/>如果启用redis:代码生成后,要退出,再登陆。<br/>菜单路径:<br/>"
+
"接口路径:"
+
"rest/list或者get或者save或者delete<br/>..."
;
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
()+
msg
);
return
"redirect:"
+
adminPath
+
"/gen/genTable/"
;
}
String
href
=
""
;
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
href
=
"/"
+
genScheme
.
getModuleName
()+
"/"
+
genScheme
.
getSubModuleName
()+
"/"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
());
}
else
{
href
=
"/"
+
genScheme
.
getModuleName
()+
"/"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
());
}
if
(
"tree"
.
equals
(
genScheme
.
getCategory
())){
href
=
href
+
"Tree"
;
}
genMenu
(
genScheme
,
href
);
String
result
=
this
.
genSchemeService
.
save
(
genScheme
);
addMessage
(
redirectAttributes
,
genScheme
.
getGenTable
().
getName
()
+
"代码和菜单、接口已生成成功;<br/>如果启用redis:代码生成后,要退出,再登陆。<br/>菜单路径:"
+
href
+
"<br/>"
+
"接口路径:"
+
"rest/"
+
href
+
"/list或者get或者save或者delete<br/>"
+
result
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTable/?repage"
;
}
public
void
genMenu
(
GenScheme
genScheme
,
String
href
){
String
paraentId
=
"158586ffb6b44175885680d1c93f05bd"
;
Menu
menu
=
new
Menu
();
List
<
Menu
>
menus
=
systemService
.
findAllMenu
();
for
(
Menu
menuItem:
menus
)
{
if
(
href
.
equals
(
menuItem
.
getHref
())){
return
;
}
}
menu
.
setHref
(
href
);
menu
.
setName
(
genScheme
.
getFunctionName
());
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menu
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":list"
);
}
else
{
menu
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":list"
);
}
menu
.
setSort
(
30
);
menu
.
setIsShow
(
"1"
);
menu
.
setDelFlag
(
"0"
);
Menu
parent
=
new
Menu
();
parent
.
setId
(
paraentId
);
parent
.
setName
(
"生成模块"
);
menu
.
setParent
(
parent
);
systemService
.
saveMenu
(
menu
);
//View
Menu
menuView
=
new
Menu
();
menuView
.
setName
(
"查看"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuView
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuView
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuView
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":view"
);
}
else
{
menuView
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":view"
);
}
menuView
.
setSort
(
30
);
menuView
.
setIsShow
(
"1"
);
menuView
.
setDelFlag
(
"0"
);
menuView
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuView
);
//edit
Menu
menuEdit
=
new
Menu
();
menuEdit
.
setName
(
"编辑"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuEdit
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuEdit
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuEdit
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":edit"
);
}
else
{
menuEdit
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":edit"
);
}
menuEdit
.
setSort
(
60
);
menuEdit
.
setIsShow
(
"1"
);
menuEdit
.
setDelFlag
(
"0"
);
menuEdit
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuEdit
);
//add
Menu
menuAdd
=
new
Menu
();
menuAdd
.
setName
(
"添加"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuAdd
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuAdd
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuAdd
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":add"
);
}
else
{
menuAdd
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":add"
);
}
menuAdd
.
setSort
(
90
);
menuAdd
.
setIsShow
(
"1"
);
menuAdd
.
setDelFlag
(
"0"
);
menuAdd
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuAdd
);
//del
Menu
menuDel
=
new
Menu
();
menuDel
.
setName
(
"删除"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuDel
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuDel
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuDel
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":del"
);
}
else
{
menuDel
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":del"
);
}
menuDel
.
setSort
(
120
);
menuDel
.
setIsShow
(
"1"
);
menuDel
.
setDelFlag
(
"0"
);
menuDel
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuDel
);
//export
Menu
menuExport
=
new
Menu
();
menuExport
.
setName
(
"导出"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuExport
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuExport
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuExport
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":export"
);
}
else
{
menuExport
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":export"
);
}
menuExport
.
setSort
(
150
);
menuExport
.
setIsShow
(
"1"
);
menuExport
.
setDelFlag
(
"0"
);
menuExport
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuExport
);
//import
Menu
menuImport
=
new
Menu
();
menuImport
.
setName
(
"导入"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuImport
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuImport
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuImport
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":import"
);
}
else
{
menuImport
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":import"
);
}
menuImport
.
setSort
(
180
);
menuImport
.
setIsShow
(
"1"
);
menuImport
.
setDelFlag
(
"0"
);
menuImport
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuImport
);
//total
Menu
menuTotal
=
new
Menu
();
menuTotal
.
setName
(
"统计"
);
for
(
Menu
menuItem:
menus
)
{
if
((
menuTotal
.
getName
().
equals
(
menuItem
.
getName
())
||
menuItem
.
getName
().
contains
(
genScheme
.
getFunctionName
()))
&&
menuItem
.
getParentId
().
equals
(
menu
.
getParentId
())){
menuTotal
=
menuItem
;
}
}
if
(
genScheme
.
getSubModuleName
()!=
null
&&
genScheme
.
getSubModuleName
().
length
()>
0
){
menuTotal
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
genScheme
.
getSubModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":total"
);
}
else
{
menuTotal
.
setPermission
(
genScheme
.
getModuleName
()+
":"
+
StringUtils
.
toCamelCase
(
genScheme
.
getGenTable
().
getName
())+
":total"
);
}
menuTotal
.
setSort
(
210
);
menuTotal
.
setIsShow
(
"1"
);
menuTotal
.
setDelFlag
(
"0"
);
menuTotal
.
setParent
(
menu
);
systemService
.
saveMenu
(
menuTotal
);
}
@Autowired
private
GenTableService
genTableService
;
@Autowired
private
GenSchemeService
genSchemeService
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/web/GenTemplateController.java
0 → 100644
View file @
d5ba54ba
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:52
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTemplateController.java
package
com.jeespring.modules.gen.web
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.gen.entity.GenTemplate
;
import
com.jeespring.modules.gen.service.GenTemplateService
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
@Controller
@RequestMapping
(
value
={
"${adminPath}/gen/genTemplate"
})
public
class
GenTemplateController
extends
AbstractBaseController
{
@Autowired
private
SysConfigService
sysConfigService
;
public
GenTemplateController
()
{
}
@ModelAttribute
public
GenTemplate
get
(
@RequestParam
(
required
=
true
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
))
{
return
genTemplateService
.
get
(
id
);
}
else
{
return
new
GenTemplate
();
}
}
@RequiresPermissions
(
value
={
"gen:genTemplate:view"
})
@RequestMapping
(
value
={
"list"
,
""
})
public
String
list
(
GenTemplate
genTemplate
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(!
user
.
isAdmin
())
{
genTemplate
.
setCreateBy
(
user
);
}
Page
page
=
genTemplateService
.
find
(
new
Page
(
request
,
response
),
genTemplate
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/gen/genTemplateList"
;
}
@RequiresPermissions
(
value
={
"gen:genTemplate:view"
})
@RequestMapping
(
value
={
"form"
})
public
String
form
(
GenTemplate
genTemplate
,
Model
model
)
{
model
.
addAttribute
(
"genTemplate"
,
genTemplate
);
return
"modules/gen/genTemplateForm"
;
}
@RequiresPermissions
(
value
={
"gen:genTemplate:edit"
})
@RequestMapping
(
value
={
"save"
})
public
String
save
(
GenTemplate
genTemplate
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTemplate/"
;
}
if
(!
beanValidator
(
model
,
genTemplate
))
{
return
form
(
genTemplate
,
model
);
}
this
.
genTemplateService
.
save
(
genTemplate
);
addMessage
(
redirectAttributes
,
"保存代码模板'"
+
genTemplate
.
getName
()
+
"'成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTemplate/?repage"
;
}
@RequiresPermissions
(
value
={
"gen:genTemplate:edit"
})
@RequestMapping
(
value
={
"delete"
})
public
String
delete
(
GenTemplate
genTemplate
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/gen/genTemplate/"
;
}
this
.
genTemplateService
.
delete
(
genTemplate
);
addMessage
(
redirectAttributes
,
"删除代码模板成功"
);
return
"redirect:"
+
this
.
adminPath
+
"/gen/genTemplate/?repage"
;
}
@Autowired
private
GenTemplateService
genTemplateService
;
}
Prev
1
…
12
13
14
15
16
17
18
19
20
Next
Write
Preview
Supports
Markdown
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