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
4c80cacd
Commit
4c80cacd
authored
Jun 15, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused code.
parent
9a424b9a
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
98 additions
and
154 deletions
+98
-154
pom.xml
pom.xml
+6
-16
UserQueryLogController.java
.../controller/internal/querylog/UserQueryLogController.java
+2
-1
InnerController.java
...tgroup/xyqb/controller/internal/user/InnerController.java
+2
-3
UserCenterController.java
...controller/internal/user/center/UserCenterController.java
+5
-3
WxController.java
...ntgroup/xyqb/controller/middleoffice/wx/WxController.java
+22
-26
IProductLoginService.java
...cn/quantgroup/xyqb/service/user/IProductLoginService.java
+1
-1
OauthClientDetailsServiceImpl.java
...xyqb/service/user/impl/OauthClientDetailsServiceImpl.java
+1
-3
OauthLoginInfoServiceImpl.java
...oup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
+0
-2
ProductLoginServiceImpl.java
...group/xyqb/service/user/impl/ProductLoginServiceImpl.java
+3
-5
TenantServiceImpl.java
.../quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
+30
-47
UserCenterServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
+21
-34
XyqbSessionContextHolder.java
.../cn/quantgroup/xyqb/session/XyqbSessionContextHolder.java
+3
-9
JsonTest.java
src/test/java/common/JsonTest.java
+2
-4
No files found.
pom.xml
View file @
4c80cacd
...
...
@@ -46,11 +46,6 @@
<artifactId>
SensorsAnalyticsSDK
</artifactId>
<version>
3.2.0
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.3.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework.amqp
</groupId>
<artifactId>
spring-rabbit
</artifactId>
...
...
@@ -224,11 +219,7 @@
<artifactId>
commons-codec
</artifactId>
<version>
1.10
</version>
</dependency>
<dependency>
<groupId>
com.rabbitmq
</groupId>
<artifactId>
amqp-client
</artifactId>
<version>
4.0.3
</version>
</dependency>
<dependency>
<groupId>
com.zaxxer
</groupId>
<artifactId>
HikariCP
</artifactId>
...
...
@@ -325,12 +316,6 @@
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
<version>
2.1.0
</version>
<exclusions>
<exclusion>
<groupId>
io.netty
</groupId>
<artifactId>
netty-all
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
...
...
@@ -353,6 +338,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
<version>
3.1.6
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/querylog/UserQueryLogController.java
View file @
4c80cacd
...
...
@@ -15,6 +15,7 @@ import cn.quantgroup.xyqb.util.IdcardValidator;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.util.encrypt.Md5Util
;
import
cn.quantgroup.xyqb.util.encrypt.Rsa
;
import
com.alibaba.fastjson.JSON
;
import
com.google.gson.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.*
;
...
...
@@ -206,7 +207,7 @@ public class UserQueryLogController {
HashMap
<
String
,
Object
>
ha
=
new
HashMap
<>();
ha
.
put
(
"type"
,
"1"
);
ha
.
put
(
"phones"
,
phoneNos
);
String
phoneNoStr
=
new
Gson
().
toJson
(
ha
);
String
phoneNoStr
=
JSON
.
toJSONString
(
ha
);
String
data
=
""
;
String
sign
=
""
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/InnerController.java
View file @
4c80cacd
...
...
@@ -439,11 +439,10 @@ public class InnerController implements IBaseController {
if
(
tenantId
!=
null
&&
!
TenantUtil
.
TENANT_DEFAULT
.
equals
(
tenantId
))
{
// userId 查询对应productLogin 获取手机号和customerId
user
=
tenantService
.
getTenantUser
(
user
,
tenantId
);
if
(
user
=
=
null
)
{
return
JsonResult
.
build
ErrorStateResult
(
"查无此人"
,
null
);
if
(
user
!
=
null
)
{
return
JsonResult
.
build
SuccessResult
(
null
,
new
UserRet
(
user
)
);
}
}
return
JsonResult
.
buildSuccessResult
(
null
,
new
UserRet
(
user
));
}
return
JsonResult
.
buildErrorStateResult
(
"查无此人"
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/center/UserCenterController.java
View file @
4c80cacd
...
...
@@ -62,9 +62,6 @@ public class UserCenterController {
@PostMapping
(
"/attach/list"
)
public
JsonResult
queryUserAttachList
(
@RequestBody
List
<
Long
>
userIds
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
//默认羊小咩租户
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
if
(
CollectionUtils
.
isEmpty
(
userIds
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户 ID 不能为空"
,
null
);
}
...
...
@@ -72,6 +69,11 @@ public class UserCenterController {
if
(
userIds
.
size
()
>
size
)
{
return
JsonResult
.
buildErrorStateResult
(
"超出最大条数限制"
+
size
,
null
);
}
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
List
<
UserAttached
>
userAttachedList
=
userCenterService
.
searchUserAttachedListByUserId
(
userIds
,
tenantId
);
return
JsonResult
.
buildSuccessResultGeneric
(
userAttachedList
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/wx/WxController.java
View file @
4c80cacd
...
...
@@ -35,56 +35,51 @@ public class WxController {
private
IUserService
userService
;
/**
* @ yapi http://open.quantgroups.com/project/59/interface/api/693
* @ yapi http://yapi.quantgroups.com/project/17/interface/api/30122
* @param userId
* @return
* @ yapi http://open.quantgroups.com/project/59/interface/api/693
* @ yapi http://yapi.quantgroups.com/project/17/interface/api/30122
*/
@GetMapping
(
"/userId/{userId}"
)
public
JsonResult
openId
(
@PathVariable
Long
userId
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
//默认羊小咩租户
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
if
(
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
String
openId
=
null
;
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
)
||
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
);
if
(
wechatUserInfo
=
=
null
)
{
return
JsonResult
.
buildSuccessResult
();
if
(
wechatUserInfo
!
=
null
)
{
openId
=
wechatUserInfo
.
getOpenId
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
}
else
{
User
user
=
userService
.
findById
(
userId
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
if
(
user
!=
null
)
{
CustomerInfoEntity
tenantCustomerInfo
=
tenantService
.
getTenantCustomerInfo
(
user
,
tenantId
);
if
(
tenantCustomerInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
if
(
tenantCustomerInfo
!=
null
)
{
openId
=
tenantCustomerInfo
.
getSourceOpenId
();
}
}
return
JsonResult
.
buildSuccessResultGeneric
(
tenantCustomerInfo
.
getSourceOpenId
());
}
return
JsonResult
.
buildSuccessResultGeneric
(
openId
);
}
/**
* @ yapi http://yapi.quantgroups.com/project/17/interface/api/30122
* @param userId
* @param appName
* @param tenantId
* @return
* @ yapi http://yapi.quantgroups.com/project/17/interface/api/30122
*/
@GetMapping
(
"/userId/{userId}/{appName}"
)
public
JsonResult
openId
(
@PathVariable
Long
userId
,
@PathVariable
String
appName
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
public
JsonResult
openId
(
@PathVariable
Long
userId
,
@PathVariable
String
appName
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
//默认羊小咩租户
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
if
(
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
,
appName
);
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
,
appName
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
}
else
{
User
user
=
userService
.
findById
(
userId
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
...
...
@@ -99,10 +94,10 @@ public class WxController {
}
/**
* @yapi http://open.quantgroups.com/project/59/interface/api/693
* @yapi http://yapi.quantgroups.com/project/17/interface/api/30122
* @param phoneNo
* @return
* @yapi http://open.quantgroups.com/project/59/interface/api/693
* @yapi http://yapi.quantgroups.com/project/17/interface/api/30122
*/
@GetMapping
(
"/phoneNo/{phoneNo}"
)
public
JsonResult
openId
(
@PathVariable
String
phoneNo
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
...
...
@@ -115,7 +110,7 @@ public class WxController {
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
}
else
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
...
...
@@ -141,6 +136,7 @@ public class WxController {
}
/**
*
*/
@PostMapping
(
"/v1/getByOpenIdToUserIds"
)
public
JsonResult
getByOpenIdToUserIds
(
@RequestBody
Map
<
String
,
Object
>
params
,
@RequestParam
(
required
=
false
,
defaultValue
=
"wuxi"
)
String
appName
)
{
...
...
@@ -150,7 +146,7 @@ public class WxController {
return
JsonResult
.
buildErrorStateResult
(
"用户Id不能为空"
,
null
);
}
if
(
userIds
.
size
()
>
500
)
{
userIds
=
userIds
.
subList
(
0
,
500
);
userIds
=
userIds
.
subList
(
0
,
500
);
}
List
<
Long
>
userIdList
=
userIds
.
stream
().
map
(
userId
->
Long
.
parseLong
(
userId
.
toString
())).
collect
(
Collectors
.
toList
());
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IProductLoginService.java
View file @
4c80cacd
...
...
@@ -9,7 +9,7 @@ import java.util.List;
*/
public
interface
IProductLoginService
{
ProductLoginEntity
findSlaveByPloginInfo
(
String
institutionId
,
String
productId
,
Long
userId
);
List
<
ProductLoginEntity
>
findSlaveByP
loginInfos
(
String
institutionId
,
String
productId
,
List
<
Long
>
userId
);
List
<
ProductLoginEntity
>
findSlaveByP
roductLoginInfoList
(
String
institutionId
,
String
productId
,
List
<
Long
>
userId
);
List
<
ProductLoginEntity
>
findSlaveByUserId
(
Long
userId
);
List
<
ProductLoginEntity
>
findSlaveByUserIds
(
List
<
Long
>
userIds
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/OauthClientDetailsServiceImpl.java
View file @
4c80cacd
...
...
@@ -23,8 +23,7 @@ public class OauthClientDetailsServiceImpl implements IOauthClientDetailsService
@Override
public
OauthClientDetailsEntity
findFirstByClientId
(
Integer
clientId
)
{
OauthClientDetailsEntity
oauthClientDetailsEntity
=
oauthClientDetailsRepository
.
findFirstByClientId
(
clientId
);
return
oauthClientDetailsEntity
;
return
oauthClientDetailsRepository
.
findFirstByClientId
(
clientId
);
}
@Override
...
...
@@ -40,5 +39,4 @@ public class OauthClientDetailsServiceImpl implements IOauthClientDetailsService
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
View file @
4c80cacd
...
...
@@ -61,7 +61,6 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
long
id
=
atomicSequencer
.
nextId
();
String
customerName
=
customerId
+
""
;
uuid
=
RandomSequencer
.
randomUUID
(
customerId
);
ProductLoginEntity
entity
=
new
ProductLoginEntity
();
Integer
partitionKey
=
atomicSequencer
.
partitionKey
(
customerId
);
ProductLoginEntity
productLoginEntity
=
EntityBuilder
.
productLogin
(
productId
,
institutionId
,
phoneNo
,
customerId
,
customerName
,
partitionKey
,
id
);
productLoginEntity
.
setExtensionAccountId
(
userId
);
...
...
@@ -120,7 +119,6 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
long
id
=
atomicSequencer
.
nextId
();
String
customerName
=
customerId
+
""
;
uuid
=
RandomSequencer
.
randomUUID
(
customerId
);
ProductLoginEntity
entity
=
new
ProductLoginEntity
();
Integer
partitionKey
=
atomicSequencer
.
partitionKey
(
customerId
);
productLoginEntity
=
EntityBuilder
.
productLogin
(
productId
,
institutionId
,
phoneNo
,
customerId
,
customerName
,
partitionKey
,
id
);
productLoginEntity
.
setExtensionAccountId
(
userId
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ProductLoginServiceImpl.java
View file @
4c80cacd
...
...
@@ -25,9 +25,8 @@ public class ProductLoginServiceImpl implements IProductLoginService {
}
@Override
public
List
<
ProductLoginEntity
>
findSlaveByPloginInfos
(
String
institutionId
,
String
productId
,
List
<
Long
>
userIds
)
{
List
<
ProductLoginEntity
>
list
=
productLoginRepository
.
findByInstitutionIdAndProductIdAndExtensionAccountIdIn
(
institutionId
,
productId
,
userIds
);
return
list
;
public
List
<
ProductLoginEntity
>
findSlaveByProductLoginInfoList
(
String
institutionId
,
String
productId
,
List
<
Long
>
userIds
)
{
return
productLoginRepository
.
findByInstitutionIdAndProductIdAndExtensionAccountIdIn
(
institutionId
,
productId
,
userIds
);
}
@Override
...
...
@@ -38,8 +37,7 @@ public class ProductLoginServiceImpl implements IProductLoginService {
@Override
public
List
<
ProductLoginEntity
>
findSlaveByUserIds
(
List
<
Long
>
userIds
)
{
List
<
ProductLoginEntity
>
productLoginEntityList
=
productLoginRepository
.
findAllByExtensionAccountIdIn
(
userIds
);
return
productLoginEntityList
;
return
productLoginRepository
.
findAllByExtensionAccountIdIn
(
userIds
);
}
@Override
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
View file @
4c80cacd
...
...
@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.service.user.IOauthClientDetailsService;
import
cn.quantgroup.xyqb.service.user.IProductLoginService
;
import
cn.quantgroup.xyqb.service.user.ITenantService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -37,13 +38,12 @@ public class TenantServiceImpl implements ITenantService {
if
(
oauthClientDetails
!=
null
)
{
ProductLoginEntity
productLogin
=
productLoginService
.
findSlaveByPloginInfo
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
user
.
getId
());
if
(
productLogin
!=
null
)
{
if
(!
user
.
getEncryptedPhoneNo
().
equals
(
productLogin
.
getEncryptedPhoneNo
()))
{
return
null
;
}
if
(
user
.
getEncryptedPhoneNo
().
equals
(
productLogin
.
getEncryptedPhoneNo
()))
{
user
.
setPassword
(
productLogin
.
getPassword
());
return
user
;
}
}
}
return
null
;
}
...
...
@@ -107,15 +107,9 @@ public class TenantServiceImpl implements ITenantService {
if
(
oauthClientDetails
!=
null
)
{
ProductLoginEntity
productLogin
=
productLoginService
.
findSlaveByPloginInfo
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
user
.
getId
());
if
(
productLogin
!=
null
)
{
if
(!
user
.
getPhoneNo
().
equals
(
productLogin
.
getPhoneNo
()))
{
return
null
;
}
CustomerInfoEntity
customerInfo
=
customerInfoService
.
findSlaveByCustomerId
(
productLogin
.
getCustomerId
());
if
(
customerInfo
==
null
)
{
return
null
;
if
(
user
.
getPhoneNo
().
equals
(
productLogin
.
getPhoneNo
()))
{
return
customerInfoService
.
findSlaveByCustomerId
(
productLogin
.
getCustomerId
());
}
return
customerInfo
;
}
}
return
null
;
...
...
@@ -124,18 +118,14 @@ public class TenantServiceImpl implements ITenantService {
@Override
public
List
<
User
>
selectUsersByTenantId
(
List
<
User
>
users
,
Integer
tenantId
)
{
List
<
User
>
result
=
new
ArrayList
<>();
if
(
users
!=
null
)
{
if
(
CollectionUtils
.
isNotEmpty
(
users
)
)
{
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
List
<
Long
>
userIds
=
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findSlaveByP
loginInfos
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
if
(
productLoginEntities
!=
null
&&
productLoginEntities
.
size
()>
0
)
{
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findSlaveByP
roductLoginInfoList
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
if
(
CollectionUtils
.
isNotEmpty
(
productLoginEntities
)
)
{
List
<
String
>
phoneNos
=
productLoginEntities
.
stream
().
map
(
ProductLoginEntity:
:
getPhoneNo
).
collect
(
Collectors
.
toList
());
users
.
forEach
(
a
->{
if
(
phoneNos
.
contains
(
a
.
getPhoneNo
()))
{
result
.
add
(
a
);
}
});
result
=
users
.
stream
().
filter
(
i
->
phoneNos
.
contains
(
i
.
getPhoneNo
())).
collect
(
Collectors
.
toList
());
}
}
}
...
...
@@ -148,7 +138,7 @@ public class TenantServiceImpl implements ITenantService {
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
CustomerInfoEntity
customerInfo
=
customerInfoService
.
findSlaveByOpenId
(
openId
,
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
());
if
(
customerInfo
!=
null
)
{
if
(
customerInfo
!=
null
)
{
ProductLoginEntity
productLogin
=
productLoginService
.
findSlaveByCustomerInfo
(
customerInfo
.
getCustomerId
(),
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
());
if
(
productLogin
!=
null
)
{
return
productLogin
.
getExtensionAccountId
();
...
...
@@ -161,31 +151,24 @@ public class TenantServiceImpl implements ITenantService {
@Override
public
List
<
User
>
validationTentIdByTentId
(
List
<
User
>
users
,
Integer
tenantId
)
{
List
<
User
>
result
=
new
ArrayList
<>();
if
(
users
!=
null
)
{
List
<
Long
>
userIds
=
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
users
))
{
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
List
<
Long
>
userIds
=
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
oauthClientDetails
!=
null
)
{
List
<
ProductLoginEntity
>
slaveByPloginInfos
=
productLoginService
.
findSlaveByPloginInfos
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
users
.
forEach
(
a
->{
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
);
}
}
});
//1、查询出在product_login手机号码相同的用户
List
<
ProductLoginEntity
>
productLoginEntities
=
productLoginService
.
findSlaveByProductLoginInfoList
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
userIds
);
List
<
String
>
phoneNos
=
productLoginEntities
.
stream
().
map
(
ProductLoginEntity:
:
getPhoneNo
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
productLoginEntities
))
{
result
=
users
.
stream
().
filter
(
i
->
phoneNos
.
contains
(
i
.
getPhoneNo
())).
collect
(
Collectors
.
toList
());
}
}
else
{
//2、查询用户id不在product_login的扩展账户ID的用户
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
);
}
List
<
Long
>
extensionAccountIds
=
slaveByUserIds
.
stream
().
map
(
ProductLoginEntity:
:
getExtensionAccountId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
slaveByUserIds
))
{
result
=
users
.
stream
().
filter
(
i
->
extensionAccountIds
.
contains
(
i
.
getId
())).
collect
(
Collectors
.
toList
());
}
});
}
}
return
result
;
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
View file @
4c80cacd
...
...
@@ -9,6 +9,7 @@ import cn.quantgroup.xyqb.service.user.UserCenterService;
import
cn.quantgroup.xyqb.util.EmojiUtil
;
import
cn.quantgroup.xyqb.util.TenantUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hibernate.exception.ConstraintViolationException
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -46,32 +47,18 @@ 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
)
{
List
<
UserAttached
>
userAttachedList
=
userAttachedRepository
.
findByUserIdIn
(
userIds
);
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
->{
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
);
}
});
List
<
User
>
productUsers
;
if
(!
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
productUsers
=
tenantService
.
selectUsersByTenantId
(
users
,
tenantId
);
}
else
{
productUsers
=
tenantService
.
validationTentIdByTentId
(
users
,
tenantId
);
}
if
(
CollectionUtils
.
isNotEmpty
(
userAttachedList
)
&&
CollectionUtils
.
isNotEmpty
(
productUsers
))
{
List
<
Long
>
productUserIds
=
productUsers
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
());
resultProductUsers
=
userAttachedList
.
stream
().
filter
(
i
->
productUserIds
.
contains
(
i
.
getUserId
())).
collect
(
Collectors
.
toList
());
}
return
resultProductUsers
;
}
...
...
@@ -80,10 +67,10 @@ public class UserCenterServiceImpl implements UserCenterService {
@CacheEvict
(
value
=
"userAttachedCache"
,
key
=
"'xyqbUserAttached' + #userId"
,
cacheManager
=
"cacheManager"
)
public
UserAttached
saveUserAvatar
(
long
userId
,
String
avatar
)
{
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
if
(
Objects
.
isNull
(
userAttached
))
{
if
(
Objects
.
isNull
(
userAttached
))
{
userAttached
=
createUserAttached
(
userId
,
avatar
,
null
);
}
if
(!
Objects
.
equals
(
avatar
,
userAttached
.
getAvatar
()))
{
if
(!
Objects
.
equals
(
avatar
,
userAttached
.
getAvatar
()))
{
userAttached
.
setAvatar
(
avatar
);
userAttached
=
userAttachedRepository
.
save
(
userAttached
);
}
...
...
@@ -96,14 +83,14 @@ public class UserCenterServiceImpl implements UserCenterService {
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
// 替换所有,UTF-8编码时4字节的Emoji表情字符
nick
=
EmojiUtil
.
filterUnicode4
(
nick
);
if
(
Objects
.
isNull
(
userAttached
))
{
if
(
Objects
.
isNull
(
userAttached
))
{
userAttached
=
createUserAttached
(
userId
,
null
,
nick
);
}
if
(!
Objects
.
equals
(
nick
,
userAttached
.
getNick
()))
{
if
(!
Objects
.
equals
(
nick
,
userAttached
.
getNick
()))
{
userAttached
.
setNick
(
nick
);
try
{
userAttached
=
userAttachedRepository
.
save
(
userAttached
);
}
catch
(
ConstraintViolationException
e
)
{
}
catch
(
ConstraintViolationException
e
)
{
// Sql唯一约束异常(诱因是Form重复提交,因为该操作是幂等的,故此不需额外处理,可返回成功)
log
.
error
(
"Sql约束异常[uni_idx_user_id]重复提交Form是幂等操作,不影响处理结果"
,
e
);
}
...
...
@@ -129,10 +116,10 @@ public class UserCenterServiceImpl implements UserCenterService {
// 更新实例
userAttached
=
Optional
.
ofNullable
(
userAttached
).
orElse
(
new
UserAttached
());
userAttached
.
setUserId
(
userId
);
if
(
StringUtils
.
isBlank
(
userAttached
.
getAvatar
()))
{
if
(
StringUtils
.
isBlank
(
userAttached
.
getAvatar
()))
{
userAttached
.
setAvatar
(
avatar
);
}
if
(
StringUtils
.
isBlank
(
userAttached
.
getNick
()))
{
if
(
StringUtils
.
isBlank
(
userAttached
.
getNick
()))
{
userAttached
.
setNick
(
nick
);
}
return
userAttachedRepository
.
save
(
userAttached
);
...
...
src/main/java/cn/quantgroup/xyqb/session/XyqbSessionContextHolder.java
View file @
4c80cacd
...
...
@@ -52,21 +52,16 @@ public class XyqbSessionContextHolder {
}
public
static
SessionStruct
getXSessionFromRedis
(
String
token
)
{
if
(
Objects
.
isNull
(
redisTemplate
))
{
return
null
;
}
String
linkToken
=
Constants
.
Session
.
USER_SESSION_CACHE
+
token
;
String
result
=
redisTemplate
.
opsForValue
().
get
(
linkToken
);
if
(
StringUtils
.
isEmpty
(
result
))
{
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] Tokekn:{},linkTokekn:{}"
,
token
,
linkToken
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] session data 未找到:sid:{},sessionValue:{}"
,
token
,
result
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] session data 未找到:Tokekn:{},linkTokekn:{},sessionValue:{}"
,
token
,
linkToken
,
result
);
return
null
;
}
try
{
SessionValue
values
=
JSON
.
parseObject
(
result
,
SessionValue
.
class
);
if
(
values
==
null
)
{
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] Tokekn:{},linkTokekn:{}"
,
token
,
linkToken
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] session data 序列化失败:sid:{},sessionValue:{}"
,
token
,
result
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] session data 序列化失败:token:{},linkTokekn:{},sessionValue:{}"
,
token
,
linkToken
,
result
);
return
null
;
}
SessionStruct
sessionStruct
=
new
SessionStruct
();
...
...
@@ -75,8 +70,7 @@ public class XyqbSessionContextHolder {
sessionStruct
.
setExpire
(
redisTemplate
.
getExpire
(
Constants
.
Session
.
USER_SESSION_CACHE
+
token
));
return
sessionStruct
;
}
catch
(
Exception
e
)
{
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] Tokekn:{},linkTokekn:{}"
,
token
,
linkToken
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] 序列化SessionValue出错:sid:{},sessionValue:{}"
,
token
,
result
,
e
);
log
.
warn
(
"[XyqbSessionContextHolder][getXSessionFromRedis] 序列化SessionValue出错:Tokekn:{},linkTokekn:{},sessionValue:{}"
,
token
,
linkToken
,
result
,
e
);
return
null
;
}
}
...
...
src/test/java/common/JsonTest.java
View file @
4c80cacd
...
...
@@ -8,7 +8,6 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.google.gson.Gson
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.binary.Base64
;
import
org.junit.Test
;
...
...
@@ -20,7 +19,6 @@ import java.sql.Timestamp;
@Slf4j
@RunWith
(
JUnit4
.
class
)
public
class
JsonTest
{
private
static
final
Gson
GSON
=
new
Gson
();
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
()
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
)
.
configure
(
SerializationFeature
.
WRITE_ENUMS_USING_INDEX
,
true
)
...
...
@@ -34,7 +32,7 @@ public class JsonTest {
userData
.
setId
(
131L
);
userData
.
setUserId
(
119L
);
userData
.
setCreatedAt
(
new
Timestamp
(
1
));
log
.
info
(
"序列化--GSON--成功!data:{}"
,
GSON
.
toJson
(
userData
));
log
.
info
(
"序列化--GSON--成功!data:{}"
,
JSON
.
toJSONString
(
userData
));
log
.
info
(
"序列化--MAPPER--成功!data:{}"
,
MAPPER
.
writeValueAsString
(
userData
));
log
.
info
(
"序列化--JSON--成功!data:{}"
,
JSON
.
toJSONString
(
userData
,
SerializerFeature
.
config
(
JSON
.
DEFAULT_GENERATE_FEATURE
,
SerializerFeature
.
WriteEnumUsingName
,
false
)));
log
.
info
(
"序列化--JSONObject--成功!data:{}"
,
JSONObject
.
toJSONString
(
userData
));
...
...
@@ -46,7 +44,7 @@ public class JsonTest {
@Test
public
void
gsonGson
(){
try
{
UserDetail
userData
=
GSON
.
fromJson
(
body
,
UserDetail
.
class
);
UserDetail
userData
=
JSON
.
parseObject
(
body
,
UserDetail
.
class
);
log
.
info
(
"GSON--成功!data:{}"
,
userData
);
}
catch
(
Exception
e
){
log
.
error
(
"GSON--失败!"
,
e
);
...
...
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