Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
elearn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
elearn
Commits
23e6e116
Commit
23e6e116
authored
Dec 23, 2024
by
阳浪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门户搜素接口
parent
42156309
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
18 deletions
+110
-18
cloud-system/src/main/java/com/yizhi/system/application/controller/remote/DictionaryController.java
+54
-2
cloud-system/src/main/java/com/yizhi/system/application/service/DictionaryService.java
+6
-0
cloud-system/src/main/java/com/yizhi/system/application/service/impl/DictionaryServiceImpl.java
+50
-16
No files found.
cloud-system/src/main/java/com/yizhi/system/application/controller/remote/DictionaryController.java
View file @
23e6e116
...
...
@@ -78,18 +78,70 @@ public class DictionaryController {
}
/**
* 新增数据字典
* 新增
搜索
数据字典
*
* @param searchName
* @return
*/
@ApiOperation
(
value
=
"
数据字典"
,
notes
=
"新增一个
字典数据"
,
response
=
Response
.
class
)
@ApiOperation
(
value
=
"
新增搜索数据字典"
,
notes
=
"新增一个搜索的
字典数据"
,
response
=
Response
.
class
)
@GetMapping
(
"/insertBySearchName"
)
public
boolean
insertBySearchName
(
@RequestParam
(
"searchName"
)
String
searchName
)
{
return
dictionaryService
.
insertBySearchName
(
searchName
);
}
/**
* 我的搜索历史记录
*
* @return
*/
@ApiOperation
(
value
=
"我的搜索历史记录"
,
notes
=
"查询所有我的搜索历史记录"
,
response
=
Response
.
class
)
@GetMapping
(
value
=
"/home/searchListByMe"
)
public
Response
<
List
<
Dictionary
>>
searchListByMe
()
{
try
{
List
<
com
.
yizhi
.
system
.
application
.
domain
.
Dictionary
>
result
=
dictionaryService
.
searchListByMe
();
return
Response
.
ok
(
result
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
""
,
e
);
return
Response
.
fail
(
ReturnCode
.
SERVICE_UNAVAILABLE
.
getCode
(),
ReturnCode
.
SERVICE_UNAVAILABLE
.
getMsg
());
}
}
/**
* 删除我的搜索历史记录
*
* @return
*/
@ApiOperation
(
value
=
"删除我的搜索历史记录"
,
notes
=
"删除所有我的搜索历史记录"
,
response
=
Response
.
class
)
@GetMapping
(
value
=
"/home/searchDeleteByMe"
)
public
Response
<
String
>
searchDeleteByMe
()
{
try
{
dictionaryService
.
searchDeleteByMe
();
return
Response
.
ok
();
}
catch
(
Exception
e
)
{
LOG
.
error
(
""
,
e
);
return
Response
.
fail
(
ReturnCode
.
SERVICE_UNAVAILABLE
.
getCode
(),
ReturnCode
.
SERVICE_UNAVAILABLE
.
getMsg
());
}
}
/**
* 大家都在搜索历史记录
*
* @return
*/
@ApiOperation
(
value
=
"大家都在搜索历史记录"
,
notes
=
"查询所有大家都在搜索历史记录"
,
response
=
Response
.
class
)
@GetMapping
(
value
=
"/home/searchListByAll"
)
public
Response
<
List
<
Dictionary
>>
searchListByAll
()
{
try
{
List
<
com
.
yizhi
.
system
.
application
.
domain
.
Dictionary
>
result
=
dictionaryService
.
searchListByAll
();
return
Response
.
ok
(
result
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
""
,
e
);
return
Response
.
fail
(
ReturnCode
.
SERVICE_UNAVAILABLE
.
getCode
(),
ReturnCode
.
SERVICE_UNAVAILABLE
.
getMsg
());
}
}
/**
* 删除单个数据字典
*
* @param id
...
...
cloud-system/src/main/java/com/yizhi/system/application/service/DictionaryService.java
View file @
23e6e116
...
...
@@ -89,4 +89,10 @@ public interface DictionaryService extends IService<Dictionary> {
boolean
checkCode
(
String
code
);
boolean
insertBySearchName
(
String
searchName
);
List
<
Dictionary
>
searchListByMe
();
List
<
Dictionary
>
searchListByAll
();
Boolean
searchDeleteByMe
();
}
cloud-system/src/main/java/com/yizhi/system/application/service/impl/DictionaryServiceImpl.java
View file @
23e6e116
...
...
@@ -3,6 +3,8 @@ package com.yizhi.system.application.service.impl;
import
java.util.*
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.enums.SqlLike
;
import
com.google.common.collect.Lists
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.system.application.domain.Dictionary
;
...
...
@@ -35,8 +37,6 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
@Autowired
private
IdGenerator
idGenerator
;
@Autowired
private
DictionaryMapper
dictionaryMapper
;
@Override
...
...
@@ -45,7 +45,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
dictExample
.
setCode
(
dictionary
.
getCode
());
dictExample
.
setEnabled
(
Boolean
.
TRUE
);
int
num
=
dictionary
Mapper
.
selectCount
(
new
EntityWrapper
<
Dictionary
>(
dictExample
));
int
num
=
base
Mapper
.
selectCount
(
new
EntityWrapper
<
Dictionary
>(
dictExample
));
if
(
num
>
0
)
{
throw
new
RuntimeException
(
"Code has alredy existed! -- code: "
+
dictionary
.
getCode
());
}
...
...
@@ -63,7 +63,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
Dictionary
dictForParent
=
new
Dictionary
();
dictForParent
.
setId
(
dictionary
.
getParentId
());
dictForParent
.
setEnabled
(
Boolean
.
TRUE
);
Dictionary
parent
=
dictionary
Mapper
.
selectOne
(
dictForParent
);
Dictionary
parent
=
base
Mapper
.
selectOne
(
dictForParent
);
dictionary
.
setLayer
(
parent
.
getLayer
()
+
1
);
if
(
parent
.
getParentId
()
==
0
)
{
// 若父对象的parentId为0,则父为root
...
...
@@ -80,11 +80,11 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
layerDict
.
setRootId
(
dictionary
.
getRootId
());
layerDict
.
setEnabled
(
Boolean
.
TRUE
);
int
layerCount
=
dictionary
Mapper
.
selectCount
(
new
EntityWrapper
<
Dictionary
>(
layerDict
));
int
layerCount
=
base
Mapper
.
selectCount
(
new
EntityWrapper
<
Dictionary
>(
layerDict
));
dictionary
.
setSort
(
layerCount
+
1
);
}
return
dictionary
Mapper
.
insert
(
dictionary
)
==
1
;
return
base
Mapper
.
insert
(
dictionary
)
==
1
;
}
@Override
...
...
@@ -93,7 +93,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
dictExample
.
setCode
(
code
);
dictExample
.
setEnabled
(
Boolean
.
TRUE
);
return
dictionary
Mapper
.
selectOne
(
dictExample
);
return
base
Mapper
.
selectOne
(
dictExample
);
}
@Override
...
...
@@ -101,7 +101,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
Dictionary
dictionary
=
new
Dictionary
();
dictionary
.
setRootId
(
new
Long
(
0
));
dictionary
.
setEnabled
(
Boolean
.
TRUE
);
return
dictionary
Mapper
.
selectList
(
new
EntityWrapper
<
Dictionary
>(
dictionary
));
return
base
Mapper
.
selectList
(
new
EntityWrapper
<
Dictionary
>(
dictionary
));
}
@Override
...
...
@@ -128,7 +128,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
@Override
public
List
<
Dictionary
>
listChildren
(
long
id
,
Boolean
includeParent
,
Integer
layer
)
{
String
idsStr
=
dictionary
Mapper
.
getDictChildList
(
id
,
includeParent
,
layer
,
true
);
String
idsStr
=
base
Mapper
.
getDictChildList
(
id
,
includeParent
,
layer
,
true
);
if
(
StringUtils
.
isNotEmpty
(
idsStr
))
{
String
[]
ids
=
idsStr
.
split
(
","
);
List
<
Long
>
idList
=
new
ArrayList
<
Long
>();
...
...
@@ -148,7 +148,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
// 待删除id
StringBuilder
idsToDeleteSb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
idsToDeleteSb
.
append
(
","
+
dictionary
Mapper
.
getDictChildList
(
ids
[
i
],
true
,
null
,
true
));
idsToDeleteSb
.
append
(
","
+
base
Mapper
.
getDictChildList
(
ids
[
i
],
true
,
null
,
true
));
idsToDeleteSb
.
append
(
","
+
ids
[
i
]);
}
String
[]
idsToDeleteStr
=
idsToDeleteSb
.
toString
().
split
(
","
);
...
...
@@ -199,9 +199,9 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
try
{
if
(
ObjectUtils
.
isNotEmpty
(
searchName
))
{
Dictionary
Dictionary
=
findByCode
(
"all_search_list"
);
if
(
Dictionary
!=
null
)
{
List
<
Dictionary
>
DictionaryList
=
listChildren
(
Dictionary
.
getId
(),
false
,
1
);
Dictionary
search
=
findByCode
(
"all_search_list"
);
if
(
search
!=
null
)
{
List
<
Dictionary
>
DictionaryList
=
listChildren
(
search
.
getId
(),
false
,
1
);
Optional
<
Dictionary
>
optional
=
null
;
if
(
DictionaryList
==
null
){
DictionaryList
=
Lists
.
newArrayList
();
...
...
@@ -229,7 +229,7 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
dictionarySub
=
new
Dictionary
();
BeanUtil
.
copyProperties
(
dictionary
,
dictionarySub
);
dictionarySub
.
setParentId
(
dictionary
.
getId
());
dictionarySub
.
setCnName
(
searchName
+
"_"
+
ContextHolder
.
get
().
getAccountId
()
);
dictionarySub
.
setCnName
(
searchName
);
dictionarySub
.
setCode
(
key
);
dictionarySub
.
setEnName
(
key
);
insertDetail
(
dictionarySub
);
...
...
@@ -250,14 +250,14 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
dictionary
.
setCreateTime
(
today
);
dictionary
.
setSystemFlag
(
1
);
dictionary
.
setSort
(
DictionaryList
.
size
());
dictionary
.
setParentId
(
Dictionary
.
getId
());
dictionary
.
setParentId
(
search
.
getId
());
insertDetail
(
dictionary
);
Dictionary
dictionarySub
=
new
Dictionary
();
BeanUtil
.
copyProperties
(
dictionary
,
dictionarySub
);
dictionarySub
.
setParentId
(
dictionary
.
getId
());
dictionarySub
.
setCode
(
key
);
dictionarySub
.
setCnName
(
searchName
+
"_"
+
ContextHolder
.
get
().
getAccountId
()
);
dictionarySub
.
setCnName
(
searchName
);
dictionarySub
.
setEnName
(
key
);
insertDetail
(
dictionarySub
);
...
...
@@ -271,5 +271,39 @@ public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Diction
return
true
;
}
@Override
public
List
<
Dictionary
>
searchListByMe
(){
Dictionary
dictionary
=
new
Dictionary
();
dictionary
.
setEnabled
(
Boolean
.
TRUE
);
EntityWrapper
<
Dictionary
>
ew
=
new
EntityWrapper
<>(
dictionary
);
ew
.
like
(
"code"
,
"search_list"
,
SqlLike
.
DEFAULT
);
ew
.
like
(
"code"
,
ContextHolder
.
get
().
getAccountId
()+
""
,
SqlLike
.
DEFAULT
);
return
this
.
selectList
(
ew
);
}
@Override
public
List
<
Dictionary
>
searchListByAll
(){
Dictionary
search
=
findByCode
(
"all_search_list"
);
if
(
search
==
null
){
return
Lists
.
newArrayList
();
}
Dictionary
dictionary
=
new
Dictionary
();
dictionary
.
setEnabled
(
Boolean
.
TRUE
);
dictionary
.
setLayer
(
1
);
dictionary
.
setParentId
(
search
.
getId
());
EntityWrapper
<
Dictionary
>
ew
=
new
EntityWrapper
<>(
dictionary
);
return
this
.
selectList
(
ew
);
}
@Override
public
Boolean
searchDeleteByMe
(){
List
<
Dictionary
>
dictionaries
=
searchListByMe
();
if
(
CollectionUtil
.
isNotEmpty
(
dictionaries
)){
dictionaries
.
stream
().
forEach
(
d
->{
d
.
setEnabled
(
Boolean
.
FALSE
);
updateById
(
d
);
});
}
return
true
;
}
}
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