|
@@ -9,12 +9,14 @@ import com.sxtvs.open.core.conf.OauthConfig;
|
|
|
import com.sxtvs.open.core.sls.AliyunLogger;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.apache.hc.client5.http.fluent.Request;
|
|
|
+import org.apache.hc.core5.http.ContentType;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.time.Duration;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
@Service
|
|
@@ -53,6 +55,8 @@ public class OauthService {
|
|
|
authCodeRequest.setComponentAccessToken(ticket);
|
|
|
var body = Request.post("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?" +
|
|
|
"component_access_token=" + ticket)
|
|
|
+ .bodyString(objectMapper.writeValueAsString(Map.of("component_access_token", ticket, "component_appid", OauthConfig.wxClientKey)),
|
|
|
+ ContentType.APPLICATION_JSON)
|
|
|
.execute()
|
|
|
.returnContent()
|
|
|
.asString(StandardCharsets.UTF_8);
|