Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
00c4f321
Commit
00c4f321
authored
Dec 18, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
a33ec3c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
28 deletions
+52
-28
AppUserRelationBiz.java
...github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
+52
-28
No files found.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
View file @
00c4f321
...
...
@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.admin.vo.InviteMemberVo;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.sun.corba.se.impl.orbutil.concurrent.Sync
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -60,6 +61,25 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
@Autowired
private
AppStaffUserBiz
staffUserBiz
;
private
static
final
HashMap
<
Integer
,
Boolean
>
map
=
new
HashMap
<>();
private
static
final
Object
obj
=
new
Object
();
private
boolean
lock
(
Integer
userId
)
{
synchronized
(
obj
)
{
if
(
map
.
get
(
userId
)
==
null
)
{
map
.
put
(
userId
,
true
);
return
true
;
}
}
return
false
;
}
private
void
unLock
(
Integer
userId
)
{
synchronized
(
obj
)
{
map
.
remove
(
userId
);
}
}
/**
* 关系绑定
* 规则A->B (B无有效上线+无有效下线)
...
...
@@ -84,44 +104,48 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
log
.
info
(
"----userId==="
+
userId
+
"----parentId===="
+
parentId
+
"----该上线用户不存在"
);
return
;
}
AppUserRelation
relation
=
getMyBiz
().
getRelationByUserId
(
parentId
);
Long
time
=
System
.
currentTimeMillis
();
if
(
relation
==
null
){
relation
=
new
AppUserRelation
();
relation
.
setUserId
(
parentId
);
relation
.
setBindType
(
type
);
insertSelective
(
relation
);
}
Long
bindTime
=
time
-
validTime
;
//判断用户是否有有效的下线
if
(
getCountByParentId
(
userId
,
bindTime
)==
0L
){
relation
=
getMyBiz
().
getRelationByUserId
(
userId
);
if
(
relation
==
null
){
relation
=
new
AppUserRelation
();
relation
.
setUserId
(
userId
);
relation
.
setParentId
(
parentId
);
if
(
lock
(
userId
))
{
AppUserRelation
relation
=
getMyBiz
().
getRelationByUserId
(
parentId
);
Long
time
=
System
.
currentTimeMillis
();
if
(
relation
==
null
)
{
relation
=
new
AppUserRelation
();
relation
.
setUserId
(
parentId
);
relation
.
setBindType
(
type
);
relation
.
setBindTime
(
time
);
insertSelective
(
relation
);
}
else
{
//判断用户是否有有效的上线
log
.
info
(
"----userId==="
+
userId
+
"----bindTime===="
+
bindTime
+
"----relation.getBindTime()==="
+
relation
.
getBindTime
());
if
(
relation
.
getParentId
()==
null
||
relation
.
getParentId
()==
0
||(
relation
.
getIsForever
()!=
1
&&
validTime
>
0
&&
relation
.
getBindTime
()<
bindTime
)){
}
Long
bindTime
=
time
-
validTime
;
//判断用户是否有有效的下线
if
(
getCountByParentId
(
userId
,
bindTime
)
==
0L
)
{
relation
=
getMyBiz
().
getRelationByUserId
(
userId
);
if
(
relation
==
null
)
{
relation
=
new
AppUserRelation
();
relation
.
setUserId
(
userId
);
relation
.
setParentId
(
parentId
);
relation
.
setBindType
(
type
);
relation
.
setBindTime
(
time
);
getMyBiz
().
updRelation
(
relation
);
insertSelective
(
relation
);
if
(
relation
!=
null
)
{
AppStaffUserDTO
staffUserDTO
=
new
AppStaffUserDTO
();
staffUserDTO
.
setSuId
(
relation
.
getParentId
());
staffUserDTO
.
setUid
(
relation
.
getUserId
());
staffUserBiz
.
addAppStaffUser
(
staffUserDTO
);
}
}
else
{
//判断用户是否有有效的上线
log
.
info
(
"----userId==="
+
userId
+
"----bindTime===="
+
bindTime
+
"----relation.getBindTime()==="
+
relation
.
getBindTime
());
if
(
relation
.
getParentId
()
==
null
||
relation
.
getParentId
()
==
0
||
(
relation
.
getIsForever
()
!=
1
&&
validTime
>
0
&&
relation
.
getBindTime
()
<
bindTime
))
{
relation
.
setParentId
(
parentId
);
relation
.
setBindType
(
type
);
relation
.
setBindTime
(
time
);
getMyBiz
().
updRelation
(
relation
);
}
}
}
if
(
relation
!=
null
){
AppStaffUserDTO
staffUserDTO
=
new
AppStaffUserDTO
();
staffUserDTO
.
setSuId
(
relation
.
getParentId
());
staffUserDTO
.
setUid
(
relation
.
getUserId
());
staffUserBiz
.
addAppStaffUser
(
staffUserDTO
);
}
}
}
catch
(
Exception
e
){
log
.
info
(
"网络异常==="
+
e
.
getMessage
());
}
finally
{
unLock
(
userId
);
}
}
...
...
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