Browse Source

Merge remote-tracking branch 'origin/dev_jcet' into dev_temp

dev_shibei_match
zxc 5 years ago
parent
commit
fcd1df887b
  1. 2
      epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java
  2. 18
      epmet-auth/src/main/java/com/epmet/controller/SsoController.java
  3. 2
      epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
  4. 4
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java
  5. 8
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java
  6. 7
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java
  7. 24
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java

2
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()】结果为空......";

18
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<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO));
}
@PostMapping("testlogin")
public Result<UserInfoResultDTO> testssoLogin(){
UserInfoResultDTO userInfoByTicket = null;
try {
userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return new Result<UserInfoResultDTO>().ok(userInfoByTicket);
}
}

2
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<UserDTO> userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO);
if (!userDTOResult.success()){
throw new RenException(SsoConstant.INSERT_UPDATE_USER_FAILURE);

4
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);
}
}

8
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<String, String> 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;
}

7
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);
}
}

24
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;
}

Loading…
Cancel
Save