Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
e37ea877
Commit
e37ea877
authored
Nov 29, 2021
by
guangjing.gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
校验是否羊小咩租户
parent
ce324a54
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
26 deletions
+70
-26
UserController.java
...oup/xyqb/controller/middleoffice/user/UserController.java
+4
-1
IProductLoginRepository.java
...n/quantgroup/xyqb/repository/IProductLoginRepository.java
+2
-0
IProductLoginService.java
...cn/quantgroup/xyqb/service/user/IProductLoginService.java
+2
-0
ProductLoginServiceImpl.java
...group/xyqb/service/user/impl/ProductLoginServiceImpl.java
+12
-0
TenantServiceImpl.java
.../quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
+32
-17
UserCenterServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
+18
-8
No files found.
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/user/UserController.java
View file @
e37ea877
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.event.DisableActiveEvent;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.TenantUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -15,6 +16,7 @@ import java.util.Map;
/**
* 用户信息
*/
@Slf4j
@RestController
(
"middleUserController"
)
@RequestMapping
(
"/middle_office/user"
)
public
class
UserController
{
...
...
@@ -85,10 +87,11 @@ public class UserController {
*/
@PostMapping
(
"/getByUuidsOrUserIds"
)
public
JsonResult
getByUuidsOrUserIds
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
log
.
info
(
"根据uuid或者userids 获取用户信息 {}"
,
params
);
List
<
String
>
vals
=
(
List
<
String
>)
params
.
get
(
"vals"
);
Integer
type
=
(
Integer
)
params
.
get
(
"type"
);
Integer
tenantId
=
Integer
.
valueOf
(
String
.
valueOf
(
params
.
get
(
"tenantId"
)));
if
(
type
==
null
||
(
type
!=
1
&&
type
!=
2
))
{
return
JsonResult
.
buildErrorStateResult
(
"type错误"
,
null
);
}
...
...
src/main/java/cn/quantgroup/xyqb/repository/IProductLoginRepository.java
View file @
e37ea877
...
...
@@ -19,8 +19,10 @@ public interface IProductLoginRepository extends JpaRepository<ProductLoginEntit
ProductLoginEntity
findFirstByPhoneNo
(
String
phoneNo
);
ProductLoginEntity
findByInstitutionIdAndProductIdAndExtensionAccountId
(
String
institutionId
,
String
productId
,
Long
userId
);
List
<
ProductLoginEntity
>
findByInstitutionIdAndProductIdAndExtensionAccountIdIn
(
String
institutionId
,
String
productId
,
List
<
Long
>
userIds
);
List
<
ProductLoginEntity
>
findAllByExtensionAccountId
(
Long
userId
);
List
<
ProductLoginEntity
>
findAllByExtensionAccountIdIn
(
List
<
Long
>
userId
);
/**
* @author -REYLI
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IProductLoginService.java
View file @
e37ea877
...
...
@@ -9,7 +9,9 @@ import java.util.List;
*/
public
interface
IProductLoginService
{
ProductLoginEntity
findSlaveByPloginInfo
(
String
institutionId
,
String
productId
,
Long
userId
);
List
<
ProductLoginEntity
>
findSlaveByPloginInfos
(
String
institutionId
,
String
productId
,
List
<
Long
>
userId
);
List
<
ProductLoginEntity
>
findSlaveByUserId
(
Long
userId
);
List
<
ProductLoginEntity
>
findSlaveByUserIds
(
List
<
Long
>
userIds
);
/**
* @author -REYLI
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ProductLoginServiceImpl.java
View file @
e37ea877
...
...
@@ -27,6 +27,12 @@ public class ProductLoginServiceImpl implements IProductLoginService {
return
productLogin
;
}
@Override
public
List
<
ProductLoginEntity
>
findSlaveByPloginInfos
(
String
institutionId
,
String
productId
,
List
<
Long
>
userIds
)
{
List
<
ProductLoginEntity
>
list
=
productLoginRepository
.
findByInstitutionIdAndProductIdAndExtensionAccountIdIn
(
institutionId
,
productId
,
userIds
);
return
list
;
}
@Override
@TargetDataSource
(
type
=
DSType
.
SLAVE
)
//查询从库
public
List
<
ProductLoginEntity
>
findSlaveByUserId
(
Long
userId
)
{
...
...
@@ -34,6 +40,12 @@ public class ProductLoginServiceImpl implements IProductLoginService {
return
productLoginEntityList
;
}
@Override
public
List
<
ProductLoginEntity
>
findSlaveByUserIds
(
List
<
Long
>
userIds
)
{
List
<
ProductLoginEntity
>
productLoginEntityList
=
productLoginRepository
.
findAllByExtensionAccountIdIn
(
userIds
);
return
productLoginEntityList
;
}
@Override
public
List
<
ProductLoginEntity
>
findProductLoginsByInstitutionIdAndProductId
(
String
institutionId
,
String
productId
)
{
return
productLoginRepository
.
findProductLoginsByInstitutionIdAndProductId
(
institutionId
,
productId
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
View file @
e37ea877
...
...
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* Created by 11 on 2016/12/29.
...
...
@@ -124,18 +125,19 @@ public class TenantServiceImpl implements ITenantService {
@Override
public
List
<
User
>
selectUsersByTenantId
(
List
<
User
>
users
,
Integer
tenantId
)
{
List
<
User
>
result
=
new
ArrayList
<>();
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findProductLoginsByInstitutionIdAndProductId
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
());
if
(
productLoginEntities
!=
null
&&
productLoginEntities
.
size
()>
0
)
{
users
.
forEach
(
a
->{
productLoginEntities
.
forEach
(
b
->{
if
(
a
.
getPhoneNo
().
equals
(
b
.
getPhoneNo
()))
{
a
.
setPassword
(
b
.
getPassword
());
if
(
users
!=
null
)
{
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
List
<
Long
>
userIds
=
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findSlaveByPloginInfos
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
if
(
productLoginEntities
!=
null
&&
productLoginEntities
.
size
()>
0
)
{
List
<
String
>
phoneNos
=
productLoginEntities
.
stream
().
map
(
ProductLoginEntity:
:
getPhoneNo
).
collect
(
Collectors
.
toList
());
users
.
forEach
(
a
->{
if
(
phoneNos
.
contains
(
a
.
getPhoneNo
()))
{
result
.
add
(
a
);
}
});
}
);
}
}
}
return
result
;
...
...
@@ -160,17 +162,30 @@ public class TenantServiceImpl implements ITenantService {
@Override
public
List
<
User
>
validationTentIdByTentId
(
List
<
User
>
users
,
Integer
tenantId
)
{
List
<
User
>
result
=
new
ArrayList
<>();
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findProductLoginsByInstitutionIdAndProductId
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
());
if
(
productLoginEntities
==
null
||
productLoginEntities
.
size
()>
0
)
{
if
(
users
!=
null
)
{
List
<
Long
>
userIds
=
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
List
<
ProductLoginEntity
>
slaveByPloginInfos
=
productLoginService
.
findSlaveByPloginInfos
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
users
.
forEach
(
a
->{
productLoginEntities
.
forEach
(
b
->
{
if
(
a
.
getPhoneNo
().
equals
(
b
.
getPhoneNo
()))
{
a
.
setPassword
(
b
.
getPassword
());
if
(
slaveByPloginInfos
!=
null
&&
slaveByPloginInfos
.
size
()>
0
)
{
List
<
String
>
phoneNos
=
slaveByPloginInfos
.
stream
().
map
(
ProductLoginEntity:
:
getPhoneNo
).
collect
(
Collectors
.
toList
());
if
(
phoneNos
.
contains
(
a
.
getPhoneNo
()))
{
result
.
add
(
a
);
}
});
}
});
}
List
<
ProductLoginEntity
>
slaveByUserIds
=
productLoginService
.
findSlaveByUserIds
(
userIds
);
if
(
slaveByUserIds
!=
null
)
{
List
<
Long
>
collect
=
slaveByUserIds
.
stream
().
map
(
ProductLoginEntity:
:
getExtensionAccountId
).
collect
(
Collectors
.
toList
());
users
.
forEach
(
a
->{
if
(
collect
!=
null
)
{
if
(!
collect
.
contains
(
a
.
getId
()))
{
result
.
add
(
a
);
}
}
});
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
View file @
e37ea877
...
...
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* Created by 11 on 2017/3/22.
...
...
@@ -47,29 +48,38 @@ public class UserCenterServiceImpl implements UserCenterService {
@Override
public
List
<
UserAttached
>
searchUserAttachedListByUserId
(
List
<
Long
>
userIds
,
Integer
tenantId
)
{
List
<
UserAttached
>
resultProductUsers
=
new
ArrayList
<>();
List
<
UserAttached
>
userAttacheds
=
userAttachedRepository
.
findByUserIdIn
(
userIds
);
if
(!
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
if
(
userAttacheds
!=
null
)
{
//租户ID校验
if
(!
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
List
<
UserAttached
>
resultProductUsers
=
new
ArrayList
<>();
List
<
User
>
users
=
userRepository
.
findByIdIn
(
userIds
);
List
<
User
>
productUsers
=
tenantService
.
selectUsersByTenantId
(
users
,
tenantId
);
if
(
productUsers
!=
null
)
{
List
<
Long
>
collect
=
productUsers
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
userAttacheds
.
forEach
(
a
->{
productUsers
.
forEach
(
b
->{
if
(
a
.
getUserId
().
equals
(
b
.
getId
()))
{
resultProductUsers
.
add
(
a
);
}
});
if
(
collect
.
contains
(
a
.
getUserId
()))
{
resultProductUsers
.
add
(
a
);
}
});
}
return
resultProductUsers
;
}
}
}
else
{
List
<
User
>
users
=
userRepository
.
findByIdIn
(
userIds
);
List
<
User
>
productUsers
=
tenantService
.
validationTentIdByTentId
(
users
,
tenantId
);
if
(
productUsers
!=
null
)
{
List
<
Long
>
collect
=
productUsers
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
userAttacheds
.
forEach
(
a
->{
if
(
collect
.
contains
(
a
.
getUserId
()))
{
resultProductUsers
.
add
(
a
);
}
});
}
}
return
userAttached
s
;
return
resultProductUser
s
;
}
@Override
...
...
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