Commit 8552e86d8adec7b8dab4985c9606e896160fcb32

Authored by puhui999
1 parent 12ae5bf1

完善三方登录

yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientBaseVO.java
@@ -24,14 +24,17 @@ public class SocialClientBaseVO { @@ -24,14 +24,17 @@ public class SocialClientBaseVO {
24 @NotNull(message = "用户类型不能为空") 24 @NotNull(message = "用户类型不能为空")
25 private Integer userType; 25 private Integer userType;
26 26
27 - @Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "145442115") 27 + @Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "wwd411c69a39ad2e54")
28 @NotNull(message = "客户端编号不能为空") 28 @NotNull(message = "客户端编号不能为空")
29 private String clientId; 29 private String clientId;
30 30
31 - @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "215151515154446") 31 + @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "1wTb7hYxnpT2TUbIeHGXGo7T0odav1ic10mLdyyATOw")
32 @NotNull(message = "客户端密钥不能为空") 32 @NotNull(message = "客户端密钥不能为空")
33 private String clientSecret; 33 private String clientSecret;
34 34
  35 + @Schema(description = "授权方的网页应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000045")
  36 + private String agentId;
  37 +
35 @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 38 @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
36 @NotNull(message = "状态不能为空") 39 @NotNull(message = "状态不能为空")
37 private Integer status; 40 private Integer status;
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUser @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUser
9 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserUpdateReqVO; 9 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserUpdateReqVO;
10 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; 10 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
11 import org.mapstruct.Mapper; 11 import org.mapstruct.Mapper;
  12 +import org.mapstruct.Mapping;
12 import org.mapstruct.factory.Mappers; 13 import org.mapstruct.factory.Mappers;
13 14
14 import java.util.List; 15 import java.util.List;
@@ -18,6 +19,7 @@ public interface SocialUserConvert { @@ -18,6 +19,7 @@ public interface SocialUserConvert {
18 19
19 SocialUserConvert INSTANCE = Mappers.getMapper(SocialUserConvert.class); 20 SocialUserConvert INSTANCE = Mappers.getMapper(SocialUserConvert.class);
20 21
  22 + @Mapping(target = "socialType", source = "reqVO.type")
21 SocialUserBindReqDTO convert(Long userId, Integer userType, SocialUserBindReqVO reqVO); 23 SocialUserBindReqDTO convert(Long userId, Integer userType, SocialUserBindReqVO reqVO);
22 24
23 SocialUserUnbindReqDTO convert(Long userId, Integer userType, SocialUserUnbindReqVO reqVO); 25 SocialUserUnbindReqDTO convert(Long userId, Integer userType, SocialUserUnbindReqVO reqVO);
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/social/SocialClientDO.java
@@ -64,5 +64,9 @@ public class SocialClientDO extends TenantBaseDO { @@ -64,5 +64,9 @@ public class SocialClientDO extends TenantBaseDO {
64 * 客户端 Secret 64 * 客户端 Secret
65 */ 65 */
66 private String clientSecret; 66 private String clientSecret;
  67 + /**
  68 + * 授权方的网页应用 ID
  69 + */
  70 + private String agentId;
67 71
68 } 72 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
@@ -159,6 +159,9 @@ public class SocialClientServiceImpl implements SocialClientService { @@ -159,6 +159,9 @@ public class SocialClientServiceImpl implements SocialClientService {
159 // 2.2 修改对应的 clientId + clientSecret 密钥 159 // 2.2 修改对应的 clientId + clientSecret 密钥
160 newAuthConfig.setClientId(client.getClientId()); 160 newAuthConfig.setClientId(client.getClientId());
161 newAuthConfig.setClientSecret(client.getClientSecret()); 161 newAuthConfig.setClientSecret(client.getClientSecret());
  162 + if (client.getAgentId() != null) { // 如果有 agentId 则修改 agentId
  163 + newAuthConfig.setAgentId(client.getAgentId());
  164 + }
162 // 2.3 设置会 request 里,进行后续使用 165 // 2.3 设置会 request 里,进行后续使用
163 ReflectUtil.setFieldValue(request, "config", newAuthConfig); 166 ReflectUtil.setFieldValue(request, "config", newAuthConfig);
164 } 167 }