From f7e1a6002bf0e28a48b3efbe723fe3a6aef9dc03 Mon Sep 17 00:00:00 2001 From: qiushengjie Date: Tue, 29 Aug 2023 19:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E9=80=A0=E6=8E=88=E6=9D=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ms/api/DsTestJavaRequestService.java | 5 +- .../src/main/java/com/ms/api/bo/ShopBO.java | 75 +++++++++++++++++++ .../com/ms/api/common/SPIBaseService.java | 21 +++++- .../spi/auth/GetPlatformAuthUrlService.java | 17 +++-- 4 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 ms-biz/src/main/java/com/ms/api/bo/ShopBO.java diff --git a/ms-biz/src/main/java/com/ms/api/DsTestJavaRequestService.java b/ms-biz/src/main/java/com/ms/api/DsTestJavaRequestService.java index 92cda5e8..49c25ed1 100644 --- a/ms-biz/src/main/java/com/ms/api/DsTestJavaRequestService.java +++ b/ms-biz/src/main/java/com/ms/api/DsTestJavaRequestService.java @@ -24,14 +24,13 @@ import java.util.*; @Slf4j public class DsTestJavaRequestService implements ExtensionServiceHandler { -// @Autowired -// private DsFormRequestTemplate dsFormRequestTemplate; - @Autowired private DsJsonRequestTemplate dsJsonRequestTemplate; @Override public BaseResponse handle(BaseRequest req) { + log.info(""); + HashMap params = new HashMap<>(); List arrayString = new ArrayList<>(); diff --git a/ms-biz/src/main/java/com/ms/api/bo/ShopBO.java b/ms-biz/src/main/java/com/ms/api/bo/ShopBO.java new file mode 100644 index 00000000..6e16b3bd --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/bo/ShopBO.java @@ -0,0 +1,75 @@ +package com.ms.api.bo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ShopBO { + + /** + * shop_id + */ + private Long shopId; + + /** + * shop_name + */ + private String shopName; + + /** + * access_token + */ + private String accessToken; + + /** + * refresh_token + */ + private String refreshToken; + + /** + * expires_in + */ + private String expiresIn; + + /** + * last_login_ip + */ + private String lastLoginIp; + + /** + * total_product + */ + private Integer totalProduct; + + /** + * total_move_detail + */ + private Integer totalMoveDetail; + + /** + * app_version + */ + private String appVersion; + + /** + * gmt_last_login + */ + private Date gmtLastLogin; + + /** + * gmt_expire + */ + private Date gmtExpire; + + /** + * gmt_create + */ + private Date gmtCreate; + + /** + * gmt_modified + */ + private Date gmtModified; + +} diff --git a/ms-biz/src/main/java/com/ms/api/common/SPIBaseService.java b/ms-biz/src/main/java/com/ms/api/common/SPIBaseService.java index dd548ba9..3001f969 100644 --- a/ms-biz/src/main/java/com/ms/api/common/SPIBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/SPIBaseService.java @@ -1,9 +1,28 @@ package com.ms.api.common; +import com.jinritemai.cloud.base.api.BaseRequest; +import com.jinritemai.cloud.base.api.BaseResponse; +import com.jinritemai.cloud.base.api.ExtensionServiceHandler; +import com.ms.api.bo.ShopBO; +import com.ms.dal.entity.Shop; + /** * SPI基础类 */ -public class SPIBaseService { +public class SPIBaseService implements ExtensionServiceHandler { + + protected String shopId; + protected ShopBO shopInfo; + + @Override + public BaseResponse handle(BaseRequest req) { + shopId = req.getAuthId(); + + // TODO 后面可以改为redis + // TODO 数据库查下shopId 有就注入到shopInfo中,没有要新增, + // TODO 并且调用抖店的查询店铺详情接口补充详情,可以是accesToken那个接口 + return null; + } } diff --git a/ms-biz/src/main/java/com/ms/api/spi/auth/GetPlatformAuthUrlService.java b/ms-biz/src/main/java/com/ms/api/spi/auth/GetPlatformAuthUrlService.java index f7e751f9..6abb3b1f 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/auth/GetPlatformAuthUrlService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/auth/GetPlatformAuthUrlService.java @@ -8,25 +8,30 @@ import com.ms.api.common.R; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.auth.GetPlatformAuthUrlRequestDTO; import com.ms.api.tool.DsFormRequestTemplate; +import com.ms.api.tool.DsJsonRequestTemplate; import com.ms.api.tool.SecurityTool; import com.ms.api.common.UniqueKeyMultiValueMap; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.MultiValueMap; +import java.util.HashMap; + /** * 获取授权1688地址 * 抖店店铺未与任何1688账户绑定,可以通过当前连接获取与1688账户进行授权绑定 */ @ExtensionService("getPlatformAuthUrl") @Slf4j -public class GetPlatformAuthUrlService extends SPIBaseService implements ExtensionServiceHandler { +public class GetPlatformAuthUrlService extends SPIBaseService { @Autowired - private DsFormRequestTemplate dsFormRequestTemplate; + private DsJsonRequestTemplate dsJsonRequestTemplate; @Override public BaseResponse handle(BaseRequest req) { + super.handle(req); + // ----参数校验---- GetPlatformAuthUrlRequestDTO fields = req.getData(); @@ -35,12 +40,12 @@ public class GetPlatformAuthUrlService extends SPIBaseService implements Extensi // ----业务处理---- // TODO 群里讨论过说,先判断下获取授权信息列表,如果授权过,就不用再获取这个链接 open/platform_shop/get_platform_auth_url - MultiValueMap params = new UniqueKeyMultiValueMap<>(); - params.add("userId", SecurityTool.encodeByAES(fields.getUserId())); - params.add("platform","ddMicroApp"); + HashMap params = new HashMap<>(); + params.put("userId", SecurityTool.encodeByAES(shopId)); + params.put("platform","ddMicroApp"); String res = null; try { - res = dsFormRequestTemplate.execute("/platform_shop/getPlatformAuthUrl", params); + res = dsJsonRequestTemplate.execute("/platform_shop/getPlatformAuthUrl", params); log.info(res); } catch (Exception e) { e.printStackTrace();