mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
新增 微信第三方平台 拼接授权链接接口
This commit is contained in:
@@ -7,6 +7,7 @@ import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.domain.AuthorizationEventResult;
|
||||
import com.jsowell.pile.domain.agentDev.CategoryInfo;
|
||||
import com.jsowell.pile.dto.agentDev.CommitCodeDTO;
|
||||
import com.jsowell.pile.dto.agentDev.ConcatenateAuthLinkDTO;
|
||||
import com.jsowell.pile.dto.agentDev.GetComponentTokenDTO;
|
||||
import com.jsowell.pile.dto.agentDev.SubmitAuditDTO;
|
||||
import com.jsowell.pile.vo.agentDev.AuthInfoVO;
|
||||
@@ -108,6 +109,27 @@ public class AgentDevController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接授权链接
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/concatenateAuthLinks")
|
||||
public RestApiResponse<?> concatenateAuthLinks(@RequestBody ConcatenateAuthLinkDTO dto) {
|
||||
logger.info("第三方平台 拼接授权链接 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String url = agentDevService.concatenateAuthLinks(dto);
|
||||
response = new RestApiResponse<>(url);
|
||||
} catch (Exception e) {
|
||||
logger.error("第三方平台 拼接授权链接 error, ", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("第三方平台 拼接授权链接 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用授权码获取授权信息
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jsowell.service;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.http.HttpUtils;
|
||||
@@ -12,6 +13,7 @@ import com.jsowell.common.util.wxplatform.WXXmlToMapUtil;
|
||||
import com.jsowell.pile.domain.agentDev.AuditItem;
|
||||
import com.jsowell.pile.domain.agentDev.CategoryInfo;
|
||||
import com.jsowell.pile.dto.agentDev.CommitCodeDTO;
|
||||
import com.jsowell.pile.dto.agentDev.ConcatenateAuthLinkDTO;
|
||||
import com.jsowell.pile.dto.agentDev.GetComponentTokenDTO;
|
||||
import com.jsowell.pile.dto.agentDev.SubmitAuditDTO;
|
||||
import com.jsowell.pile.vo.agentDev.AuthInfoVO;
|
||||
@@ -132,6 +134,7 @@ public class AgentDevService {
|
||||
/**
|
||||
* 小程序/公众号授权事件
|
||||
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/authorize_event.html
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
private void authorizedInform(Map<String, String> map) {
|
||||
@@ -323,6 +326,7 @@ public class AgentDevService {
|
||||
|
||||
/**
|
||||
* 提交代码审核
|
||||
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/code-management/submitAudit.html
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
@@ -400,6 +404,29 @@ public class AgentDevService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼接授权链接
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public String concatenateAuthLinks(ConcatenateAuthLinkDTO dto) {
|
||||
String versionType = dto.getVersionType();
|
||||
String url = "";
|
||||
if (StringUtils.equals(Constants.ONE, versionType)) {
|
||||
// 1-PC版链接
|
||||
url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=" + dto.getPlatformAppID()
|
||||
+ "&pre_auth_code=" + dto.getPreAuthCode() + "&redirect_uri=" + dto.getRedirectUri() + "&auth_type=" + dto.getAuthType();
|
||||
} else {
|
||||
// 2-H5版链接
|
||||
url = "https://open.weixin.qq.com/wxaopen/safe/bindcomponent?action=bindcomponent&no_scan=1&component_appid=" + dto.getPlatformAppID()
|
||||
+ "&pre_auth_code=" + dto.getPreAuthCode() + "&redirect_uri=" + dto.getRedirectUri() + "&auth_type=" + dto.getAuthType();
|
||||
}
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONArray array = new JSONArray();
|
||||
array.set(0, "1");
|
||||
|
||||
Reference in New Issue
Block a user