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()】结果为空......"; 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-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); 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/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index 7100d71b3b..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 @@ -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; @@ -85,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; } 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); + } + } 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; }