This commit is contained in:
dzc committed 2025-04-01 19:01:42 +08:00
commit fd61046a7d
4 files changed
+45 -11

No files matched your search

@@ -0,0 +1,21 @@
package com.bsd.pjcloud.thirdparty.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 出库入口
*/
@AllArgsConstructor
@Getter
public enum UserTypeEnum {
ZZD("1", "浙政钉用户"),
SH("2", "诗画"),
;
private final String type;
private final String description;
}
@@ -49,12 +49,12 @@ public class ThirdPartyOAth2Cotroller {
private final ThirdPartyUserService thirdPartyUserService;
@Operation(summary = "浙政钉token" )
@GetMapping("/zzd/sso" )
public R getThirdPartyzzdsso(@RequestParam("token")String token) {
return R.ok(thirdPartyOAuth2Service.getZZDUserInfo(token));
}
// @Operation(summary = "浙政钉token" )
// @GetMapping("/zzd/sso" )
// public R getThirdPartyzzdsso(@RequestParam("token")String token) {
// return R.ok(thirdPartyOAuth2Service.getZZDUserInfo(token));
//
// }
@Operation(summary = "诗画token" )
@GetMapping("/sh/sso" )
@@ -104,4 +104,8 @@ public class ThirdPartyLogEntity extends Model<ThirdPartyLogEntity> {
*/
@Schema(description="租户编号")
private Long tenantId;
@Schema(description="请求参数")
private String requestParameter;
}
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.thirdparty.config.OAuth2ClientConfig;
import com.bsd.pjcloud.thirdparty.constant.UserTypeEnum;
import com.bsd.pjcloud.thirdparty.dto.*;
import com.bsd.pjcloud.thirdparty.entity.ThirdPartyDeptEntity;
import com.bsd.pjcloud.thirdparty.entity.ThirdPartyLogEntity;
@@ -367,7 +368,7 @@ public class ThirdPartyOAuth2Service {
//使用token获取当前登录人的信息(浙政钉和诗画的在一起)
// ZZDUserDTO zzdUser = getZZDUserInfo(zzdToken);
ZZDUserDTO zzdUser = getZZDUserInfo(token);
ZZDUserDTO zzdUser = getZZDUserInfo(token,UserTypeEnum.ZZD.getType());
return zzdUser;
}
@@ -390,7 +391,7 @@ public class ThirdPartyOAuth2Service {
* @param zzdToken
* @return
*/
public ZZDUserDTO getZZDUserInfo(String zzdToken) {
public ZZDUserDTO getZZDUserInfo(String zzdToken,String type) {
// 构建请求URL
try {
@@ -413,10 +414,15 @@ public class ThirdPartyOAuth2Service {
if (response.getBody().getCode().equals("-1")){
log.error("获取浙政钉/诗画用户信息失败");
log.error("token",zzdToken);
log.error("response",response.getBody());
ThirdPartyLogEntity thirdPartyLogEntity = new ThirdPartyLogEntity();
thirdPartyLogEntity.setApiName("获取浙政钉/诗画用户信息失败");
if (type.equals(UserTypeEnum.ZZD.getType())){
thirdPartyLogEntity.setApiName(UserTypeEnum.ZZD.getDescription());
}else if (type.equals(UserTypeEnum.SH.getType())){
thirdPartyLogEntity.setApiName(UserTypeEnum.SH.getDescription());
}
// thirdPartyLogEntity.setApiName("获取浙政钉/诗画用户信息失败");
thirdPartyLogEntity.setRequestUrl(url);
thirdPartyLogEntity.setRequestParameter(zzdToken);
thirdPartyLogEntity.setResponseBody(JSON.toJSONString(response.getBody()));
thirdPartyLogEntity.setErrorCode(response.getBody().getCode());
thirdPartyLogEntity.setErrorMsg(response.getBody().getDescription());
@@ -542,7 +548,10 @@ public class ThirdPartyOAuth2Service {
*/
public ZZDUserDTO shjnsso(String accountId, String sessionId) {
String shjnToken = getSHJNToken(accountId, sessionId);
ZZDUserDTO zzdUserDTO = getZZDUserInfo(shjnToken);
if (StringUtils.isEmpty(shjnToken)){
throw new RuntimeException("获取诗画江南token失败");
}
ZZDUserDTO zzdUserDTO = getZZDUserInfo(shjnToken,UserTypeEnum.SH.getType());
return zzdUserDTO;
}
}