first commit

This commit is contained in:
2023-12-05 01:39:52 +08:00
commit 767b08a025
46 changed files with 1739 additions and 0 deletions

View File

@@ -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);
}
}