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
32fad388
Commit
32fad388
authored
Mar 21, 2025
by
xuepeng.chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.Apollo 动态刷新配置
2.限制用户小程序登陆
parent
58b47a33
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
4 deletions
+73
-4
Bootstrap.java
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
+2
-0
ApolloConfigListener.java
.../java/cn/quantgroup/xyqb/config/ApolloConfigListener.java
+45
-0
CommonProperties.java
...in/java/cn/quantgroup/xyqb/constant/CommonProperties.java
+17
-0
InterLoginStrategy.java
...ava/cn/quantgroup/xyqb/service/v2/InterLoginStrategy.java
+9
-4
No files found.
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
View file @
32fad388
package
cn
.
quantgroup
.
xyqb
;
import
cn.quantgroup.xyqb.config.SequencerProperties
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -26,6 +27,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
@EnableConfigurationProperties
({
SequencerProperties
.
class
})
@EnableFeignClients
@EnableApolloConfig
public
class
Bootstrap
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/cn/quantgroup/xyqb/config/ApolloConfigListener.java
0 → 100644
View file @
32fad388
package
cn
.
quantgroup
.
xyqb
.
config
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
java.util.Set
;
/**
* 配置文件监听
* 当apollo配置文件发生变更的时候,监听所有被{@link RefreshScope}修饰的类,这些类进行删除,在使用的是重新加载
*/
@Component
@Slf4j
public
class
ApolloConfigListener
implements
ApplicationContextAware
{
private
ApplicationContext
applicationContext
;
@Autowired
RefreshScope
refreshScope
;
@ApolloConfigChangeListener
(
value
=
{
"application"
})
public
void
configChange
(
ConfigChangeEvent
event
)
{
Set
<
String
>
changedKeys
=
event
.
changedKeys
();
for
(
String
changedKey
:
changedKeys
)
{
log
.
info
(
"changed key = {}"
,
changedKey
);
log
.
info
(
"oldValue={},newValue= {}"
,
event
.
getChange
(
changedKey
).
getOldValue
(),
event
.
getChange
(
changedKey
).
getNewValue
());
}
this
.
applicationContext
.
publishEvent
(
new
EnvironmentChangeEvent
(
event
.
changedKeys
()));
refreshScope
.
refreshAll
();
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
}
}
\ No newline at end of file
src/main/java/cn/quantgroup/xyqb/constant/CommonProperties.java
0 → 100644
View file @
32fad388
package
cn
.
quantgroup
.
xyqb
.
constant
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Component
;
@NoArgsConstructor
@Data
@Component
@RefreshScope
public
class
CommonProperties
{
/** 限制用户小程序登陆*/
@Value
(
"${wechat.black.userIds:}"
)
private
String
wechatBlackUserIds
;
}
src/main/java/cn/quantgroup/xyqb/service/v2/InterLoginStrategy.java
View file @
32fad388
package
cn
.
quantgroup
.
xyqb
.
service
.
v2
;
import
cn.quantgroup.xyqb.constant.CommonProperties
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.controller.req.v2.LoginReq
;
import
cn.quantgroup.xyqb.entity.User
;
...
...
@@ -35,11 +36,15 @@ public class InterLoginStrategy implements LoginStrategy {
private
final
IWechatService
wechatService
;
private
final
ISessionService
sessionService
;
public
InterLoginStrategy
(
ILockIpv4Service
lockIpv4Service
,
IUserService
userService
,
IWechatService
wechatService
,
ISessionService
sessionService
)
{
private
final
CommonProperties
commonProperties
;
public
InterLoginStrategy
(
ILockIpv4Service
lockIpv4Service
,
IUserService
userService
,
IWechatService
wechatService
,
ISessionService
sessionService
,
CommonProperties
commonProperties
)
{
this
.
lockIpv4Service
=
lockIpv4Service
;
this
.
userService
=
userService
;
this
.
wechatService
=
wechatService
;
this
.
sessionService
=
sessionService
;
this
.
commonProperties
=
commonProperties
;
}
@Override
...
...
@@ -88,10 +93,10 @@ public class InterLoginStrategy implements LoginStrategy {
}
// 临时的限制泄露账户的用户不让用户的小程序登陆,在上线微信解绑功能后删除
if
(
StringUtils
.
isNotEmpty
(
interLoginParam
.
getAppId
())
&&
StringUtils
.
isNotEmpty
(
interLoginParam
.
getOpenId
())){
if
(
user
.
getId
().
equals
(
53007786L
)
||
user
.
getId
().
equals
(
9440153L
)){
if
(
StringUtils
.
isNotEmpty
(
commonProperties
.
getWechatBlackUserIds
())
&&
commonProperties
.
getWechatBlackUserIds
().
contains
(
user
.
getId
().
toString
()))
log
.
info
(
"用户,限制小程序登陆,userId:{}"
,
user
.
getId
());
throw
new
SilentBizException
(
BizExceptionEnum
.
ERROR_WECHAT_LOGIN
);
}
throw
new
SilentBizException
(
BizExceptionEnum
.
ERROR_WECHAT_LOGIN
);
}
//2、需要判断是否是否启用
...
...
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