first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.kimgo.wepush.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.kimgo.wepush.config.UserConfig;
|
||||
import com.kimgo.wepush.mapper.ApiSettingMapper;
|
||||
import com.kimgo.wepush.model.ApiSetting;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ApiSettingService {
|
||||
private final Logger logger = LoggerFactory.getLogger(ApiSettingService.class);
|
||||
private ApiSetting apiSetting;
|
||||
@Autowired
|
||||
private ApiSettingMapper apiSettingMapper;
|
||||
@Autowired
|
||||
private UserConfig userConfig;
|
||||
public ApiSetting getApiSetting() {
|
||||
if (apiSetting == null) {
|
||||
queryApiSetting();
|
||||
}
|
||||
return apiSetting;
|
||||
}
|
||||
private void queryApiSetting(){
|
||||
String phoneNumberToSearch = userConfig.getPhoneNumber();
|
||||
QueryWrapper<ApiSetting> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("phone_number", phoneNumberToSearch);
|
||||
logger.info("wrapper: {}",wrapper);
|
||||
ApiSetting result = apiSettingMapper.selectOne(wrapper);
|
||||
logger.info("result: {}",result);
|
||||
if (result == null){
|
||||
apiSetting = null;
|
||||
logger.error("updateAccessToken error");
|
||||
}
|
||||
apiSetting = result;
|
||||
logger.info("get apiSetting from mysql,accessToken: {}",apiSetting);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user