From a0a5d3a35741cdbbc39e9448b95d912cc87b4185 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 5 Oct 2021 00:36:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=9A=84=E7=A4=BE=E4=BA=A4=E7=99=BB=E9=99=86=E7=9A=84=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=202.=20=E5=B0=86=E4=B8=89=E6=96=B9=E7=99=BB=E9=99=86?= =?UTF-8?q?=EF=BC=8C=E7=BB=9F=E4=B8=80=E6=94=B9=E6=88=90=E7=A4=BE=E4=BA=A4?= =?UTF-8?q?=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/auth/SysAuthController.java | 2 +- .../dal/redis/SysRedisKeyConstants.java | 2 +- .../system/enums/SysErrorCodeConstants.java | 2 +- .../service/auth/impl/SysAuthServiceImpl.java | 2 +- .../system/service/user/SysUserService.java | 8 --- .../service/user/SysUserServiceImpl.java | 21 ++------ yudao-admin-ui/src/utils/constants.js | 22 ++++++-- yudao-admin-ui/src/views/login.vue | 54 ++++++++----------- yudao-admin-ui/src/views/socialLogin.vue | 25 +++++---- 9 files changed, 63 insertions(+), 75 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java index 76b97cd6c..7862ac04b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java @@ -105,7 +105,7 @@ public class SysAuthController { @GetMapping("/social-login-redirect") @ApiOperation("社交登陆的跳转") @ApiImplicitParams({ - @ApiImplicitParam(name = "type", value = "三方类型", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "type", value = "社交类型", required = true, dataTypeClass = Integer.class), @ApiImplicitParam(name = "redirectUri", value = "回调路径", dataTypeClass = String.class) }) public CommonResult socialLoginRedirect(@RequestParam("type") Integer type, diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/redis/SysRedisKeyConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/redis/SysRedisKeyConstants.java index b128fa966..2012ec3a9 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/redis/SysRedisKeyConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/redis/SysRedisKeyConstants.java @@ -23,7 +23,7 @@ public interface SysRedisKeyConstants { "captcha_code:%s", // 参数为 uuid STRING, String.class, RedisKeyDefine.TimeoutTypeEnum.DYNAMIC); - RedisKeyDefine AUTH_SOCIAL_USER = new RedisKeyDefine("认证的三方用户", + RedisKeyDefine AUTH_SOCIAL_USER = new RedisKeyDefine("认证的社交用户", "auth_social_user:%d:%s", // 参数为 type,code STRING, AuthUser.class, Duration.ofDays(1)); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java index 069d2b4ab..487ae1309 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java @@ -17,7 +17,7 @@ public interface SysErrorCodeConstants { ErrorCode AUTH_LOGIN_CAPTCHA_NOT_FOUND = new ErrorCode(1002000003, "验证码不存在"); ErrorCode AUTH_LOGIN_CAPTCHA_CODE_ERROR = new ErrorCode(1002000004, "验证码不正确"); ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1002000005, "未绑定账号,需要进行绑定"); - ErrorCode AUTH_THIRD_OAUTH_FAILURE = new ErrorCode(1002000006, "三方授权失败,原因是:{}"); + ErrorCode AUTH_THIRD_OAUTH_FAILURE = new ErrorCode(1002000006, "社交授权失败,原因是:{}"); // ========== TOKEN 模块 1002001000 ========== ErrorCode TOKEN_EXPIRED = new ErrorCode(1002001000, "Token 已经过期"); 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 1f4159e7b..9b26a8ace 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 @@ -258,7 +258,7 @@ public class SysAuthServiceImpl implements SysAuthService { private AuthUser obtainAuthUser(Integer type, AuthCallback authCallback) { AuthRequest authRequest = authRequestFactory.get(SysSocialTypeEnum.valueOfType(type).getSource()); AuthResponse authResponse = authRequest.login(authCallback); - log.info("[obtainAuthUser][请求三方平台 type({}) request({}) response({})]", type, JsonUtils.toJsonString(authCallback), + log.info("[obtainAuthUser][请求社交平台 type({}) request({}) response({})]", type, JsonUtils.toJsonString(authCallback), JsonUtils.toJsonString(authResponse)); if (!authResponse.ok()) { throw exception(AUTH_THIRD_OAUTH_FAILURE, authResponse.getMsg()); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java index f9e6a1c23..78071d246 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java @@ -34,14 +34,6 @@ public interface SysUserService { */ Long createUser(SysUserCreateReqVO reqVO); - /** - * 绑定第三方用户 - * @param sysUserId 系统用户ID - * @param socialUSerId 第三方唯一标识 - * @return - */ - Long bindSocialUSer(Long sysUserId, String socialUSerId); - /** * 修改用户 * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserServiceImpl.java index ec585dbc8..ef26b0778 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserServiceImpl.java @@ -4,11 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysSocialUserDO; -import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.social.SysUserSocialMapper; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; @@ -17,10 +12,14 @@ import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.social.SysUserSocialMapper; import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper; import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; @@ -33,9 +32,8 @@ import javax.annotation.Resource; import java.io.InputStream; import java.util.*; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; - +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** * 用户 Service 实现类 @@ -78,15 +76,6 @@ public class SysUserServiceImpl implements SysUserService { return user.getId(); } - @Override - public Long bindSocialUSer(Long sysUserId, String socialUSerId) { - SysSocialUserDO userSocialDO = new SysSocialUserDO(); - userSocialDO.setUserId(sysUserId); -// userSocialDO.setSocialUserId(socialUSerId); - userSocialMapper.insert(userSocialDO); - return userSocialDO.getUserId(); - } - @Override public void updateUser(SysUserUpdateReqVO reqVO) { // 校验正确性 diff --git a/yudao-admin-ui/src/utils/constants.js b/yudao-admin-ui/src/utils/constants.js index 6580f2514..d0251ae68 100644 --- a/yudao-admin-ui/src/utils/constants.js +++ b/yudao-admin-ui/src/utils/constants.js @@ -68,9 +68,25 @@ export const InfApiErrorLogProcessStatusEnum = { } /** - * 用户的三方平台的类型枚举 + * 用户的社交平台的类型枚举 */ export const SysUserSocialTypeEnum = { - GITEE: 10, - DINGTALK: 20, + // GITEE: { + // title: "码云", + // type: 10, + // source: "gitee", + // img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.11/gitee.png", + // }, + DINGTALK: { + title: "钉钉", + type: 20, + source: "dingtalk", + img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.11/dingtalk.png", + }, + WECHAT_ENTERPRISE: { + title: "企业微信", + type: 30, + source: "wechat_enterprise", + img: "https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.11/wechat_enterprise.png", + } } diff --git a/yudao-admin-ui/src/views/login.vue b/yudao-admin-ui/src/views/login.vue index cffe64e92..243da1768 100644 --- a/yudao-admin-ui/src/views/login.vue +++ b/yudao-admin-ui/src/views/login.vue @@ -30,8 +30,8 @@