From a0fcdabfdff6791b68dca429bfb4c3d8a9cd7fdc Mon Sep 17 00:00:00 2001 From: qiushengjie Date: Wed, 30 Aug 2023 00:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ms/api/TestSignService.java | 2 -- .../java/com/ms/api/common/SPIBaseService.java | 17 ++++++----------- .../com/ms/api/tool/DsJsonRequestTemplate.java | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/TestSignService.java b/ms-biz/src/main/java/com/ms/api/TestSignService.java index 2d540b06..cd721a84 100644 --- a/ms-biz/src/main/java/com/ms/api/TestSignService.java +++ b/ms-biz/src/main/java/com/ms/api/TestSignService.java @@ -24,8 +24,6 @@ public class TestSignService implements ExtensionServiceHandler @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/common/SPIBaseService.java b/ms-biz/src/main/java/com/ms/api/common/SPIBaseService.java index c533ac70..d6afe318 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 @@ -44,23 +44,19 @@ public class SPIBaseService { // 更新信息,根据请求抖店接口的结果,可失败 if (StringUtils.isEmpty(shop.getShopName())) { try { + String code = "df020f1c-37ed-41b5-8341-85d3d3b02250"; TokenCreateRequest request = new TokenCreateRequest(); TokenCreateParam param = request.getParam(); - param.setCode("df020f1c-37ed-41b5-8341-85d3d3b02250"); + param.setCode(code); param.setGrantType("authorization_code"); TokenCreateResponse response = request.execute(); log.info("TokenCreateResponse:" + JSON.toJSONString(response)); if (response.isSuccess()) { TokenCreateData data = response.getData(); - Long shopId = data.getShopId(); - String accessToken = data.getAccessToken(); - Long expiresIn = data.getExpiresIn(); - String shopName = data.getShopName(); - String refreshToken = data.getRefreshToken(); - shop.setShopName(shopName); - shop.setAccessToken(SecurityTool.encodeByAES(accessToken)); // 加密 - shop.setRefreshToken(SecurityTool.encodeByAES(refreshToken)); // 加密 - shop.setExpiresIn(expiresIn.toString()); // TODO 这个可能是时间格式,转成时间 + shop.setShopName(data.getShopName()); + shop.setAccessToken(SecurityTool.encodeByAES(data.getAccessToken())); // 加密 + shop.setRefreshToken(SecurityTool.encodeByAES(data.getRefreshToken())); // 加密 + shop.setExpiresIn(data.getExpiresIn().toString()); // TODO 这里使用时间格式 } shopService.updateByPrimaryKey(shop); } catch (Exception e) { @@ -70,6 +66,5 @@ public class SPIBaseService { ModelMapper modelMapper = new ModelMapper(); shopInfo = modelMapper.map(shop, ShopBO.class); - } } diff --git a/ms-biz/src/main/java/com/ms/api/tool/DsJsonRequestTemplate.java b/ms-biz/src/main/java/com/ms/api/tool/DsJsonRequestTemplate.java index 54885c52..69c7e29b 100644 --- a/ms-biz/src/main/java/com/ms/api/tool/DsJsonRequestTemplate.java +++ b/ms-biz/src/main/java/com/ms/api/tool/DsJsonRequestTemplate.java @@ -68,9 +68,12 @@ public class DsJsonRequestTemplate { sb.append(dsToken); for (String s : keyArray) { sb.append(s).append(JSON.toJSONString(params.get(s))); +// sb.append(s).append(params.get(s)); } sb.append(dsToken); + log.info("row sign sb:" + sb); String sign = SecureUtil.md5(sb.toString()); + log.info("sign:" + sign); headers.set("x-dd-micro-app-sign", sign); return cloudRequestTemplate.executePost(dsHost + url, JSON.toJSONString(params), headers);