From 37bac23a5fa03ee24b90ed550ac9927419202ba1 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 19 Jan 2021 15:56:20 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B0=86jcetApiService=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=8C=96=EF=BC=8C=E4=BB=8E@Component=E6=94=B9?= =?UTF-8?q?=E4=B8=BAThirdplatConfig=E4=B8=AD=E7=BB=9F=E4=B8=80=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/thirdplat/apiservice/jcet/JcetApiService.java | 2 -- .../epmet/commons/thirdplat/config/ThirdplatConfig.java | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index 7100d71b3b..b6a01d729d 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -11,13 +11,11 @@ import com.epmet.commons.thirdplat.properties.JcetThirdplatProps; import com.epmet.commons.thirdplat.properties.ThirdplatProps; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; -import org.springframework.stereotype.Component; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; -@Component public class JcetApiService extends AbstractApiService { private JcetThirdplatProps jcetThirdplatProps; diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java index 16258ed150..4e8f0dbf3d 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java @@ -1,7 +1,9 @@ package com.epmet.commons.thirdplat.config; +import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; import com.epmet.commons.thirdplat.properties.ThirdplatProps; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** @@ -11,4 +13,9 @@ import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties(ThirdplatProps.class) public class ThirdplatConfig { + @Bean + public JcetApiService JcetApiService(ThirdplatProps props) { + return new JcetApiService(props); + } + } From 9c6835bb48f3fcc1dbeb30d9804ab2f5bb720ee4 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 19 Jan 2021 16:11:20 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=94=9F=E6=88=90=E7=AD=BE=E5=90=8D=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E4=BB=A3=E6=9B=BF=E9=AD=94=E6=B3=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/thirdplat/apiservice/jcet/JcetApiService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index b6a01d729d..b24803fa09 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -83,10 +83,10 @@ public class JcetApiService extends AbstractApiService { Map headers = new HashMap(); long timestamp = System.currentTimeMillis(); - headers.put("openTimestamp", String.valueOf(timestamp)); - headers.put("openAppId", jcetThirdplatProps.getAppkey()); + headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, String.valueOf(timestamp)); + headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, jcetThirdplatProps.getAppkey()); String encryptContent = jcetThirdplatProps.getAppkey() + timestamp + bodyLength; - headers.put("openSign", SignUtils.generate(encryptContent, jcetThirdplatProps.getAppsecret())); + headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, jcetThirdplatProps.getAppsecret())); return headers; } From 9d7b1cfff265a1a659278fdedc50099841f83bf0 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 19 Jan 2021 17:49:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?login=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java b/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java index 88b4f56389..235525cfe8 100644 --- a/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java +++ b/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java @@ -9,7 +9,7 @@ public interface SsoConstant { /** * 酒城e通appId */ - String WINE_CITY_E_OPEN_APP_ID = ""; + String WINE_CITY_E_OPEN_APP_ID = "hw0f263b5d3dc4f7c5"; String USER_INFO_IS_NULL = "【jcetApiService.getUserInfoByTicket(formDTO.getTicket()】结果为空......"; From facda9c629e266b487c809fce525858fe183a850 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 19 Jan 2021 18:20:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7byTicket=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/SsoController.java | 18 ++++++++++++++ .../apiservice/AbstractApiService.java | 4 +++- .../dto/result/jcet/UserInfoResultDTO.java | 24 +++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java index 3251b5a06c..cc53f86f2e 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java @@ -1,5 +1,7 @@ package com.epmet.controller; +import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; +import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.SsoLoginFormDTO; @@ -11,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.io.UnsupportedEncodingException; + /** * @Author zxc * @DateTime 2021/1/18 下午4:33 @@ -22,6 +26,9 @@ public class SsoController { @Autowired private SsoService ssoService; + @Autowired + private JcetApiService jcetApiService; + /** * @Description 0、入口:得到token * @Param formDTO @@ -34,4 +41,15 @@ public class SsoController { return new Result().ok(ssoService.ssoLogin(formDTO)); } + @PostMapping("testlogin") + public Result testssoLogin(){ + UserInfoResultDTO userInfoByTicket = null; + try { + userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return new Result().ok(userInfoByTicket); + } + } diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java index 7950526fd1..b0aa1e0d0b 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java @@ -1,6 +1,7 @@ package com.epmet.commons.thirdplat.apiservice; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.epmet.commons.thirdplat.dto.result.jcet.JcetResult; import com.epmet.commons.thirdplat.properties.ThirdplatProps; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -29,6 +30,7 @@ public class AbstractApiService { jcetResult.getMsg().concat(",错误码:") + jcetResult.getCode()); } - return JSON.parseObject(jcetResult.getMsg(), resultType); + JSONObject jo = (JSONObject) jcetResult.getData(); + return jo.toJavaObject(resultType); } } diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java index 5adf33436d..09fc1bcace 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java @@ -4,10 +4,26 @@ import lombok.Data; @Data public class UserInfoResultDTO { - - private String name; + private String id; + /** + * 用户名称 + */ + private String userName; + /** + * 手机号码 + */ private String mobile; - private String uid; - private String account; + /** + * 姓名 + */ + private String name; + /** + * 邮箱 + */ + private String email; + /** + * sessionId,用于维持在线状态 + */ + private String oaSessionId; } From 0d4c800432443f53f16b4402e60e2d74dc8c545d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 19 Jan 2021 18:27:23 +0800 Subject: [PATCH 5/5] =?UTF-8?q?login=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/service/impl/SsoServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index bafae81684..482738566f 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -74,6 +74,8 @@ public class SsoServiceImpl implements SsoService { } UserInfoFormDTO userInfoFormDTO = ConvertUtils.sourceToTarget(userInfo, UserInfoFormDTO.class); userInfoFormDTO.setApp(formDTO.getApp()); + userInfoFormDTO.setUid(userInfo.getId()); + userInfoFormDTO.setName(userInfo.getUserName()); Result userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO); if (!userDTOResult.success()){ throw new RenException(SsoConstant.INSERT_UPDATE_USER_FAILURE);