feat(backend): 添加集材社调用接口
- 新增 HomeController 类,实现集材社调用的接口 - 添加订单信息获取和更新功能 - 使用 Swagger 注解进行接口文档化 -集成幂等性注解防止重复提交
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package org.dromara.web.common;
|
||||
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @author Maosw
|
||||
*/
|
||||
public class WxXcxUtils {
|
||||
|
||||
static String appid = "wxf1d78a0b58fc890c";
|
||||
static String secret = "e1a3e888471d48addf1a23e4c9ea7f84";
|
||||
|
||||
public static String getAccessToken(){
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+secret;
|
||||
String result = HttpUtil.get(url);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
return jsonObject.get("access_token").toString();
|
||||
}
|
||||
|
||||
public static JSONObject getUserPhoneNumber(String code){
|
||||
String accessToken = getAccessToken();
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+accessToken;
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", code);
|
||||
String result = HttpRequest.post(url).body(json.toString()).execute().body();
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user