diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java index 0bf08e8c2..558967c2e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java @@ -75,6 +75,7 @@ public class SysAuthServiceImpl implements SysAuthService { @Resource private SysSocialService socialService; + // TODO @timfruit:静态枚举类,需要都大写,例如说 USER_TYPE_ENUM;静态变量,放在普通变量前面;这个实践不错哈。 private static final UserTypeEnum userTypeEnum = UserTypeEnum.ADMIN; @Override @@ -214,7 +215,6 @@ public class SysAuthServiceImpl implements SysAuthService { // 创建 LoginUser 对象 LoginUser loginUser = SysAuthConvert.INSTANCE.convert(user); - // TODO 芋艿:需要改造下,增加各种登录方式 loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 // 绑定社交用户(更新) diff --git a/yudao-core-service/pom.xml b/yudao-core-service/pom.xml index d1102ae22..56402180f 100644 --- a/yudao-core-service/pom.xml +++ b/yudao-core-service/pom.xml @@ -86,11 +86,12 @@ guava + com.xkcoding.justauth justauth-spring-boot-starter - 1.4.0 + diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/social/SysSocialUserMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/social/SysSocialUserMapper.java index 43fc4a790..ee8db4eac 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/social/SysSocialUserMapper.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/social/SysSocialUserMapper.java @@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper; import java.util.Collection; import java.util.List; +// TODO @timfruit:SysSocialUserCoreMapper 改名,方便区分 @Mapper public interface SysSocialUserMapper extends BaseMapperX { diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/SysRedisKeyCoreConstants.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/SysRedisKeyCoreConstants.java index 8076980d3..5db3e9fd4 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/SysRedisKeyCoreConstants.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/SysRedisKeyCoreConstants.java @@ -19,11 +19,11 @@ public interface SysRedisKeyCoreConstants { "login_user:%s", // 参数为 sessionId STRING, LoginUser.class, RedisKeyDefine.TimeoutTypeEnum.DYNAMIC); - RedisKeyDefine SOCIAL_AUTH_USER = new RedisKeyDefine("社交的授权用户", + RedisKeyDefine SOCIAL_AUTH_USER = new RedisKeyDefine("社交登陆的授权用户", "social_auth_user:%d:%s", // 参数为 type,code STRING, AuthUser.class, Duration.ofDays(1)); - RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交的 state", + RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state", "social_auth_state:%s", // 参数为 state STRING, String.class, Duration.ofHours(24)); // 值为 state } diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/social/SysSocialAuthUserRedisDAO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/social/SysSocialAuthUserRedisDAO.java index e82c81394..514281071 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/social/SysSocialAuthUserRedisDAO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/redis/social/SysSocialAuthUserRedisDAO.java @@ -10,7 +10,7 @@ import javax.annotation.Resource; import static cn.iocoder.yudao.coreservice.modules.system.dal.redis.SysRedisKeyCoreConstants.SOCIAL_AUTH_USER; - +// TODO @timfruit,这里的 AuthUser 还是保留全路径,主要想体现出来,不是自己定义的 /** * 社交 {@link AuthUser} 的 RedisDAO * diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/social/SysSocialTypeEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/social/SysSocialTypeEnum.java index 592c274a1..8532283c1 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/social/SysSocialTypeEnum.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/social/SysSocialTypeEnum.java @@ -21,6 +21,7 @@ public enum SysSocialTypeEnum implements IntArrayValuable { GITEE(10, "GITEE"), // https://gitee.com/api/v5/oauth_doc#/ DINGTALK(20, "DINGTALK"), // https://developers.dingtalk.com/document/app/obtain-identity-credentials WECHAT_ENTERPRISE(30, "WECHAT_ENTERPRISE"), // https://xkcoding.com/2019/08/06/use-justauth-integration-wechat-enterprise.html + // TODO @timfruit:微信平台,从 30 开始递增哈。另外,尽量不要出现,先 12,然后 11,有序,嘿嘿。 /** * 微信公众平台 - H5 */ diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/SysSocialService.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/SysSocialService.java index 81ee31ecf..ad72a5780 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/SysSocialService.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/SysSocialService.java @@ -15,6 +15,7 @@ import java.util.List; * * @author 芋道源码 */ +// TODO @timfruit:SysSocialCoreService 改名,方便区分 public interface SysSocialService { /** @@ -77,5 +78,6 @@ public interface SysSocialService { * @param unionId 社交平台的 unionId */ void unbindSocialUser(Long userId, Integer type, String unionId,UserTypeEnum userTypeEnum); + // TODO @timfruit:逗号后面要有空格;缺少了 @userTypeEnum 的注释,都补充下哈。 } diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 723ea0c6a..18894b0d9 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -52,6 +52,7 @@ 4.5.25 2.1.0 1.2.7 + 1.4.0 @@ -399,7 +400,6 @@ yunpian-java-sdk ${yunpian-java-sdk.version} - com.aliyun aliyun-java-sdk-core @@ -421,6 +421,13 @@ ${aliyun-java-sdk-dysmsapi.version} + + + com.xkcoding.justauth + justauth-spring-boot-starter + ${justauth.version} + + diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.java index 1e85f427d..a21a56ede 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.userserver.modules.system.controller.auth; import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialService; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.*; import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; import cn.iocoder.yudao.userserver.modules.system.service.sms.SysSmsCodeService; @@ -82,6 +81,7 @@ public class SysAuthController { return CommonResult.success(socialService.getAuthorizeUrl(type, redirectUri)); } + // TODO @timfruit:这个接口,是要删除的么? @GetMapping("/social-login-get") @ApiOperation("微信公众号授权回调地址,输出social-login2的必要参数用于测试,使用 code 授权码") @ResponseBody diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java index 52acc46a3..2394cd03a 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO; -import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeEnum; import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum; import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; @@ -37,7 +36,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import javax.validation.Valid; import java.util.List; import java.util.Objects; @@ -130,8 +128,6 @@ public class SysAuthServiceImpl implements SysAuthService { // 创建 LoginUser 对象 LoginUser loginUser = SysAuthConvert.INSTANCE.convert(user); - // TODO 芋艿:需要改造下,增加各种登录方式 -// loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 // 绑定社交用户(更新) socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser, userTypeEnum); diff --git a/yudao-user-server/src/main/resources/application-dev.yaml b/yudao-user-server/src/main/resources/application-dev.yaml index bbf739864..c015867af 100644 --- a/yudao-user-server/src/main/resources/application-dev.yaml +++ b/yudao-user-server/src/main/resources/application-dev.yaml @@ -142,7 +142,7 @@ yudao: justauth: enabled: true - type: + type: # TODO @timfruit:GITEE、DINGTALK、WECHAT_ENTERPRISE 这个几个,对于用户端是不需要的哈,可以删除噢 GITEE: # Gitee client-id: ee61f0374a4c6c404a8717094caa7a410d76950e45ff60348015830c519ba5c1 client-secret: 7c044a5671be3b051414db0cf2cec6ad702dd298d2416ba24ceaf608e6fa26f9