重新封装
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package org.jiayunet.controller;
|
package org.jiayunet.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.jiayunet.remote.jsxq.JsxqClient;
|
import org.jiayunet.remote.jsxq.JsxqClient;
|
||||||
import org.jiayunet.remote.jsxq.pojo.JsxqPage;
|
import org.jiayunet.remote.jsxq.pojo.JsxqPage;
|
||||||
@@ -9,6 +8,7 @@ import org.jiayunet.remote.jsxq.pojo.dto.MentorFullInfoDto;
|
|||||||
import org.jiayunet.remote.jsxq.pojo.dto.MentorItemDto;
|
import org.jiayunet.remote.jsxq.pojo.dto.MentorItemDto;
|
||||||
import org.jiayunet.remote.jsxq.pojo.dto.TeacherTalkDto;
|
import org.jiayunet.remote.jsxq.pojo.dto.TeacherTalkDto;
|
||||||
import org.jiayunet.remote.jsxq.pojo.param.MentorPageParam;
|
import org.jiayunet.remote.jsxq.pojo.param.MentorPageParam;
|
||||||
|
import org.jiayunet.remote.jsxq.pojo.param.QrCodeParam;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class MentorController {
|
|||||||
* 获取二维码
|
* 获取二维码
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getQrCode")
|
@PostMapping("/getQrCode")
|
||||||
public Map<String, Object> getQrCode(@RequestBody JSONObject data) {
|
public Map<String, Object> getQrCode(@Validated @RequestBody QrCodeParam param) {
|
||||||
return jsxqClient.getQrCode(data);
|
return jsxqClient.getQrCode(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,5 @@ app:
|
|||||||
# 简史星球开放平台配置
|
# 简史星球开放平台配置
|
||||||
jsxq:
|
jsxq:
|
||||||
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
||||||
token: ${JSXQ_TOKEN:f69b5086-97b0-4e5e-b172-453e444d448c}
|
|
||||||
tenant-id: ${JSXQ_TENANT_ID:1}
|
tenant-id: ${JSXQ_TENANT_ID:1}
|
||||||
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
||||||
|
|||||||
@@ -109,6 +109,5 @@ app:
|
|||||||
# 简史星球开放平台配置
|
# 简史星球开放平台配置
|
||||||
jsxq:
|
jsxq:
|
||||||
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
||||||
token: ${JSXQ_TOKEN:f69b5086-97b0-4e5e-b172-453e444d448c}
|
|
||||||
tenant-id: ${JSXQ_TENANT_ID:1}
|
tenant-id: ${JSXQ_TENANT_ID:1}
|
||||||
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
||||||
|
|||||||
@@ -110,6 +110,5 @@ app:
|
|||||||
# 简史星球开放平台配置
|
# 简史星球开放平台配置
|
||||||
jsxq:
|
jsxq:
|
||||||
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
base-url: ${JSXQ_BASE_URL:https://jsxq.jianshixingqiu.com/api/admin}
|
||||||
token: ${JSXQ_TOKEN:f69b5086-97b0-4e5e-b172-453e444d448c}
|
|
||||||
tenant-id: ${JSXQ_TENANT_ID:1}
|
tenant-id: ${JSXQ_TENANT_ID:1}
|
||||||
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
client-toc: ${JSXQ_CLIENT_TOC:Y}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.jiayunet.remote.jsxq;
|
package org.jiayunet.remote.jsxq;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -17,6 +16,7 @@ import org.jiayunet.remote.jsxq.pojo.dto.MentorFullInfoDto;
|
|||||||
import org.jiayunet.remote.jsxq.pojo.dto.MentorItemDto;
|
import org.jiayunet.remote.jsxq.pojo.dto.MentorItemDto;
|
||||||
import org.jiayunet.remote.jsxq.pojo.dto.TeacherTalkDto;
|
import org.jiayunet.remote.jsxq.pojo.dto.TeacherTalkDto;
|
||||||
import org.jiayunet.remote.jsxq.pojo.param.MentorPageParam;
|
import org.jiayunet.remote.jsxq.pojo.param.MentorPageParam;
|
||||||
|
import org.jiayunet.remote.jsxq.pojo.param.QrCodeParam;
|
||||||
import org.jiayunet.tool.HttpTool;
|
import org.jiayunet.tool.HttpTool;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -85,20 +85,17 @@ public class JsxqClient {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取二维码
|
* 获取二维码(开放接口,无需token,由TENANT-ID + CLIENT-TOC鉴权)
|
||||||
* <p>POST /getQrCode</p>
|
* <p>POST /public/website/getQrCode</p>
|
||||||
|
* <p>入参:path(小程序页面路径)、teacherId(老师ID)、loginAppid(小程序appid)</p>
|
||||||
|
* <p>返回:data.code 为 base64 编码的二维码图片(data:image/png;base64,...)</p>
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getQrCode(JSONObject data) {
|
public Map<String, Object> getQrCode(QrCodeParam param) {
|
||||||
JavaType type = HttpTool.objectMapper.getTypeFactory()
|
JavaType type = HttpTool.objectMapper.getTypeFactory()
|
||||||
.constructMapType(Map.class, String.class, Object.class);
|
.constructMapType(Map.class, String.class, Object.class);
|
||||||
return post("/getQrCode", data, type);
|
return post("/public/website/getQrCode", param, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ============================ 底层通用调用 ============================
|
// ============================ 底层通用调用 ============================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,11 +157,11 @@ public class JsxqClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建公共请求头:Authorization / TENANT-ID / CLIENT-TOC
|
* 构建公共请求头:TENANT-ID / CLIENT-TOC
|
||||||
|
* <p>当前对接的均为简史星球开放接口(/public/website/),无需 Authorization</p>
|
||||||
*/
|
*/
|
||||||
private Map<String, String> buildHeaders() {
|
private Map<String, String> buildHeaders() {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("Authorization", "Bearer " + properties.getToken());
|
|
||||||
headers.put("TENANT-ID", properties.getTenantId());
|
headers.put("TENANT-ID", properties.getTenantId());
|
||||||
headers.put("CLIENT-TOC", properties.getClientToc());
|
headers.put("CLIENT-TOC", properties.getClientToc());
|
||||||
return headers;
|
return headers;
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ public class JsxqProperties {
|
|||||||
/** 平台基础地址(含网关前缀),如 https://jsxq.jianshixingqiu.com/api/admin */
|
/** 平台基础地址(含网关前缀),如 https://jsxq.jianshixingqiu.com/api/admin */
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
/** 访问令牌,作为 Authorization: Bearer {token} */
|
|
||||||
private String token;
|
|
||||||
|
|
||||||
/** 租户ID,作为 TENANT-ID 请求头 */
|
/** 租户ID,作为 TENANT-ID 请求头 */
|
||||||
private String tenantId = "1";
|
private String tenantId = "1";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.jiayunet.remote.jsxq.pojo.param;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简史星球-获取小程序二维码入参
|
||||||
|
* <p>对应接口 POST /public/website/getQrCode</p>
|
||||||
|
*
|
||||||
|
* @author zk
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QrCodeParam {
|
||||||
|
|
||||||
|
/** 小程序页面路径,如 pages/teacher/teacher */
|
||||||
|
@NotBlank(message = "path不能为空")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/** 老师ID */
|
||||||
|
@NotBlank(message = "teacherId不能为空")
|
||||||
|
private String teacherId;
|
||||||
|
|
||||||
|
/** 小程序appid */
|
||||||
|
@NotBlank(message = "loginAppid不能为空")
|
||||||
|
private String loginAppid;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user