Files
wePush/src/main/java/com/kimgo/wepush/service/QyWeChatURLService.java

43 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.kimgo.wepush.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kimgo.wepush.config.UserConfig;
import com.kimgo.wepush.mapper.QyWeChatAppInfoMapper;
import com.kimgo.wepush.mapper.QyWeChatURLMapper;
import com.kimgo.wepush.model.QyWeChatAppInfo;
import com.kimgo.wepush.model.QyWeChatURL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QyWeChatURLService {
private final Logger logger = LoggerFactory.getLogger(QyWeChatURLService.class);
@Autowired
private QyWeChatURLMapper qyWeChatURLMapper;
@Autowired
private UserConfig userConfig;
private String sendTextCardMessageUrl;
private String qyWechatGetTokenUrl;
public String getSendTextCardMessageUrl() {
if (sendTextCardMessageUrl == null){
queryURL();
}
return sendTextCardMessageUrl;
}
private void queryURL(){
String phoneNumberToSearch = userConfig.getPhoneNumber();
QueryWrapper<QyWeChatURL> wrapper = new QueryWrapper<>();
wrapper.eq("phone_number", phoneNumberToSearch);
QyWeChatURL result = qyWeChatURLMapper.selectOne(wrapper);
if (result == null){
logger.error("queryURL error");
}
logger.info("queryURL result {}",result.toString());
sendTextCardMessageUrl = result.getSendTextCardMessageUrl();
qyWechatGetTokenUrl = result.getQyWechatGetTokenUrl();
};
}