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
1a3afc71
Commit
1a3afc71
authored
Jul 20, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix an issue.(add appid 、unionID、openId)
parent
d3d1d3c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
14 deletions
+56
-14
UserApiV2Controller.java
...uantgroup/xyqb/controller/api/v2/UserApiV2Controller.java
+18
-14
UserBean.java
src/main/java/cn/quantgroup/xyqb/model/UserBean.java
+38
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/api/v2/UserApiV2Controller.java
View file @
1a3afc71
...
...
@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.entity.WechatUserInfo;
import
cn.quantgroup.xyqb.exception.BizException
;
import
cn.quantgroup.xyqb.exception.BizExceptionEnum
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.UserBean
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
...
...
@@ -41,9 +42,10 @@ public class UserApiV2Controller {
* @see <a href="http://yapi.quantgroups.com/project/17/interface/api/65724">查询用户信息</a>
*/
@PostMapping
(
"info"
)
public
JsonResult
<
User
>
info
(
@RequestBody
UserInfoReq
userInfoReq
)
{
public
JsonResult
<
User
Bean
>
info
(
@RequestBody
UserInfoReq
userInfoReq
)
{
SessionStruct
sessionStruct
=
XyqbSessionContextHolder
.
getXSession
();
User
user
=
null
;
WechatUserInfo
wechatUserInfo
=
null
;
//1、校验
if
(
userInfoReq
.
getUserId
()
==
null
&&
StringUtils
.
isEmpty
(
userInfoReq
.
getUuid
())
&&
StringUtils
.
isEmpty
(
userInfoReq
.
getPhoneNo
())
&&
(
StringUtils
.
isEmpty
(
userInfoReq
.
getAppId
())
&&
StringUtils
.
isEmpty
(
userInfoReq
.
getOpenId
()))
...
...
@@ -56,24 +58,24 @@ public class UserApiV2Controller {
user
=
userRepository
.
findByIdAndTenantId
(
userInfoReq
.
getUserId
(),
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getUuid
()))
{
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getUuid
()))
{
user
=
userRepository
.
findByUuidAndTenantId
(
userInfoReq
.
getUuid
(),
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getPhoneNo
()))
{
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getPhoneNo
()))
{
user
=
userRepository
.
findByPhoneNoAndTenantId
(
userInfoReq
.
getPhoneNo
(),
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getAppId
())
&&
StringUtils
.
isNotEmpty
(
userInfoReq
.
getOpenId
()))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
findWechatUserInfoFromDb
(
userInfoReq
.
getOpenId
(),
userInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getAppId
())
&&
StringUtils
.
isNotEmpty
(
userInfoReq
.
getOpenId
()))
{
wechatUserInfo
=
wechatService
.
findWechatUserInfoFromDb
(
userInfoReq
.
getOpenId
(),
userInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
if
(
wechatUserInfo
==
null
||
wechatUserInfo
.
getUserId
()
==
null
)
{
throw
new
BizException
(
BizExceptionEnum
.
UN_EXIT_USER
);
}
user
=
userRepository
.
findByIdAndTenantId
(
wechatUserInfo
.
getUserId
(),
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getAppId
())
&&
StringUtils
.
isNotEmpty
(
userInfoReq
.
getUnionId
()))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
findByUnionIdAndAppIdAndTenantId
(
userInfoReq
.
getUnionId
(),
userInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
if
(
StringUtils
.
isNotEmpty
(
userInfoReq
.
getAppId
())
&&
StringUtils
.
isNotEmpty
(
userInfoReq
.
getUnionId
()))
{
wechatUserInfo
=
wechatService
.
findByUnionIdAndAppIdAndTenantId
(
userInfoReq
.
getUnionId
(),
userInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
if
(
wechatUserInfo
==
null
||
wechatUserInfo
.
getUserId
()
==
null
)
{
throw
new
BizException
(
BizExceptionEnum
.
UN_EXIT_USER
);
}
...
...
@@ -85,7 +87,7 @@ public class UserApiV2Controller {
throw
new
BizException
(
BizExceptionEnum
.
UN_EXIT_USER
);
}
return
JsonResult
.
buildSuccessResultGeneric
(
user
);
return
JsonResult
.
buildSuccessResultGeneric
(
UserBean
.
from
(
user
,
wechatUserInfo
)
);
}
/**
...
...
@@ -113,17 +115,18 @@ public class UserApiV2Controller {
userList
=
userRepository
.
findByIdInAndTenantId
(
batchInfoReq
.
getUserIds
(),
sessionStruct
.
getTenantId
());
}
if
(
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getUuids
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getUuids
()))
{
userList
=
userRepository
.
findByUuidInAndTenantId
(
batchInfoReq
.
getUuids
(),
sessionStruct
.
getTenantId
());
}
if
(
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getPhoneNos
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getPhoneNos
()))
{
userList
=
userRepository
.
findByPhoneNoInAndTenantId
(
batchInfoReq
.
getPhoneNos
(),
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
batchInfoReq
.
getAppId
())
&&
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getOpenIds
()))
{
if
(
StringUtils
.
isNotEmpty
(
batchInfoReq
.
getAppId
())
&&
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getOpenIds
()))
{
List
<
WechatUserInfo
>
wechatUserInfo
=
wechatService
.
findWechatUserInfoFromDb
(
batchInfoReq
.
getOpenIds
(),
batchInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
List
<
Long
>
userIds
=
wechatUserInfo
.
stream
().
map
(
WechatUserInfo:
:
getUserId
).
collect
(
Collectors
.
toList
());;
List
<
Long
>
userIds
=
wechatUserInfo
.
stream
().
map
(
WechatUserInfo:
:
getUserId
).
collect
(
Collectors
.
toList
());
;
if
(
CollectionUtils
.
isEmpty
(
wechatUserInfo
)
||
CollectionUtils
.
isEmpty
(
userIds
))
{
throw
new
BizException
(
BizExceptionEnum
.
UN_EXIT_USER
);
}
...
...
@@ -131,9 +134,10 @@ public class UserApiV2Controller {
userList
=
userRepository
.
findByIdInAndTenantId
(
userIds
,
sessionStruct
.
getTenantId
());
}
if
(
StringUtils
.
isNotEmpty
(
batchInfoReq
.
getAppId
())
&&
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getUnionIds
()))
{
if
(
StringUtils
.
isNotEmpty
(
batchInfoReq
.
getAppId
())
&&
CollectionUtils
.
isNotEmpty
(
batchInfoReq
.
getUnionIds
()))
{
List
<
WechatUserInfo
>
wechatUserInfo
=
wechatService
.
findUnionIdsAndOpenIdAndTenantId
(
batchInfoReq
.
getUnionIds
(),
batchInfoReq
.
getAppId
(),
sessionStruct
.
getTenantId
());
List
<
Long
>
userIds
=
wechatUserInfo
.
stream
().
map
(
WechatUserInfo:
:
getUserId
).
collect
(
Collectors
.
toList
());;
List
<
Long
>
userIds
=
wechatUserInfo
.
stream
().
map
(
WechatUserInfo:
:
getUserId
).
collect
(
Collectors
.
toList
());
;
if
(
CollectionUtils
.
isEmpty
(
wechatUserInfo
)
||
CollectionUtils
.
isEmpty
(
userIds
))
{
throw
new
BizException
(
BizExceptionEnum
.
UN_EXIT_USER
);
}
...
...
src/main/java/cn/quantgroup/xyqb/model/UserBean.java
0 → 100644
View file @
1a3afc71
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
lombok.Data
;
@Data
public
class
UserBean
{
private
Long
userId
;
private
String
openId
;
private
String
appId
;
private
String
unionId
;
private
String
phoneNo
;
private
Long
registeredFrom
;
private
String
uuid
;
private
Boolean
enable
;
private
Integer
tenantId
;
public
static
UserBean
from
(
User
user
,
WechatUserInfo
wechatUserInfo
)
{
UserBean
userBean
=
new
UserBean
();
userBean
.
setUserId
(
user
.
getId
());
userBean
.
setPhoneNo
(
userBean
.
getPhoneNo
());
userBean
.
setRegisteredFrom
(
user
.
getRegisteredFrom
());
userBean
.
setUuid
(
userBean
.
getUuid
());
userBean
.
setEnable
(
user
.
getEnable
());
userBean
.
setTenantId
(
user
.
getTenantId
());
if
(
wechatUserInfo
!=
null
)
{
userBean
.
setOpenId
(
wechatUserInfo
.
getOpenId
());
userBean
.
setUnionId
(
wechatUserInfo
.
getUnionId
());
userBean
.
setAppId
(
wechatUserInfo
.
getAppId
());
}
return
userBean
;
}
}
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