mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +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");
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.jsowell.pile.dto.agentDev;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拼接授权链接 DTO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/7/31 14:04
|
||||
*/
|
||||
@Data
|
||||
public class ConcatenateAuthLinkDTO {
|
||||
/**
|
||||
* 第三方平台方 appid
|
||||
*/
|
||||
private String platformAppID;
|
||||
|
||||
/**
|
||||
* 预授权码
|
||||
*/
|
||||
private String preAuthCode;
|
||||
|
||||
/**
|
||||
* 授权回调 URI (填写格式为https://xxx)
|
||||
*/
|
||||
private String redirectUri;
|
||||
|
||||
/**
|
||||
* 要授权的账号类型,即商家点击授权链接或者扫了授权码之后,展示在用户手机端的授权账号类型。
|
||||
*
|
||||
* - 1 表示手机端仅展示公众号;2 表示仅展示小程序,3 表示公众号和小程序都展示。如果为未指定,则默认小程序和公众号都展示。
|
||||
* - 第三方平台开发者可以使用本字段来控制授权的账号类型。
|
||||
* - 对于已经注销、冻结、封禁、以及未完成注册的账号不再出现于授权账号列表。
|
||||
*/
|
||||
private String authType;
|
||||
|
||||
/**
|
||||
* 指定授权唯一的小程序或公众号
|
||||
*
|
||||
* - 如果指定了appid,则只能是该appid的管理员进行授权,其他用户扫码会出现报错。
|
||||
* - auth_type、biz_appid 两个字段如果设置的信息冲突,则biz_appid生效的优先级更高。
|
||||
* - 例如,auth_type=1,但是biz_appid是小程序的appid,则会按照auth_type=2来处理,即以biz_appid的类型为准去拉出来对应的权限集列表.
|
||||
*/
|
||||
private String bizAppid;
|
||||
|
||||
/**
|
||||
* 指定的权限集id列表,如果不指定,则默认拉取当前第三方账号已经全网发布的权限集列表
|
||||
*
|
||||
* - 如需要指定单个权限集ID,写法为“category_id_list=99” ,如果有多个权限集,则权限集id与id之间用中竖线隔开。
|
||||
*/
|
||||
private List<String> categoryIdList;
|
||||
|
||||
/**
|
||||
* 版本类型
|
||||
* 1 - PC版
|
||||
* 2 - H5版
|
||||
*/
|
||||
private String versionType;
|
||||
}
|
||||
Reference in New Issue
Block a user