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 ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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