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
3d71098b
Commit
3d71098b
authored
Jul 19, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix an issue(appId)
parent
de79c554
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
7 deletions
+42
-7
WechatConfiguration.java
...a/cn/quantgroup/xyqb/config/data/WechatConfiguration.java
+18
-5
WechatAppNameMapping.java
...n/java/cn/quantgroup/xyqb/model/WechatAppNameMapping.java
+10
-0
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+11
-2
WechatServiceImpl.java
...uantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
+3
-0
No files found.
src/main/java/cn/quantgroup/xyqb/config/data/WechatConfiguration.java
View file @
3d71098b
...
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.config.data;
import
cn.quantgroup.xyqb.exception.BizException
;
import
cn.quantgroup.xyqb.exception.BizExceptionEnum
;
import
cn.quantgroup.xyqb.model.WechatAppNameMapping
;
import
cn.quantgroup.xyqb.model.WechatConfigBean
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ctrip.framework.apollo.ConfigService
;
...
...
@@ -16,23 +17,35 @@ import java.util.Optional;
public
class
WechatConfiguration
{
private
final
List
<
WechatConfigBean
>
list
;
private
final
List
<
WechatAppNameMapping
>
wechatAppNameMappingList
;
public
WechatConfiguration
()
{
String
data
=
ConfigService
.
getAppConfig
().
getProperty
(
"wechat.configs"
,
"[]"
);
String
data2
=
ConfigService
.
getAppConfig
().
getProperty
(
"wechat.appName.mapping"
,
"[]"
);
list
=
JSONArray
.
parseArray
(
data
,
WechatConfigBean
.
class
);
wechatAppNameMappingList
=
JSONArray
.
parseArray
(
data2
,
WechatAppNameMapping
.
class
);
}
public
WechatConfigBean
getByAppIdAndTenantId
(
String
appId
,
Integer
tenantId
){
Optional
<
WechatConfigBean
>
optional
=
list
.
stream
().
filter
(
i
->
i
.
getAppId
().
equals
(
appId
)&&
i
.
getTenantId
().
equals
(
tenantId
)).
findFirst
();
if
(!
optional
.
isPresent
())
{
public
WechatConfigBean
getByAppIdAndTenantId
(
String
appId
,
Integer
tenantId
)
{
Optional
<
WechatConfigBean
>
optional
=
list
.
stream
().
filter
(
i
->
i
.
getAppId
().
equals
(
appId
)
&&
i
.
getTenantId
().
equals
(
tenantId
)).
findFirst
();
if
(!
optional
.
isPresent
())
{
throw
new
BizException
(
BizExceptionEnum
.
ERROR_WECHAT_APP_ID
);
}
else
{
}
else
{
return
optional
.
get
();
}
}
public
WechatConfigBean
getDefault
(){
public
WechatConfigBean
getDefault
()
{
return
list
.
stream
().
filter
(
WechatConfigBean:
:
isDefaultMini
).
findFirst
().
get
();
}
public
WechatAppNameMapping
getByAppName
(
String
appName
)
{
Optional
<
WechatAppNameMapping
>
optional
=
wechatAppNameMappingList
.
stream
().
filter
(
i
->
i
.
getAppName
().
equals
(
appName
)).
findFirst
();
if
(!
optional
.
isPresent
())
{
throw
new
BizException
(
BizExceptionEnum
.
ERROR_WECHAT_APP_ID
);
}
else
{
return
optional
.
get
();
}
}
}
src/main/java/cn/quantgroup/xyqb/model/WechatAppNameMapping.java
0 → 100644
View file @
3d71098b
package
cn
.
quantgroup
.
xyqb
.
model
;
import
lombok.Data
;
@Data
public
class
WechatAppNameMapping
{
private
String
appName
;
private
String
appId
;
private
Integer
tenantId
;
}
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
3d71098b
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
.
impl
;
import
cn.quantgroup.xyqb.config.data.WechatConfiguration
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.ILoginModule
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo
;
...
...
@@ -38,16 +39,19 @@ public class AppletServiceImpl implements IAppletService {
private
final
IUserService
userService
;
private
ILoginModule
loginModule
;
private
final
WechatConfiguration
wechatConfiguration
;
@Autowired
public
AppletServiceImpl
(
IWeChatUserRepository
iWeChatUserRepository
,
IUserRegisterService
iUserRegisterService
,
IUserService
userService
,
ILoginModule
loginModule
)
{
ILoginModule
loginModule
,
WechatConfiguration
wechatConfiguration
)
{
this
.
iWeChatUserRepository
=
iWeChatUserRepository
;
this
.
iUserRegisterService
=
iUserRegisterService
;
this
.
userService
=
userService
;
this
.
loginModule
=
loginModule
;
this
.
wechatConfiguration
=
wechatConfiguration
;
}
@Override
...
...
@@ -55,10 +59,14 @@ public class AppletServiceImpl implements IAppletService {
public
Long
relevance
(
AppletParamEntry
appletParamEntry
)
{
WechatUserInfo
wechatUserInfo
=
iWeChatUserRepository
.
findByOpenIdAndAppNameAndAppIdAndTenantId
(
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
(),
appletParamEntry
.
getAppId
(),
appletParamEntry
.
getTenantId
());
//这个接口先不考虑更换手机号的情况
if
(
appletParamEntry
.
getTenantId
()==
null
)
{
if
(
appletParamEntry
.
getTenantId
()
==
null
)
{
appletParamEntry
.
setTenantId
(
UserConstant
.
defaultTenantId
);
}
if
(
StringUtils
.
isEmpty
(
appletParamEntry
.
getAppId
()))
{
}
wechatUserInfo
=
(
wechatUserInfo
==
null
?
new
WechatUserInfo
()
:
wechatUserInfo
);
wechatUserInfo
.
setNickName
(
appletParamEntry
.
getNickName
());
wechatUserInfo
.
setCity
(
appletParamEntry
.
getCity
());
...
...
@@ -86,6 +94,7 @@ public class AppletServiceImpl implements IAppletService {
}
wechatUserInfo
.
setUserId
(
user
.
getId
());
}
wechatUserInfo
.
setAppId
(
wechatConfiguration
.
getByAppName
(
appletParamEntry
.
getAppName
()).
getAppId
());
//如果存在就更新在微信表里
iWeChatUserRepository
.
save
(
wechatUserInfo
);
...
...
src/main/java/cn/quantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
View file @
3d71098b
...
...
@@ -144,6 +144,9 @@ public class WechatServiceImpl implements IWechatService {
userInfo
.
setTenantId
(
UserConstant
.
defaultTenantId
);
}
userInfo
.
setAppId
(
wechatConfiguration
.
getByAppName
(
userInfo
.
getAppName
()).
getAppId
());
log
.
info
(
"微信信息保存开始:{}"
,
JSON
.
toJSONString
(
userInfo
));
if
(
Objects
.
isNull
(
userInfo
)
||
Objects
.
isNull
(
userInfo
.
getOpenId
()))
{
return
null
;
...
...
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