Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
one-certificate-system
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
赵啸非
one-certificate-system
Commits
2827b329
Commit
2827b329
authored
Aug 08, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加水印图片
parent
8cecaf4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
28 deletions
+154
-28
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/model/CertificateIndustryTreeSelect.java
...dule/certificate/model/CertificateIndustryTreeSelect.java
+135
-1
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/CertificateIndustryService.java
...odule/certificate/service/CertificateIndustryService.java
+4
-11
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/impl/CertificateIndustryServiceImpl.java
...tificate/service/impl/CertificateIndustryServiceImpl.java
+15
-16
No files found.
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/model/CertificateIndustryTreeSelect.java
View file @
2827b329
package
com.mortals.xhx.module.certificate.model
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.ArrayList
;
import
com.mortals.xhx.module.certificate.model.vo.CertificateIndustryVo
;
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
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -24,6 +31,11 @@ public class CertificateIndustryTreeSelect implements Serializable {
*/
private
Long
id
;
/**
* 父节点ID
*/
private
Long
parentId
;
/**
* 节点名称
*/
...
...
@@ -35,12 +47,134 @@ public class CertificateIndustryTreeSelect implements Serializable {
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
private
List
<
CertificateIndustryTreeSelect
>
children
;
public
CertificateIndustryTreeSelect
()
{
}
public
CertificateIndustryTreeSelect
(
CertificateIndustryEntity
entity
)
{
this
.
id
=
entity
.
getId
();
this
.
parentId
=
entity
.
getParentId
();
this
.
label
=
entity
.
getIndustryName
();
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getChildren
())){
this
.
children
=
entity
.
getChildren
().
stream
().
map
(
CertificateIndustryTreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
}
// 反序列化器
public
class
Deserializer
implements
ObjectDeserializer
{
@Override
public
CertificateIndustryTreeSelect
deserialze
(
DefaultJSONParser
parser
,
Type
type
,
Object
fieldName
)
{
CertificateIndustryTreeSelect
node
=
new
CertificateIndustryTreeSelect
();
JSONObject
jsonObject
=
parser
.
parseObject
();
node
.
setId
(
jsonObject
.
getLong
(
"id"
));
node
.
setLabel
(
jsonObject
.
getString
(
"label"
));
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"children"
);
List
<
CertificateIndustryTreeSelect
>
children
=
new
ArrayList
<>();
if
(!
ObjectUtils
.
isEmpty
(
jsonArray
)){
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
CertificateIndustryTreeSelect
child
=
JSON
.
parseObject
(
jsonArray
.
getJSONObject
(
i
).
toJSONString
(),
CertificateIndustryTreeSelect
.
class
);
children
.
add
(
child
);
}
}
node
.
setChildren
(
children
);
return
node
;
}
@Override
public
int
getFastMatchToken
()
{
return
JSONToken
.
LBRACE
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
json
=
"{\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"id\": 10,\n"
+
" \"label\": \"小餐馆\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 11,\n"
+
" \"label\": \"奶茶店\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 14,\n"
+
" \"label\": \"咖啡店\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 1,\n"
+
" \"label\": \"餐饮类\"\n"
+
" },\n"
+
" {\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"id\": 16,\n"
+
" \"label\": \"超市\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 17,\n"
+
" \"label\": \"便利店\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 15,\n"
+
" \"label\": \"购物类\"\n"
+
" },\n"
+
" {\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"id\": 19,\n"
+
" \"label\": \"茶楼\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 20,\n"
+
" \"label\": \"酒吧\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 21,\n"
+
" \"label\": \"游艺厅\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 22,\n"
+
" \"label\": \"电玩城\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 23,\n"
+
" \"label\": \"KTV\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 24,\n"
+
" \"label\": \"洗浴场所\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 25,\n"
+
" \"label\": \"网吧\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 26,\n"
+
" \"label\": \"游乐场\"\n"
+
" },\n"
+
" {\n"
+
" \"id\": 27,\n"
+
" \"label\": \"电影院\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 18,\n"
+
" \"label\": \"娱乐类\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": -1,\n"
+
" \"label\": \"全部行业\"\n"
+
"}"
;
CertificateIndustryTreeSelect
certificateIndustryTreeSelect
=
JSONObject
.
parseObject
(
json
,
CertificateIndustryTreeSelect
.
class
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
certificateIndustryTreeSelect
));
}
}
\ No newline at end of file
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/CertificateIndustryService.java
View file @
2827b329
...
...
@@ -25,15 +25,6 @@ public interface CertificateIndustryService extends ICRUDService<CertificateIndu
boolean
hasChildByCertificateIndustryId
(
Long
certificateIndustryId
);
/**
* 查询行业目录数据
*
* @param certificateIndustry 行业目录
* @return 行业目录集合
*/
List
<
CertificateIndustryEntity
>
selectCertificateIndustryList
(
CertificateIndustryEntity
certificateIndustry
);
/**
* 构建前端所需要下拉树结构
*
...
...
@@ -52,11 +43,13 @@ public interface CertificateIndustryService extends ICRUDService<CertificateIndu
List
<
CertificateIndustryTreeSelect
>
getListByParentId
(
Long
parentId
,
Context
context
);
/**
* 根据父id获取所有子节点id
* 根据父id查询子节点
*
* @param parentId
* @param context
* @return
*/
List
<
Long
>
getAllListByParentId
(
Long
parentId
,
Context
context
);
List
<
CertificateIndustryTreeSelect
>
getAllListByParentId
(
Long
parentId
,
Context
context
);
}
\ No newline at end of file
one-certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/impl/CertificateIndustryServiceImpl.java
View file @
2827b329
...
...
@@ -100,10 +100,6 @@ public class CertificateIndustryServiceImpl extends AbstractCRUDServiceImpl<Cert
return
list
.
size
()
>
0
?
true
:
false
;
}
@Override
public
List
<
CertificateIndustryEntity
>
selectCertificateIndustryList
(
CertificateIndustryEntity
certificateIndustry
)
{
return
this
.
find
(
new
CertificateIndustryQuery
());
}
@Override
public
List
<
CertificateIndustryTreeSelect
>
buildCertificateIndustryTreeSelect
(
List
<
CertificateIndustryEntity
>
list
)
{
...
...
@@ -118,12 +114,9 @@ public class CertificateIndustryServiceImpl extends AbstractCRUDServiceImpl<Cert
returnList
.
add
(
certificateIndustryEntity
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
list
;
}
return
returnList
.
stream
().
map
(
CertificateIndustryTreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
...
...
@@ -166,23 +159,29 @@ public class CertificateIndustryServiceImpl extends AbstractCRUDServiceImpl<Cert
if
(
ObjectUtils
.
isEmpty
(
parentId
))
{
parentId
=
-
1L
;
}
List
<
CertificateIndustryTreeSelect
>
collect
=
this
.
find
(
new
CertificateIndustryQuery
().
parentId
(
parentId
),
context
)
.
stream
().
map
(
item
->
new
CertificateIndustryTreeSelect
(
item
))
.
collect
(
Collectors
.
toList
());
if
(
parentId
==
-
1L
)
{
return
collect
;
}
return
collect
;
}
@Override
public
List
<
Long
>
getAllListByParentId
(
Long
parentId
,
Context
context
)
{
List
<
CertificateIndustryEntity
>
list
=
this
.
find
(
new
CertificateIndustryQuery
().
parentId
(
parentId
));
public
List
<
CertificateIndustryTreeSelect
>
getAllListByParentId
(
Long
parentId
,
Context
context
)
{
List
<
CertificateIndustryEntity
>
list
=
this
.
find
(
new
CertificateIndustryQuery
());
List
<
CertificateIndustryEntity
>
returnList
=
new
ArrayList
<>();
List
<
Long
>
tempList
=
list
.
stream
().
map
(
CertificateIndustryEntity:
:
getId
).
collect
(
Collectors
.
toList
());
if
(!
tempList
.
contains
(
parentId
))
{
CertificateIndustryEntity
certificateIndustryEntity
=
this
.
get
(
parentId
,
context
);
recursionFn
(
list
,
certificateIndustryEntity
);
returnList
.
add
(
certificateIndustryEntity
);
}
return
null
;
if
(
returnList
.
isEmpty
())
{
returnList
=
list
;
}
return
returnList
.
stream
().
map
(
CertificateIndustryTreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
}
\ No newline at end of file
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