Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tagManager
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanmw
tagManager
Commits
0c7ad044
Commit
0c7ad044
authored
Dec 20, 2019
by
lanmw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1044ba1c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
29 deletions
+88
-29
TagCtrl.java
src/main/java/com/keymobile/tagmanager/api/TagCtrl.java
+30
-16
TagFileCtrl.java
src/main/java/com/keymobile/tagmanager/api/TagFileCtrl.java
+19
-9
ImportLog.java
src/main/java/com/keymobile/tagmanager/model/ImportLog.java
+9
-0
TagFileService.java
...java/com/keymobile/tagmanager/service/TagFileService.java
+4
-2
Constants.java
src/main/java/com/keymobile/tagmanager/util/Constants.java
+3
-0
UserInfoUtils.java
...ain/java/com/keymobile/tagmanager/util/UserInfoUtils.java
+23
-2
No files found.
src/main/java/com/keymobile/tagmanager/api/TagCtrl.java
View file @
0c7ad044
package
com
.
keymobile
.
tagmanager
.
api
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -36,7 +37,7 @@ public class TagCtrl {
@RequestBody
Tag
tag
)
throws
Exception
{
String
userName
=
UserInfoUtils
.
getUserName
();
tag
.
setCreator
(
userName
);
tag
.
setDept
(
UserInfoUtils
.
getUser
Dept
());
tag
.
setDept
(
UserInfoUtils
.
getUser
CompanyIdPath
());
return
tagService
.
addOrUpdateTag
(
parentId
,
tag
,
userName
);
}
...
...
@@ -51,7 +52,6 @@ public class TagCtrl {
@GetMapping
(
value
=
"/hasChild"
)
public
boolean
hasChild
(
@RequestParam
(
value
=
"tagId"
)
String
tagId
)
throws
Exception
{
String
userName
=
UserInfoUtils
.
getUserName
();
UserInfoUtils
.
getUserDomains
();
return
tagService
.
hasChild
(
tagId
,
userName
);
}
...
...
@@ -65,25 +65,34 @@ public class TagCtrl {
@ApiOperation
(
value
=
"查询维度标签树"
,
notes
=
"查询维度标签树"
)
@GetMapping
(
value
=
"/queryDimensionTagAsTree"
)
public
JsonNode
[]
queryDimensionTagAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
)
throws
TagNotExistException
{
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagService
.
queryDimensionTagAsTree
(
dept
,
parentId
);
public
JsonNode
[]
queryDimensionTagAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
,
@RequestParam
(
required
=
false
)
String
deptIdPath
)
throws
TagNotExistException
{
if
(
StringUtils
.
isBlank
(
deptIdPath
))
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
return
tagService
.
queryDimensionTagAsTree
(
deptIdPath
,
parentId
);
}
@ApiOperation
(
value
=
"查询个人标签树"
,
notes
=
"查询个人标签树"
)
@GetMapping
(
value
=
"/queryPersonalTagAsTree"
)
public
JsonNode
[]
queryPersonalTagAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
)
throws
TagNotExistException
{
public
JsonNode
[]
queryPersonalTagAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
,
@RequestParam
(
required
=
false
)
String
deptIdPath
)
throws
TagNotExistException
{
if
(
StringUtils
.
isBlank
(
deptIdPath
))
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
String
userName
=
UserInfoUtils
.
getUserName
();
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagService
.
queryPersonalTagAsTree
(
parentId
,
userName
,
dept
);
return
tagService
.
queryPersonalTagAsTree
(
parentId
,
userName
,
deptIdPath
);
}
@ApiOperation
(
value
=
"查询个人标签树不包括分享的标签"
,
notes
=
"查询个人标签树不包括分享的标签"
)
@GetMapping
(
value
=
"/queryPersonalTagExcludeOpenTypeAsTree"
)
public
JsonNode
[]
queryPersonalTagExcludeOpenTypeAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
)
throws
TagNotExistException
{
public
JsonNode
[]
queryPersonalTagExcludeOpenTypeAsTree
(
@RequestParam
(
value
=
"parentId"
,
required
=
false
)
String
parentId
,
@RequestParam
(
required
=
false
)
String
deptIdPath
)
throws
TagNotExistException
{
String
userName
=
UserInfoUtils
.
getUserName
();
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagService
.
queryPersonalTagExcludeOpenTypeAsTree
(
parentId
,
userName
,
dept
);
if
(
StringUtils
.
isBlank
(
deptIdPath
))
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
return
tagService
.
queryPersonalTagExcludeOpenTypeAsTree
(
parentId
,
userName
,
deptIdPath
);
}
@ApiOperation
(
value
=
"搜索系統标签"
,
notes
=
"搜索系統标签"
)
...
...
@@ -100,14 +109,17 @@ public class TagCtrl {
@ApiOperation
(
value
=
"搜索维度标签里面的个人标签"
,
notes
=
"搜索维度标签里面的个人标签"
)
@GetMapping
(
value
=
"/searchPersonalDimensionTagByPage"
)
public
Page
searchPersonalDimensionTagByPage
(
@RequestParam
(
required
=
false
,
value
=
"keyword"
)
String
keyword
,
public
Page
searchPersonalDimensionTagByPage
(
@RequestParam
(
required
=
false
,
value
=
"keyword"
)
String
keyword
,
@RequestParam
(
required
=
false
,
value
=
"domain"
)
Integer
domain
,
@RequestParam
(
required
=
false
,
value
=
"deptIdPath"
)
String
deptIdPath
,
@RequestParam
(
required
=
false
,
value
=
"path"
)
String
path
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
)
{
String
userName
=
UserInfoUtils
.
getUserName
();
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagService
.
searchPersonalDimensionTagByPage
(
userName
,
dept
,
keyword
,
path
,
domain
,
new
Page
(
pageSize
,
pageNo
));
if
(
StringUtils
.
isBlank
(
deptIdPath
))
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
return
tagService
.
searchPersonalDimensionTagByPage
(
userName
,
deptIdPath
,
keyword
,
path
,
domain
,
new
Page
(
pageSize
,
pageNo
));
}
@ApiOperation
(
value
=
"搜索个人标签"
,
notes
=
"搜索个人标签"
)
...
...
@@ -115,11 +127,13 @@ public class TagCtrl {
public
Page
searchPersonalTagByPage
(
@RequestParam
(
required
=
false
,
value
=
"keyword"
)
String
keyword
,
@RequestParam
(
required
=
false
,
value
=
"domain"
)
Integer
domain
,
@RequestParam
(
required
=
false
,
value
=
"path"
)
String
path
,
@RequestParam
(
required
=
false
,
value
=
"deptIdPath"
)
String
deptIdPath
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
)
{
String
userName
=
UserInfoUtils
.
getUserName
();
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagService
.
searchPersonalTagByPage
(
userName
,
dept
,
keyword
,
path
,
domain
,
new
Page
(
pageSize
,
pageNo
));
if
(
StringUtils
.
isBlank
(
deptIdPath
))
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
return
tagService
.
searchPersonalTagByPage
(
userName
,
deptIdPath
,
keyword
,
path
,
domain
,
new
Page
(
pageSize
,
pageNo
));
}
@ApiOperation
(
value
=
"分享标签"
,
notes
=
"分享标签"
)
...
...
src/main/java/com/keymobile/tagmanager/api/TagFileCtrl.java
View file @
0c7ad044
...
...
@@ -2,6 +2,7 @@ package com.keymobile.tagmanager.api;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -25,24 +26,33 @@ public class TagFileCtrl {
private
TagFileService
tagExportService
;
@GetMapping
(
"/exportTag"
)
public
int
export
(
HttpServletResponse
response
)
{
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagExportService
.
exportExcel
(
dept
,
response
);
public
int
export
(
HttpServletResponse
response
,
@RequestParam
(
required
=
false
,
value
=
"deptIdPath"
)
String
deptIdPath
)
{
if
(
StringUtils
.
isBlank
(
deptIdPath
))
{
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
}
return
tagExportService
.
exportExcel
(
deptIdPath
,
response
);
}
@PostMapping
(
"/importTag"
)
public
String
importExcel
(
MultipartFile
file
,
HttpServletResponse
response
)
throws
Exception
{
public
String
importExcel
(
MultipartFile
file
,
HttpServletResponse
response
,
@RequestParam
(
required
=
false
,
value
=
"deptIdPath"
)
String
deptIdPath
)
throws
Exception
{
String
userName
=
UserInfoUtils
.
getUserName
();
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagExportService
.
importExcel
(
userName
,
dept
,
file
);
if
(
StringUtils
.
isBlank
(
deptIdPath
))
{
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
}
return
tagExportService
.
importExcel
(
userName
,
deptIdPath
,
file
);
}
@ApiOperation
(
value
=
"分页获取导入日志"
,
notes
=
"分页获取导入日志"
)
@GetMapping
(
value
=
"/listImportTagLogByPage"
)
public
Page
searchPersonalDimensionTagByPage
(
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
public
Page
searchPersonalDimensionTagByPage
(
@RequestParam
(
required
=
false
,
value
=
"deptIdPath"
)
String
deptIdPath
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
)
{
String
dept
=
UserInfoUtils
.
getUserDept
();
return
tagExportService
.
listImportlogByPage
(
dept
,
new
Page
(
pageSize
,
pageNo
));
if
(
StringUtils
.
isBlank
(
deptIdPath
))
{
deptIdPath
=
UserInfoUtils
.
getUserCompanyIdPath
();
}
return
tagExportService
.
listImportlogByPage
(
deptIdPath
,
new
Page
(
pageSize
,
pageNo
));
}
@ApiOperation
(
value
=
"撤销导入"
,
notes
=
"撤销导入"
)
...
...
src/main/java/com/keymobile/tagmanager/model/ImportLog.java
View file @
0c7ad044
...
...
@@ -33,6 +33,7 @@ public class ImportLog implements Serializable {
private
String
report
;
private
boolean
hasFinish
=
false
;
private
String
type
=
Constants
.
COMMON_TAG_LOG_TYPE
;
private
String
dept
;
@Transient
...
...
@@ -76,6 +77,14 @@ public class ImportLog implements Serializable {
}
public
void
setDept
(
String
dept
)
{
this
.
dept
=
dept
;
}
public
String
getDept
()
{
return
dept
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
...
...
src/main/java/com/keymobile/tagmanager/service/TagFileService.java
View file @
0c7ad044
...
...
@@ -44,7 +44,8 @@ public class TagFileService {
private
TagRepository
tagRepository
;
public
int
exportExcel
(
String
dept
,
HttpServletResponse
response
)
{
List
<
Tag
>
toExportTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"dept"
).
is
(
dept
)),
Tag
.
class
);
List
<
Tag
>
toExportTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"dept"
).
is
(
dept
)
.
and
(
"dimensionType"
).
is
(
Constants
.
TAG_DIMENSION_TRUE
)),
Tag
.
class
);
// 导出操作
ExcelUtils
.
exportExcel
(
toExportTags
,
null
,
"sheet1"
,
Tag
.
class
,
"标签.xlsx"
,
response
);
return
toExportTags
.
size
();
...
...
@@ -53,6 +54,7 @@ public class TagFileService {
public
String
importExcel
(
String
userName
,
String
dept
,
MultipartFile
file
)
throws
Exception
{
ImportLog
importLog
=
new
ImportLog
(
UUID
.
randomUUID
().
toString
());
importLog
.
setCreator
(
userName
);
importLog
.
setDept
(
dept
);
mongoOperations
.
save
(
importLog
);
new
Thread
(
new
ExcelImportExecutor
(
userName
,
dept
,
file
,
importLog
)).
start
();
return
"ok"
;
...
...
@@ -152,7 +154,7 @@ public class TagFileService {
@Override
public
void
run
()
{
List
<
Tag
>
dimensionTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"dept"
).
is
(
dept
)),
Criteria
.
where
(
"dept"
).
is
(
dept
)
.
and
(
"dimensionType"
).
is
(
Constants
.
TAG_DIMENSION_TRUE
)
),
Tag
.
class
);
Map
<
String
,
Tag
>
pathTags
=
dimensionTags
.
stream
().
collect
(
Collectors
.
toMap
(
Tag:
:
getPath
,
tag
->
tag
));
try
{
...
...
src/main/java/com/keymobile/tagmanager/util/Constants.java
View file @
0c7ad044
...
...
@@ -89,5 +89,8 @@ public final class Constants {
public
static
final
String
ORG_QUERY_SQL
=
"select SPP_ID, SUBSPP_TYPE, SUBSPP_NAM, SUBSPP_ID FROM DIM_SUBSPP"
;
public
static
final
String
DEPT_DEFAULT_ID_PATH
=
"4285,4287"
;
public
static
final
String
DEPT_DEFAULT_SEPERATOR
=
","
;
}
src/main/java/com/keymobile/tagmanager/util/UserInfoUtils.java
View file @
0c7ad044
...
...
@@ -42,10 +42,31 @@ public class UserInfoUtils {
return
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
)[
0
];
}
public
static
String
getUserDept
()
{
return
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
)[
0
];
public
static
String
getUserCompanyIdPath
()
{
if
(
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
).
length
>
5
)
{
String
deptIdPath
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
)[
5
];
String
[]
ids
=
deptIdPath
.
split
(
Constants
.
DEPT_DEFAULT_SEPERATOR
);
if
(
ids
.
length
==
1
)
{
return
deptIdPath
;
}
else
{
return
ids
[
0
]
+
Constants
.
DEPT_DEFAULT_SEPERATOR
+
ids
[
1
];
}
}
return
Constants
.
DEPT_DEFAULT_ID_PATH
;
}
public
static
String
getUserDeptIdPath
()
{
if
(
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
).
length
>
5
)
{
return
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
)[
5
];
}
return
Constants
.
DEPT_DEFAULT_ID_PATH
;
}
// public static String getUserDeptIdPath() {
// return SecurityContextHolder.getContext().getAuthentication().getName().split(":")[5];
// }
public
static
Integer
getUserId
()
{
return
Integer
.
valueOf
(
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
().
split
(
":"
)[
1
]);
}
...
...
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