Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
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
base_platform_enterprise
gic-platform-auth
Commits
9b326e2b
Commit
9b326e2b
authored
Jan 27, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
审核员接口调整:区分是否关联管理员
parent
27f80c26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
54 deletions
+61
-54
AuditorApiServiceImpl.java
...om/gic/auth/service/outer/impl/AuditorApiServiceImpl.java
+61
-54
No files found.
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/AuditorApiServiceImpl.java
View file @
9b326e2b
...
...
@@ -31,10 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -74,16 +71,7 @@ public class AuditorApiServiceImpl implements AuditorApiService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ServiceResponse
<
String
>
saveOrUpdateAuditor
(
AuditorDTO
auditorDTO
)
{
//是否是关联管理员,如果是,则姓名和手机号取自管理员信息
Integer
userId
=
auditorDTO
.
getUserId
();
boolean
isRelationUser
=
userId
!=
null
;
if
(
isRelationUser
)
{
TabSysUser
tabSysUser
=
userService
.
getUserById
(
userId
);
if
(
tabSysUser
!=
null
)
{
auditorDTO
.
setPhone
(
tabSysUser
.
getPhoneNumber
());
auditorDTO
.
setAuditorName
(
tabSysUser
.
getUserName
());
}
}
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
boolean
nameIsRepeat
=
auditorService
.
validAuditorNameIsRepeat
(
auditorDTO
.
getEnterpriseId
(),
auditorDTO
.
getAuditorName
(),
auditorDTO
.
getAuditorId
());
if
(
nameIsRepeat
)
{
...
...
@@ -168,9 +156,6 @@ public class AuditorApiServiceImpl implements AuditorApiService {
return
EnterpriseServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
);
}
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
//是否是关联管理员,如果是,则姓名和手机号取自管理员信息
Integer
userId
=
auditorDTO
.
getUserId
();
boolean
isRelationUser
=
userId
!=
null
;
List
<
TabAuditorProjectItemRel
>
projectList
=
auditorProjectItemRelService
.
listRelByAuditorId
(
auditorId
);
if
(
CollectionUtils
.
isNotEmpty
(
projectList
))
{
...
...
@@ -182,28 +167,8 @@ public class AuditorApiServiceImpl implements AuditorApiService {
List
<
Integer
>
groupIds
=
groupList
.
stream
().
map
(
TabAuditorAuditedGroupRel:
:
getAuditedGroupId
).
collect
(
Collectors
.
toList
());
auditorDTO
.
setAuditedGroupIdList
(
groupIds
);
}
//二维码链接
String
codeUrl
;
if
(
isRelationUser
)
{
codeUrl
=
QrcodeUtils
.
getTempQrCodeUrl
(
QrcodeTypeEnum
.
USER
.
getCode
(),
userId
,
auditor
.
getEnterpriseId
());
}
else
{
codeUrl
=
QrcodeUtils
.
getTempQrCodeUrl
(
QrcodeTypeEnum
.
AUDITOR
.
getCode
(),
auditorId
,
auditor
.
getEnterpriseId
());
}
auditorDTO
.
setQrcodeUrl
(
codeUrl
);
//微信用户数据
String
openId
=
auditor
.
getOpenid
();
if
(
isRelationUser
)
{
TabSysUser
tabSysUser
=
userService
.
getUserById
(
userId
);
if
(
tabSysUser
!=
null
)
{
openId
=
tabSysUser
.
getOpenId
();
}
}
WechatUserDTO
wechatUserDTO
=
QrcodeUtils
.
getMemberInfoByOpenId
(
openId
);
if
(
wechatUserDTO
!=
null
)
{
auditorDTO
.
setWeChatNickName
(
wechatUserDTO
.
getNickname
());
auditorDTO
.
setHeadUrl
(
wechatUserDTO
.
getHeadimgurl
());
}
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
setWeChatInfo
(
auditorDTO
);
return
ServiceResponse
.
success
(
auditorDTO
);
}
...
...
@@ -214,25 +179,14 @@ public class AuditorApiServiceImpl implements AuditorApiService {
Page
<
AuditorDTO
>
resultPage
=
PageHelperUtils
.
changePageHelperToCurrentPage
(
page
,
AuditorDTO
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
resultPage
.
getResult
()))
{
List
<
Integer
>
auditorIdList
=
resultPage
.
getResult
().
stream
().
map
(
AuditorDTO:
:
getAuditorId
).
collect
(
Collectors
.
toList
());
//查询关联的管理员手机号和名称
List
<
Integer
>
userIdList
=
resultPage
.
getResult
().
stream
().
filter
(
e
->
e
.
getUserId
()
!=
null
).
map
(
AuditorDTO:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
TabSysUser
>
userList
=
userService
.
listUserByIdList
(
userIdList
);
Map
<
Integer
,
TabSysUser
>
userMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
userMap
=
userList
.
stream
().
collect
(
Collectors
.
toMap
(
e
->
e
.
getUserId
(),
e
->
e
));
}
Map
<
Integer
,
Integer
>
projectItemMap
=
auditorProjectItemRelService
.
getCountByAuditorIds
(
auditorIdList
);
Map
<
Integer
,
Integer
>
userCountMap
=
auditorAuditedGroupRelService
.
getUserCountByAuditorIds
(
auditorIdList
);
for
(
AuditorDTO
auditorDTO
:
resultPage
.
getResult
())
{
auditorDTO
.
setProjectItemCount
(
projectItemMap
.
get
(
auditorDTO
.
getAuditorId
()));
auditorDTO
.
setAuditedGroupCount
(
userCountMap
.
get
(
auditorDTO
.
getAuditorId
()));
TabSysUser
user
=
userMap
.
get
(
auditorDTO
.
getAuditorId
());
if
(
user
!=
null
)
{
auditorDTO
.
setPhone
(
user
.
getPhoneNumber
());
auditorDTO
.
setAuditorName
(
user
.
getUserName
());
}
}
//其中有处理重复消耗(但是为了单一指责,可重复调用)
setUserInfo
(
resultPage
.
getResult
());
}
return
ServiceResponse
.
success
(
resultPage
);
}
...
...
@@ -262,6 +216,7 @@ public class AuditorApiServiceImpl implements AuditorApiService {
List
<
Integer
>
auditorIds
=
auditorAuditedGroupRelService
.
listRelByAuditedGroupIdAndAuditId
(
enterpriseId
,
auditedGroupIds
,
projectAuditorIds
);
List
<
AuditorDTO
>
list
=
listAuditor
(
auditorIds
,
enterpriseId
);
if
(
list
!=
null
)
{
setUserInfo
(
list
);
return
ServiceResponse
.
success
(
list
);
}
}
...
...
@@ -294,6 +249,7 @@ public class AuditorApiServiceImpl implements AuditorApiService {
List
<
Integer
>
projectAuditorIds
=
auditorProjectItemRelService
.
listAuditorIdByProjectItemId
(
enterpriseId
,
projectItemId
);
List
<
AuditorDTO
>
list
=
listAuditor
(
projectAuditorIds
,
enterpriseId
);
if
(
list
!=
null
)
{
setUserInfo
(
list
);
return
ServiceResponse
.
success
(
list
);
}
AuditorDTO
adminAuditor
=
this
.
getAdminAuditor
(
enterpriseId
);
...
...
@@ -304,7 +260,9 @@ public class AuditorApiServiceImpl implements AuditorApiService {
public
ServiceResponse
<
AuditorDTO
>
getAuditorByOpenid
(
String
openid
)
{
TabAuditor
auditor
=
this
.
auditorService
.
getAuditorByOpenid
(
openid
);
if
(
auditor
!=
null
)
{
return
EnterpriseServiceResponse
.
success
(
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
));
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
return
EnterpriseServiceResponse
.
success
(
auditorDTO
);
}
else
{
return
EnterpriseServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
);
}
...
...
@@ -319,7 +277,9 @@ public class AuditorApiServiceImpl implements AuditorApiService {
@Override
public
ServiceResponse
<
AuditorDTO
>
getAuditorByUserId
(
Integer
enterpriseId
,
Integer
userId
)
{
TabAuditor
auditor
=
auditorService
.
getAuditorByUserId
(
enterpriseId
,
userId
);
return
EnterpriseServiceResponse
.
success
(
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
));
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
return
EnterpriseServiceResponse
.
success
(
auditorDTO
);
}
private
AuditorDTO
getAdminAuditor
(
Integer
enterpriseId
)
{
...
...
@@ -351,4 +311,51 @@ public class AuditorApiServiceImpl implements AuditorApiService {
}
return
null
;
}
/**
* 设置管理员的手机号和名称数据
* @param auditorList
*/
private
void
setUserInfo
(
List
<
AuditorDTO
>
auditorList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
auditorList
))
{
//查询关联的管理员手机号和名称
List
<
Integer
>
userIdList
=
auditorList
.
stream
().
filter
(
e
->
e
.
getUserId
()
!=
null
).
map
(
AuditorDTO:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
TabSysUser
>
userList
=
userService
.
listUserByIdList
(
userIdList
);
Map
<
Integer
,
TabSysUser
>
userMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
userMap
=
userList
.
stream
().
collect
(
Collectors
.
toMap
(
e
->
e
.
getUserId
(),
e
->
e
));
}
for
(
AuditorDTO
auditorDTO
:
auditorList
)
{
TabSysUser
user
=
userMap
.
get
(
auditorDTO
.
getUserId
());
if
(
user
!=
null
)
{
auditorDTO
.
setPhone
(
user
.
getPhoneNumber
());
auditorDTO
.
setAuditorName
(
user
.
getUserName
());
auditorDTO
.
setOpenid
(
user
.
getOpenId
());
}
}
}
}
/**
* 设置微信用户相关数据
* @param auditorDTO
*/
private
void
setWeChatInfo
(
AuditorDTO
auditorDTO
)
{
//是否是关联管理员,如果是,则姓名和手机号取自管理员信息
Integer
userId
=
auditorDTO
.
getUserId
();
boolean
isRelationUser
=
userId
!=
null
;
//二维码链接
String
codeUrl
;
if
(
isRelationUser
)
{
codeUrl
=
QrcodeUtils
.
getTempQrCodeUrl
(
QrcodeTypeEnum
.
USER
.
getCode
(),
userId
,
auditorDTO
.
getEnterpriseId
());
}
else
{
codeUrl
=
QrcodeUtils
.
getTempQrCodeUrl
(
QrcodeTypeEnum
.
AUDITOR
.
getCode
(),
auditorDTO
.
getAuditorId
(),
auditorDTO
.
getEnterpriseId
());
}
auditorDTO
.
setQrcodeUrl
(
codeUrl
);
WechatUserDTO
wechatUserDTO
=
QrcodeUtils
.
getMemberInfoByOpenId
(
auditorDTO
.
getOpenid
());
if
(
wechatUserDTO
!=
null
)
{
auditorDTO
.
setWeChatNickName
(
wechatUserDTO
.
getNickname
());
auditorDTO
.
setHeadUrl
(
wechatUserDTO
.
getHeadimgurl
());
}
}
}
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