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
c2b970e9
Commit
c2b970e9
authored
Jan 28, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
审批调整:管理员和审核员数据互相同步
parent
a2464baf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
41 deletions
+102
-41
AuditorApiService.java
...src/main/java/com/gic/auth/service/AuditorApiService.java
+19
-0
AuditorApiServiceImpl.java
...om/gic/auth/service/outer/impl/AuditorApiServiceImpl.java
+43
-39
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+10
-1
AuditorQrcode.java
...rc/main/java/com/gic/auth/utils/qrcode/AuditorQrcode.java
+15
-1
UserQrcode.java
...e/src/main/java/com/gic/auth/utils/qrcode/UserQrcode.java
+6
-0
AuditorController.java
...n/java/com/gic/auth/web/controller/AuditorController.java
+9
-0
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/service/AuditorApiService.java
View file @
c2b970e9
...
...
@@ -50,6 +50,13 @@ public interface AuditorApiService {
ServiceResponse
<
AuditorDTO
>
getAuditor
(
Integer
auditorId
);
/**
* 获取审核员的服务号二维码
* @param auditorId
* @return
*/
ServiceResponse
<
String
>
getQrcodeUrl
(
Integer
auditorId
);
/**
* pageAuditor
* @Title: pageAuditor
* @Description:
...
...
@@ -155,4 +162,16 @@ public interface AuditorApiService {
* @throws
*/
ServiceResponse
<
AuditorDTO
>
getAuditorByUserId
(
Integer
enterpriseId
,
Integer
userId
);
/**
* 管理员数据修改同步到审核员
* @param userId
* @param enterpriseId
* @param phone
* @param name
* @param openId
* @return
*/
ServiceResponse
<
Void
>
syncModifyNameOrPhone
(
Integer
userId
,
Integer
enterpriseId
,
String
phone
,
String
name
,
String
openId
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/AuditorApiServiceImpl.java
View file @
c2b970e9
...
...
@@ -100,8 +100,13 @@ public class AuditorApiServiceImpl implements AuditorApiService {
}
auditorDTO
.
setIsUse
(
auditorDTO
.
getUserId
()
==
null
?
0
:
1
);
// 这里进来的 不会去修改openid,所以把openid设为null
auditorDTO
.
setOpenid
(
null
);
if
(
StringUtils
.
isNotBlank
(
auditorDTO
.
getOpenid
()))
{
boolean
repeat
=
this
.
auditorService
.
validOpenidIsRepeat
(
auditorDTO
.
getEnterpriseId
(),
auditorDTO
.
getOpenid
(),
auditorDTO
.
getAuditorId
());
if
(
repeat
)
{
return
ServiceResponse
.
success
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"扫码openId重复"
);
}
}
// 保存审核员信息
if
(
auditorDTO
.
getAuditorId
()
==
null
)
{
// save
...
...
@@ -161,13 +166,23 @@ public class AuditorApiServiceImpl implements AuditorApiService {
List
<
Integer
>
groupIds
=
groupList
.
stream
().
map
(
TabAuditorAuditedGroupRel:
:
getAuditedGroupId
).
collect
(
Collectors
.
toList
());
auditorDTO
.
setAuditedGroupIdList
(
groupIds
);
}
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
setWeChatInfo
(
auditorDTO
);
return
ServiceResponse
.
success
(
auditorDTO
);
}
@Override
public
ServiceResponse
<
String
>
getQrcodeUrl
(
Integer
auditorId
)
{
TabAuditor
auditor
=
this
.
auditorService
.
getAuditor
(
auditorId
);
if
(
auditor
==
null
)
{
return
EnterpriseServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
);
}
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
setWeChatInfo
(
auditorDTO
);
return
ServiceResponse
.
success
(
auditorDTO
.
getQrcodeUrl
());
}
@Override
public
ServiceResponse
<
Page
<
AuditorDTO
>>
pageAuditor
(
AuditorListQO
auditorListQO
)
{
com
.
github
.
pagehelper
.
Page
<
TabAuditor
>
page
=
this
.
auditorService
.
pageAuditor
(
auditorListQO
);
Page
<
AuditorDTO
>
resultPage
=
PageHelperUtils
.
changePageHelperToCurrentPage
(
page
,
AuditorDTO
.
class
);
...
...
@@ -179,8 +194,6 @@ public class AuditorApiServiceImpl implements AuditorApiService {
auditorDTO
.
setProjectItemCount
(
projectItemMap
.
get
(
auditorDTO
.
getAuditorId
()));
auditorDTO
.
setAuditedGroupCount
(
userCountMap
.
get
(
auditorDTO
.
getAuditorId
()));
}
//其中有处理重复消耗(但是为了单一指责,可重复调用)
setUserInfo
(
resultPage
.
getResult
());
}
return
ServiceResponse
.
success
(
resultPage
);
}
...
...
@@ -210,7 +223,6 @@ 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
);
}
}
...
...
@@ -243,7 +255,6 @@ 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
);
...
...
@@ -256,29 +267,9 @@ public class AuditorApiServiceImpl implements AuditorApiService {
if
(
auditor
!=
null
)
{
//如果查询到数据
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
//
if
(!
Objects
.
equals
(
openid
,
auditorDTO
.
getOpenid
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"openId:"
+
openid
+
"错误"
);
}
return
EnterpriseServiceResponse
.
success
(
auditorDTO
);
}
else
{
//如果查询不到,则去查询用户列表
TabSysUser
user
=
userService
.
getUserByOpenId
(
openid
,
enterpriseId
);
if
(
user
!=
null
)
{
TabAuditor
auditorByUserId
=
auditorService
.
getAuditorByUserId
(
user
.
getEnterpriseId
(),
user
.
getUserId
());
if
(
auditorByUserId
!=
null
)
{
//如果有值,则数据正确
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditorByUserId
);
auditorDTO
.
setOpenid
(
user
.
getOpenId
());
auditorDTO
.
setPhone
(
user
.
getPhoneNumber
());
auditorDTO
.
setAuditorName
(
user
.
getUserName
());
return
EnterpriseServiceResponse
.
success
(
auditorDTO
);
}
}
return
EnterpriseServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
);
}
return
EnterpriseServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
);
}
@Override
...
...
@@ -294,10 +285,32 @@ public class AuditorApiServiceImpl implements AuditorApiService {
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"查询不到审核员数据"
);
}
AuditorDTO
auditorDTO
=
EntityUtil
.
changeEntityByJSON
(
AuditorDTO
.
class
,
auditor
);
setUserInfo
(
Arrays
.
asList
(
auditorDTO
));
return
EnterpriseServiceResponse
.
success
(
auditorDTO
);
}
@Override
public
ServiceResponse
<
Void
>
syncModifyNameOrPhone
(
Integer
userId
,
Integer
enterpriseId
,
String
phone
,
String
name
,
String
openId
)
{
logger
.
info
(
"管理员:{}修改同步到审核员参数:{},{},{},{}"
,
userId
,
enterpriseId
,
phone
,
name
,
openId
);
TabAuditor
auditor
=
auditorService
.
getAuditorByUserId
(
enterpriseId
,
userId
);
if
(
auditor
!=
null
)
{
//如果有变化,则更新
if
(
StringUtils
.
isNotBlank
(
phone
)
&&
!
Objects
.
equals
(
auditor
.
getPhone
(),
phone
))
{
auditor
.
setPhone
(
phone
);
}
if
(
StringUtils
.
isNotBlank
(
name
)
&&
!
Objects
.
equals
(
auditor
.
getAuditorName
(),
name
))
{
auditor
.
setAuditorName
(
name
);
}
if
(
StringUtils
.
isNotBlank
(
openId
)
&&
!
Objects
.
equals
(
auditor
.
getOpenid
(),
openId
))
{
boolean
repeat
=
this
.
auditorService
.
validOpenidIsRepeat
(
auditor
.
getEnterpriseId
(),
openId
,
auditor
.
getAuditorId
());
if
(!
repeat
)
{
auditor
.
setOpenid
(
openId
);
}
}
auditorService
.
update
(
EntityUtil
.
changeEntityNew
(
AuditorDTO
.
class
,
auditor
));
}
return
ServiceResponse
.
success
();
}
private
AuditorDTO
getAdminAuditor
(
Integer
enterpriseId
)
{
TabSysUser
adminUser
=
userService
.
getUserByEnterpriseId
(
enterpriseId
);
TabAuditor
auditor
=
auditorService
.
getAuditorByUserId
(
enterpriseId
,
adminUser
.
getUserId
());
...
...
@@ -357,16 +370,7 @@ public class AuditorApiServiceImpl implements AuditorApiService {
* @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
());
}
String
codeUrl
=
QrcodeUtils
.
getTempQrCodeUrl
(
QrcodeTypeEnum
.
AUDITOR
.
getCode
(),
auditorDTO
.
getAuditorId
(),
auditorDTO
.
getEnterpriseId
());
auditorDTO
.
setQrcodeUrl
(
codeUrl
);
WechatUserDTO
wechatUserDTO
=
QrcodeUtils
.
getMemberInfoByOpenId
(
auditorDTO
.
getOpenid
());
if
(
wechatUserDTO
!=
null
)
{
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
c2b970e9
...
...
@@ -65,6 +65,8 @@ public class UserApiServiceImpl implements UserApiService {
private
AuditedGroupUserRelService
auditedGroupUserRelService
;
@Autowired
private
UserMoveApiService
userMoveApiService
;
@Autowired
private
AuditorApiService
auditorApiService
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
...
...
@@ -244,6 +246,9 @@ public class UserApiServiceImpl implements UserApiService {
accountGroupRelService
.
deleteByUserId
(
userDTO
.
getUserId
(),
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
}
//同步审核员
auditorApiService
.
syncModifyNameOrPhone
(
userDTO
.
getUserId
(),
tabUser
.
getEnterpriseId
(),
userDTO
.
getPhoneNumber
(),
userDTO
.
getUserName
(),
null
);
ServiceResponse
response
=
saveRole
(
userDTO
.
getUserId
(),
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
(),
userDTO
.
getAccountGroupIds
());
if
(
response
.
isSuccess
())
{
...
...
@@ -371,6 +376,7 @@ public class UserApiServiceImpl implements UserApiService {
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ServiceResponse
<
String
>
delete
(
Integer
userId
)
{
TabSysUser
tabUser
=
userService
.
getUserById
(
userId
);
if
(
tabUser
==
null
)
{
...
...
@@ -393,7 +399,7 @@ public class UserApiServiceImpl implements UserApiService {
userResourceService
.
deleteByUserId
(
userId
);
//删除账号分组关联
accountGroupRelService
.
deleteByUserId
(
userId
,
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
//
//
受审组
auditedGroupUserRelService
.
deleteByUserId
(
userId
);
userService
.
delete
(
userId
);
return
ServiceResponse
.
success
(
tabUser
.
getUserName
());
...
...
@@ -568,6 +574,9 @@ public class UserApiServiceImpl implements UserApiService {
userDTO
.
setPhoneAreaCode
(
nationCode
);
userDTO
.
setPassword
(
password
);
userService
.
editUser
(
userDTO
);
//同步审核员
auditorApiService
.
syncModifyNameOrPhone
(
userId
,
tabUser
.
getEnterpriseId
(),
phone
,
null
,
null
);
return
ServiceResponse
.
success
(
tabUser
.
getUserName
());
}
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/utils/qrcode/AuditorQrcode.java
View file @
c2b970e9
package
com
.
gic
.
auth
.
utils
.
qrcode
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.auth.service.UserService
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,13 +23,17 @@ public class AuditorQrcode implements IQrcode{
private
static
Logger
logger
=
LogManager
.
getLogger
(
AuditorQrcode
.
class
);
@Autowired
private
AuditorService
auditorService
;
@Autowired
private
UserApiService
userApiService
;
@Autowired
private
UserService
userService
;
@Override
public
void
receiveOpenId
(
String
customParams
,
String
openid
)
{
Integer
auditorId
=
Integer
.
valueOf
(
customParams
);
TabAuditor
auditor
=
this
.
auditorService
.
getAuditor
(
auditorId
);
if
(
auditor
!=
null
)
{
boolean
repeat
=
this
.
auditorService
.
validOpenidIsRepeat
(
auditor
.
getEnterpriseId
(),
openid
,
null
);
boolean
repeat
=
this
.
auditorService
.
validOpenidIsRepeat
(
auditor
.
getEnterpriseId
(),
openid
,
auditor
.
getAuditorId
()
);
if
(
repeat
)
{
logger
.
warn
(
"receiveOpenid失败,商户:{}下,存在重复的openid:{}"
,
auditor
.
getEnterpriseId
(),
openid
);
}
else
{
...
...
@@ -36,6 +42,14 @@ public class AuditorQrcode implements IQrcode{
auditorDTO
.
setOpenid
(
openid
);
auditorDTO
.
setIsUse
(
1
);
this
.
auditorService
.
update
(
auditorDTO
);
//同步到管理员,如果是管理管理员
if
(
auditor
.
getUserId
()
!=
null
)
{
boolean
isRepeat
=
userService
.
validOpenidIsRepeat
(
auditor
.
getEnterpriseId
(),
openid
,
auditor
.
getUserId
());
if
(!
isRepeat
)
{
userApiService
.
updateUserOpenId
(
auditor
.
getUserId
(),
openid
);
}
}
}
}
}
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/utils/qrcode/UserQrcode.java
View file @
c2b970e9
package
com
.
gic
.
auth
.
utils
.
qrcode
;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.service.AuditorApiService
;
import
com.gic.auth.service.AuditorService
;
import
com.gic.auth.service.UserService
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -23,6 +25,8 @@ public class UserQrcode implements IQrcode{
private
UserApiService
userApiService
;
@Autowired
private
UserService
userService
;
@Autowired
private
AuditorApiService
auditorApiService
;
@Override
public
void
receiveOpenId
(
String
customParams
,
String
openid
)
{
...
...
@@ -33,6 +37,8 @@ public class UserQrcode implements IQrcode{
logger
.
warn
(
"receiveOpenid失败,商户:{}下,存在重复的openid:{}"
,
user
.
getEnterpriseId
(),
openid
);
}
else
{
userApiService
.
updateUserOpenId
(
Integer
.
parseInt
(
customParams
),
openid
);
//同步到审核员
auditorApiService
.
syncModifyNameOrPhone
(
user
.
getUserId
(),
user
.
getEnterpriseId
(),
null
,
null
,
openid
);
}
}
}
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/AuditorController.java
View file @
c2b970e9
...
...
@@ -69,6 +69,15 @@ public class AuditorController {
return
ResultControllerUtils
.
commonResult
(
response
);
}
/**
* 换绑
* @return
*/
@RequestMapping
(
"/auditor-qrcode"
)
public
RestResponse
changeBind
(
Integer
auditorId
)
{
return
ResultControllerUtils
.
commonResult
(
auditorApiService
.
getQrcodeUrl
(
auditorId
));
}
@RequestMapping
(
"/get-auditor"
)
public
RestResponse
getAuditor
(
Integer
auditorId
)
{
ServiceResponse
<
AuditorDTO
>
response
=
auditorApiService
.
getAuditor
(
auditorId
);
...
...
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