Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
appbuild
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
appbuild
Commits
2723e7f6
Commit
2723e7f6
authored
Aug 08, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复部分sqlXml生成缺陷
parent
df7538df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
40 deletions
+40
-40
appbuild-manager/src/main/resources/template/java/entity-tree.java.ftl
...ger/src/main/resources/template/java/entity-tree.java.ftl
+37
-1
appbuild-manager/src/main/resources/template/java/serviceImpl-tree.java.ftl
...rc/main/resources/template/java/serviceImpl-tree.java.ftl
+2
-13
appbuild-manager/src/main/resources/template/java/webBody.java.ftl
...manager/src/main/resources/template/java/webBody.java.ftl
+1
-26
No files found.
appbuild-manager/src/main/resources/template/java/entity-tree.java.ftl
View file @
2723e7f6
...
...
@@ -7,6 +7,12 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import
lombok
.
Data
;
import
java
.
io
.
Serializable
;
import
java
.
util
.
stream
.
Collectors
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
com
.
alibaba
.
fastjson
.
JSONArray
;
import
com
.
alibaba
.
fastjson
.
JSONObject
;
import
com
.
alibaba
.
fastjson
.
parser
.
DefaultJSONParser
;
import
com
.
alibaba
.
fastjson
.
parser
.
JSONToken
;
import
com
.
alibaba
.
fastjson
.
parser
.
deserializer
.
ObjectDeserializer
;
/**
*
${
functionName
}
前端映射树结构实体类
*
...
...
@@ -33,10 +39,40 @@ public class ${ClassName}TreeSelect implements Serializable {
@
JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
private
List
<${
ClassName
}
TreeSelect
>
children
;
public
${
ClassName
}
TreeSelect
()
{};
public
${
ClassName
}
TreeSelect
(${
ClassName
}
Entity
entity
)
{
this
.
id
=
entity
.
get
${
pkColumn
.
javaField
?
cap_first
}();
this
.
label
=
entity
.
get
${
treeName
?
cap_first
}();
this
.
children
=
entity
.
getChildren
().
stream
().
map
(${
ClassName
}
TreeSelect
::
new
).
collect
(
Collectors
.
toList
());
if
(
!ObjectUtils.isEmpty(entity.getChildren())){
this
.
children
=
entity
.
getChildren
().
stream
().
map
(${
ClassName
}
TreeSelect
::
new
).
collect
(
Collectors
.
toList
());
}
}
//
反序列化器
public
class
Deserializer
implements
ObjectDeserializer
{
@
Override
public
${
ClassName
}
TreeSelect
deserialze
(
DefaultJSONParser
parser
,
Type
type
,
Object
fieldName
)
{
${
ClassName
}
TreeSelect
node
=
new
${
ClassName
}
TreeSelect
();
JSONObject
jsonObject
=
parser
.
parseObject
();
node
.
setId
(
jsonObject
.
getLong
(
"id"
));
node
.
setLabel
(
jsonObject
.
getString
(
"label"
));
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"children"
);
List
<${
ClassName
}
TreeSelect
>
children
=
new
ArrayList
<>();
if
(
!ObjectUtils.isEmpty(jsonArray)){
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
${
ClassName
}
TreeSelect
child
=
JSON
.
parseObject
(
jsonArray
.
getJSONObject
(
i
).
toJSONString
(),
${
ClassName
}
TreeSelect
.
class
);
children
.
add
(
child
);
}
}
node
.
setChildren
(
children
);
return
node
;
}
@
Override
public
int
getFastMatchToken
()
{
return
JSONToken
.
LBRACE
;
}
}
}
\ No newline at end of file
appbuild-manager/src/main/resources/template/java/serviceImpl-tree.java.ftl
View file @
2723e7f6
...
...
@@ -11,7 +11,6 @@ package ${packageName}.service.impl;
import
org
.
springframework
.
stereotype
.
Service
;
import
com
.
mortals
.
framework
.
exception
.
AppException
;
import
com
.
mortals
.
framework
.
model
.
Context
;
import
com
.
mortals
.
xhx
.
common
.
code
.
SatusEnum
;
import
com
.
mortals
.
framework
.
service
.
impl
.${
Service
};
import
${
packageName
}.
dao
.${
ClassName
}
Dao
;
import
${
packageName
}.
model
.${
ClassName
}
Entity
;
...
...
@@ -55,9 +54,6 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
@
Override
protected
void
saveBefore
(${
ClassName
}
Entity
entity
,
Context
context
)
throws
AppException
{
${
ClassName
}
Entity
parent
${
ClassName
}
Entity
=
this
.
get
(
entity
.
get
${
treeParentCode
?
cap_first
}());
if
(
!ObjectUtils.isEmpty(parent${ClassName}Entity) && SatusEnum.DISENABLE.getValue() == parent${ClassName}Entity.getStatus()) {
throw
new
AppException
(
"${functionName}停用,不允许新增"
);
}
if
(
!ObjectUtils.isEmpty(parent${ClassName}Entity)) {
entity
.
setAncestors
(
parent
${
ClassName
}
Entity
.
getAncestors
()
+
","
+
entity
.
get
${
treeParentCode
?
cap_first
}());
...
...
@@ -95,8 +91,6 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
*/
private
void
updateParent
${
ClassName
}
Status
(${
ClassName
}
Entity
${
ClassName
?
uncap_first
},
Context
context
)
{
${
ClassName
}
Entity
${
ClassName
?
uncap_first
}
Entity
=
this
.
get
(${
ClassName
?
uncap_first
}.
get
${
treeParentCode
?
cap_first
}());
${
ClassName
?
uncap_first
}
Entity
.
setStatus
(
SatusEnum
.
ENABLE
.
getValue
());
${
ClassName
?
uncap_first
}
Entity
.
setUpdateTime
(
new
Date
());
${
ClassName
?
uncap_first
}
Entity
.
setUpdateUser
(
context
==
null
?
""
:
context
.
getUser
().
getLoginName
());
${
ClassName
}
Entity
condition
=
new
${
ClassName
}
Entity
();
...
...
@@ -112,9 +106,7 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
*
@
param
oldAncestors
旧的父
ID
集合
*/
public
void
update
${
ClassName
}
Children
(
Long
${
ClassName
?
uncap_first
}
Id
,
String
newAncestors
,
String
oldAncestors
,
Context
context
)
{
List
<${
ClassName
}
Entity
>
children
=
getDao
().
selectChildren
${
ClassName
}
ById
(${
ClassName
?
uncap_first
}
Id
.
toString
());
for
(${
ClassName
}
Entity
child
:
children
)
{
child
.
setAncestors
(
child
.
getAncestors
().
replace
(
oldAncestors
,
newAncestors
));
}
...
...
@@ -151,7 +143,6 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
for
(
Iterator
<${
ClassName
}
Entity
>
iterator
=
list
.
iterator
();
iterator
.
hasNext
();
)
{
${
ClassName
}
Entity
${
ClassName
?
uncap_first
}
Entity
=
iterator
.
next
();
if
(
!tempList.contains(${ClassName?uncap_first}Entity.get${treeParentCode?cap_first}())) {
recursionFn
(
list
,
${
ClassName
?
uncap_first
}
Entity
);
returnList
.
add
(${
ClassName
?
uncap_first
}
Entity
);
...
...
@@ -160,7 +151,6 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
if
(
returnList
.
isEmpty
())
{
returnList
=
list
;
}
return
returnList
.
stream
().
map
(${
ClassName
}
TreeSelect
::
new
).
collect
(
Collectors
.
toList
());
}
...
...
@@ -201,15 +191,14 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
@
Override
public
List
<${
ClassName
}
TreeSelect
>
getListByParentId
(${
treeParentCodeType
}
parentId
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
parentId
))
{
parentId
=
"0"
;
parentId
=
0L
;
}
//
只做一层
List
<${
ClassName
}
TreeSelect
>
collect
=
this
.
find
(
new
${
ClassName
}
Query
().${
treeParentCode
}(
parentId
),
context
).
stream
().
map
(
item
->
new
${
ClassName
}
TreeSelect
(
item
)
).
collect
(
Collectors
.
toList
());
if
(
"0"
.
equals
(
parentId
)
)
{
if
(
parentId
==
0L
)
{
return
collect
;
}
return
collect
;
}
...
...
appbuild-manager/src/main/resources/template/java/webBody.java.ftl
View file @
2723e7f6
...
...
@@ -57,37 +57,12 @@ public class ${ClassName}Controller extends BaseCRUDJsonBodyMappingController<${
}
<#
if
table
.
tplCategory
==
"tree"
>
@
PostMapping
(
"list/exclude"
)
public
String
excludeList
(${
ClassName
}
Entity
query
)
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
JSONObject
ret
=
new
JSONObject
();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
${
pkColumn
.
javaType
}
id
=
query
.
get
${
pkColumn
.
javaField
?
cap_first
}();
int
code
=
VALUE_RESULT_SUCCESS
;
try
{
Set
<${
pkColumn
.
javaType
}>
idSet
=
new
HashSet
<>();
idSet
.
add
(
query
.
get
${
pkColumn
.
javaField
?
cap_first
}());
List
<${
ClassName
}
Entity
>
collect
=
this
.
service
.
find
(
new
${
ClassName
}
Query
()).
stream
().
map
(
item
->
{
if
(
idSet
.
contains
(
item
.
get
${
pkColumn
.
javaField
?
cap_first
}()))
return
null
;
return
item
;
}).
filter
(
f
->
f
!= null).collect(Collectors.toList());
model
.
put
(
"result"
,
collect
);
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
code
=
VALUE_RESULT_FAILURE
;
this
.
doException
(
request
,
busiDesc
,
model
,
e
);
}
ret
.
put
(
KEY_RESULT_DATA
,
model
);
ret
.
put
(
KEY_RESULT_CODE
,
code
);
return
ret
.
toJSONString
();
}
/**
*
获取站点下拉树列表
*/
@
PostMapping
(
"treeselect"
)
public
String
treeselect
(
${
ClassName
}
Entity
query
)
{
public
String
treeselect
()
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
JSONObject
ret
=
new
JSONObject
();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment