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
9aee63ec
Commit
9aee63ec
authored
Dec 18, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
0aee91fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
10 deletions
+39
-10
AppUserRelationBiz.java
...github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
+39
-10
No files found.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
View file @
9aee63ec
...
@@ -62,7 +62,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
...
@@ -62,7 +62,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
private
AppStaffUserBiz
staffUserBiz
;
private
AppStaffUserBiz
staffUserBiz
;
private
static
final
HashMap
<
Integer
,
Boolean
>
map
=
new
HashMap
<>();
private
static
final
HashMap
<
Integer
,
Boolean
>
map
=
new
HashMap
<>();
private
static
final
HashMap
<
Integer
,
Boolean
>
parentMap
=
new
HashMap
<>();
private
static
final
Object
obj
=
new
Object
();
private
static
final
Object
obj
=
new
Object
();
private
static
final
Object
parentObj
=
new
Object
();
private
boolean
lock
(
Integer
userId
)
{
private
boolean
lock
(
Integer
userId
)
{
synchronized
(
obj
)
{
synchronized
(
obj
)
{
...
@@ -73,6 +75,21 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
...
@@ -73,6 +75,21 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
}
}
return
false
;
return
false
;
}
}
private
boolean
parentLock
(
Integer
userId
)
{
synchronized
(
parentObj
)
{
if
(
parentMap
.
get
(
userId
)
==
null
)
{
parentMap
.
put
(
userId
,
true
);
return
true
;
}
}
return
false
;
}
private
void
unParentLock
(
Integer
userId
)
{
synchronized
(
parentObj
)
{
parentMap
.
remove
(
userId
);
}
}
private
void
unLock
(
Integer
userId
)
{
private
void
unLock
(
Integer
userId
)
{
synchronized
(
obj
)
{
synchronized
(
obj
)
{
...
@@ -108,10 +125,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
...
@@ -108,10 +125,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
AppUserRelation
relation
=
getMyBiz
().
getRelationByUserId
(
parentId
);
AppUserRelation
relation
=
getMyBiz
().
getRelationByUserId
(
parentId
);
Long
time
=
System
.
currentTimeMillis
();
Long
time
=
System
.
currentTimeMillis
();
if
(
relation
==
null
)
{
if
(
relation
==
null
)
{
relation
=
new
AppUserRelation
();
insertLock
(
parentId
,
type
);
relation
.
setUserId
(
parentId
);
relation
.
setBindType
(
type
);
insertSelective
(
relation
);
}
}
Long
bindTime
=
time
-
validTime
;
Long
bindTime
=
time
-
validTime
;
//判断用户是否有有效的下线
//判断用户是否有有效的下线
...
@@ -124,12 +138,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
...
@@ -124,12 +138,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
relation
.
setBindType
(
type
);
relation
.
setBindType
(
type
);
relation
.
setBindTime
(
time
);
relation
.
setBindTime
(
time
);
insertSelective
(
relation
);
insertSelective
(
relation
);
if
(
relation
!=
null
)
{
AppStaffUserDTO
staffUserDTO
=
new
AppStaffUserDTO
();
AppStaffUserDTO
staffUserDTO
=
new
AppStaffUserDTO
();
staffUserDTO
.
setSuId
(
relation
.
getParentId
());
staffUserDTO
.
setSuId
(
relation
.
getParentId
());
staffUserDTO
.
setUid
(
relation
.
getUserId
());
staffUserDTO
.
setUid
(
relation
.
getUserId
());
staffUserBiz
.
addAppStaffUser
(
staffUserDTO
);
staffUserBiz
.
addAppStaffUser
(
staffUserDTO
);
}
}
else
{
}
else
{
//判断用户是否有有效的上线
//判断用户是否有有效的上线
log
.
info
(
"----userId==="
+
userId
+
"----bindTime===="
+
bindTime
+
"----relation.getBindTime()==="
+
relation
.
getBindTime
());
log
.
info
(
"----userId==="
+
userId
+
"----bindTime===="
+
bindTime
+
"----relation.getBindTime()==="
+
relation
.
getBindTime
());
...
@@ -150,6 +162,23 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
...
@@ -150,6 +162,23 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
}
}
private
void
insertLock
(
Integer
userId
,
Integer
type
)
{
try
{
if
(
parentLock
(
userId
))
{
AppUserRelation
relation
=
getMyBiz
().
getRelationByUserId
(
userId
);
if
(
relation
==
null
)
{
relation
=
new
AppUserRelation
();
relation
.
setUserId
(
userId
);
relation
.
setBindType
(
type
);
insertSelective
(
relation
);
}
}
}
catch
(
Exception
e
){
}
finally
{
unParentLock
(
userId
);
}
}
//首页关系绑定
//首页关系绑定
public
ObjectRestResponse
appBindRelation
(
Integer
userId
,
String
code
)
{
public
ObjectRestResponse
appBindRelation
(
Integer
userId
,
String
code
)
{
Integer
parentId
=
0
;
Integer
parentId
=
0
;
...
...
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