| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package com.inspur.customer.service.wechat;
- import com.inspur.customer.client.wechat.IWeChatService;
- import com.inspur.customer.context.HttpUrlConstant;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.dubbo.config.annotation.DubboService;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.HttpEntity;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpMethod;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.client.RestTemplate;
- import javax.annotation.Resource;
- /**
- * 发送微信
- *
- * @author wangbo
- * @version 1.0
- * @date 2022/3/9
- */
- @Slf4j
- @DubboService(interfaceClass = IWeChatService.class)
- public class WeChatServiceImpl implements IWeChatService {
- @Resource
- private RestTemplate restTemplate;
- @Value("${msr.idms.top}")
- private String MSR_IDMS_TOP;
- @Override
- public String queryTicket(String appKey, String userId, String authorization) {
- String url = String.format(HttpUrlConstant.QUERY_TICKET.replace("MSR_IDMS_TOP", MSR_IDMS_TOP), userId, appKey);
- HttpHeaders header = new HttpHeaders();
- // header.add("Authorization", authorization);
- ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(header), String.class);
- log.info("获取二维码url: {}", url);
- return response.getBody();
- }
- @Override
- public String askUser(String userId) {
- return restTemplate.getForObject(String.format(HttpUrlConstant.ASK_USER.replace("MSR_IDMS_TOP", MSR_IDMS_TOP), userId), String.class);
- }
- }
|