Skip to content

Commit 57b0b59

Browse files
committed
集成百度统计
1 parent 1c00b14 commit 57b0b59

4 files changed

Lines changed: 9 additions & 0 deletions

File tree

blog/src/main/java/liuyuyang/net/common/listener/BaiduTokenStartupListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package liuyuyang.net.common.listener;
22

3+
import liuyuyang.net.common.properties.BaiduProperties;
34
import liuyuyang.net.web.service.impl.BaiduServiceImpl;
45
import lombok.extern.slf4j.Slf4j;
56
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -13,9 +14,14 @@
1314
public class BaiduTokenStartupListener implements ApplicationListener<ApplicationReadyEvent> {
1415
@Resource
1516
private BaiduServiceImpl baiduService;
17+
@Resource
18+
private BaiduProperties baiduProperties;
1619

1720
@Override
1821
public void onApplicationEvent(ApplicationReadyEvent event) {
22+
// 如果是关闭状态,则不检查
23+
if(!baiduProperties.getIsOpen()) return;
24+
1925
log.info("应用启动完成,开始检查百度统计 Token 状态");
2026

2127
try {

blog/src/main/java/liuyuyang/net/common/properties/BaiduProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@Component
99
@ConfigurationProperties(prefix = "lyy.baidu")
1010
public class BaiduProperties {
11+
private Boolean isOpen;
1112
private String clientKey;
1213
private String clientSecret;
1314
private String refreshToken;

blog/src/main/resources/application-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ lyy:
1515
username: ${EMAIL_USERNAME}
1616
password: ${EMAIL_PASSWORD}
1717
baidu:
18+
isOpen: ${BAIDU_IS_OPEN}
1819
clientKey: ${BAIDU_CLIENT_KEY}
1920
clientSecret: ${BAIDU_CLIENT_SECRET}
2021
refreshToken: ${BAIDU_REFRESH_TOKEN}

blog/src/main/resources/application-pro.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ lyy:
1515
username: ${EMAIL_USERNAME}
1616
password: ${EMAIL_PASSWORD}
1717
baidu:
18+
isOpen: ${BAIDU_IS_OPEN}
1819
clientKey: ${BAIDU_CLIENT_KEY}
1920
clientSecret: ${BAIDU_CLIENT_SECRET}
2021
refreshToken: ${BAIDU_REFRESH_TOKEN}

0 commit comments

Comments
 (0)