From 005e7df1b8d7733b459c24104bc775c52e528454 Mon Sep 17 00:00:00 2001 From: thiszhc <2029364173@qq.com> Date: Thu, 15 Jun 2023 19:30:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/pom.xml | 14 ++- .../web/controller/AuthController.java | 12 +- .../dromara/web/service/SysLoginService.java | 72 ++++++------ ruoyi-common/ruoyi-common-bom/pom.xml | 6 + ruoyi-common/ruoyi-common-social/pom.xml | 23 ++-- .../common/social/config/SocialConfig.java | 2 +- ....java => SocialLoginConfigProperties.java} | 2 +- .../config/properties/SocialProperties.java | 2 +- .../social/utils/AuthRedisStateCache.java | 16 +-- .../common/social/utils/SocialUtils.java | 20 ++-- .../system/SocialUserController.java | 105 ------------------ .../system/service/ISocialUserService.java | 24 ---- .../service/impl/SocialUserServiceImpl.java | 69 ------------ .../mapper/system/SocialUserMapper.xml | 58 ++-------- script/sql/ry_vue_5.X.sql | 69 ++++++------ 15 files changed, 113 insertions(+), 381 deletions(-) rename ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/{ConfigProperties.java => SocialLoginConfigProperties.java} (94%) delete mode 100644 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SocialUserController.java diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index e57c444a..39731b1a 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -43,6 +43,12 @@ ruoyi-common-doc + + org.dromara + ruoyi-common-social + + + org.dromara ruoyi-system @@ -75,16 +81,12 @@ spring-boot-starter-test test + me.zhyd.oauth JustAuth - - org.dromara - ruoyi-common-social - 5.1.0-SNAPSHOT - compile - + diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index f46cbdc3..8cb96cd6 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -3,12 +3,9 @@ package org.dromara.web.controller; import cn.dev33.satoken.annotation.SaIgnore; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.json.JSON; -import cn.hutool.json.JSONUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.constraints.NotBlank; import lombok.RequiredArgsConstructor; -import me.zhyd.oauth.cache.AuthStateCache; import me.zhyd.oauth.model.AuthCallback; import me.zhyd.oauth.model.AuthResponse; import me.zhyd.oauth.model.AuthUser; @@ -22,10 +19,8 @@ import org.dromara.common.core.domain.model.SmsLoginBody; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.social.config.SocialConfig; -import org.dromara.common.social.config.properties.ConfigProperties; +import org.dromara.common.social.config.properties.SocialLoginConfigProperties; import org.dromara.common.social.config.properties.SocialProperties; -import org.dromara.common.social.utils.AuthRedisStateCache; import org.dromara.common.social.utils.SocialUtils; import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.system.domain.bo.SysTenantBo; @@ -45,7 +40,6 @@ import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.net.URL; import java.util.List; -import java.util.Map; /** * 认证 @@ -153,7 +147,7 @@ public class AuthController { { return R.fail(source + "平台账号已经被账号绑定"); } - ConfigProperties obj = socialProperties.getType().get(source); + SocialLoginConfigProperties obj = socialProperties.getType().get(source); if (ObjectUtil.isNull(obj)){ return R.fail(source + "平台账号暂不支持"); } @@ -175,7 +169,7 @@ public class AuthController { @SuppressWarnings("unchecked") @GetMapping("/social-login/{source}") public R socialLogin(@PathVariable("source") String source, AuthCallback callback, HttpServletRequest request) throws IOException { - ConfigProperties obj = socialProperties.getType().get(source); + SocialLoginConfigProperties obj = socialProperties.getType().get(source); if (ObjectUtil.isNull(obj)){ return R.fail(source + "平台账号暂不支持"); } diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/SysLoginService.java b/ruoyi-admin/src/main/java/org/dromara/web/service/SysLoginService.java index 3628b05d..84c554d1 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/SysLoginService.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/SysLoginService.java @@ -44,6 +44,7 @@ import org.dromara.system.service.ISocialUserService; import org.dromara.system.service.ISysPermissionService; import org.dromara.system.service.ISysTenantService; import org.dromara.system.service.ISysUserService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -181,27 +182,49 @@ public class SysLoginService { return R.fail("对不起,授权信息验证不通过,请退出重试!"); } AuthUser authUserData = authUser.getData(); - // 查询社交用户信息,判断是否已经绑定,如果已经绑定则直接登录,否则验证是否登录,未登录则先登录再绑定 - SocialUserVo user = socialUserService.selectSocialUserByAuthId(source + authUserData.getUuid()); + String authId = source + authUserData.getUuid(); + + SocialUserVo user = socialUserService.selectSocialUserByAuthId(authId); if (ObjectUtil.isNotNull(user)) { - checkTenant(user.getTenantId()); - SysUserVo dbUser = loadUserByUsername(user.getTenantId(), user.getUserName()); - LoginHelper.loginByDevice(buildLoginUser(dbUser), DeviceType.SOCIAL); - recordLogininfor(dbUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); - recordLoginInfo(user.getUserId()); + //执行登录和记录登录信息操作 + return loginAndRecord(user.getTenantId(), user.getUserName(), authUserData); } else { // 判断是否已登录 if (LoginHelper.getUserId() == null) { return R.fail("授权失败,请先登录再绑定"); } SocialUserBo socialUserBo = new SocialUserBo(); - socialUserService.insertByBo(setAuthUserData(authUserData, socialUserBo)); + socialUserBo.setUserId(LoginHelper.getUserId()); + socialUserBo.setAuthId(authUserData.getSource() + authUserData.getUuid()); + socialUserBo.setSource(authUserData.getSource()); + socialUserBo.setUserName(authUserData.getUsername()); + socialUserBo.setNickName(authUserData.getNickname()); + socialUserBo.setAvatar(authUserData.getAvatar()); + socialUserBo.setOpenId(authUserData.getUuid()); + BeanUtils.copyProperties(authUserData, socialUserBo); + BeanUtils.copyProperties(authUserData.getToken(), socialUserBo); + + socialUserService.insertByBo(socialUserBo); SysUserVo lodingData = loadUserByUsername(LoginHelper.getTenantId(), LoginHelper.getUsername()); - checkTenant(lodingData.getTenantId()); - LoginHelper.loginByDevice(buildLoginUser(lodingData), DeviceType.SOCIAL); - recordLogininfor(lodingData.getTenantId(), socialUserBo.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); - recordLoginInfo(socialUserBo.getUserId()); + //执行登录和记录登录信息操作 + return loginAndRecord(lodingData.getTenantId(), socialUserBo.getUserName(), authUserData); } + } + + /** + * 执行登录和记录登录信息操作 + * + * @param tenantId 租户ID + * @param userName 用户名 + * @param authUser 授权用户信息 + * @return 统一响应实体 + */ + private R loginAndRecord(String tenantId, String userName, AuthUser authUser) { + checkTenant(tenantId); + SysUserVo dbUser = loadUserByUsername(tenantId, userName); + LoginHelper.loginByDevice(buildLoginUser(dbUser), DeviceType.SOCIAL); + recordLogininfor(dbUser.getTenantId(), userName, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); + recordLoginInfo(dbUser.getUserId()); return R.ok(StpUtil.getTokenValue()); } @@ -440,29 +463,4 @@ public class SysLoginService { } } - - public SocialUserBo setAuthUserData(AuthUser authUserData, SocialUserBo socialUser) { - socialUser.setUserId(LoginHelper.getUserId()); - socialUser.setAuthId(authUserData.getSource() + authUserData.getUuid()); - socialUser.setSource(authUserData.getSource()); - socialUser.setUserName(authUserData.getUsername()); - socialUser.setNickName(authUserData.getNickname()); - socialUser.setAvatar(authUserData.getAvatar()); - socialUser.setEmail(authUserData.getEmail()); - socialUser.setOpenId(authUserData.getUuid()); - socialUser.setAccessToken(authUserData.getToken().getAccessToken()); - socialUser.setExpireIn(authUserData.getToken().getExpireIn()); - socialUser.setRefreshToken(authUserData.getToken().getRefreshToken()); - socialUser.setAccessCode(authUserData.getToken().getAccessCode()); - socialUser.setUnionId(authUserData.getToken().getUnionId()); - socialUser.setScope(authUserData.getToken().getScope()); - socialUser.setTokenType(authUserData.getToken().getTokenType()); - socialUser.setIdToken(authUserData.getToken().getIdToken()); - socialUser.setMacAlgorithm(authUserData.getToken().getMacAlgorithm()); - socialUser.setMacKey(authUserData.getToken().getMacKey()); - socialUser.setCode(authUserData.getToken().getCode()); - socialUser.setOauthToken(authUserData.getToken().getOauthToken()); - socialUser.setOauthTokenSecret(authUserData.getToken().getOauthTokenSecret()); - return socialUser; - } } diff --git a/ruoyi-common/ruoyi-common-bom/pom.xml b/ruoyi-common/ruoyi-common-bom/pom.xml index 8a9e25a9..cac678c2 100644 --- a/ruoyi-common/ruoyi-common-bom/pom.xml +++ b/ruoyi-common/ruoyi-common-bom/pom.xml @@ -117,6 +117,12 @@ ${revision} + + org.dromara + ruoyi-common-social + ${revision} + + org.dromara diff --git a/ruoyi-common/ruoyi-common-social/pom.xml b/ruoyi-common/ruoyi-common-social/pom.xml index b87479b4..77135a6d 100644 --- a/ruoyi-common/ruoyi-common-social/pom.xml +++ b/ruoyi-common/ruoyi-common-social/pom.xml @@ -1,35 +1,26 @@ - org.dromara ruoyi-common ${revision} - ../pom.xml 4.0.0 + ruoyi-common-social + - ruoyi-common-auth 认证模块 + ruoyi-common-social 授权认证 + me.zhyd.oauth JustAuth - - org.projectlombok - lombok - - - org.springframework.boot - spring-boot - - - org.springframework.boot - spring-boot-autoconfigure - + org.dromara ruoyi-common-redis diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialConfig.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialConfig.java index c50c5603..7a9a1663 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialConfig.java +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialConfig.java @@ -17,7 +17,7 @@ import org.springframework.context.annotation.Bean; public class SocialConfig { @Bean - public AuthStateCache redis() { + public AuthStateCache authStateCache() { return new AuthRedisStateCache(); } diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/ConfigProperties.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java similarity index 94% rename from ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/ConfigProperties.java rename to ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java index 813b03a6..2b63c1ee 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/ConfigProperties.java +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java @@ -3,7 +3,7 @@ package org.dromara.common.social.config.properties; import lombok.Data; @Data -public class ConfigProperties { +public class SocialLoginConfigProperties { /** * 应用 ID diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java index 4240ebab..811d821f 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java @@ -24,7 +24,7 @@ public class SocialProperties { /** * 授权类型 */ - private Map type; + private Map type; /** * 授权过期时间 diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java index f438a1c8..f7f23929 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java @@ -12,21 +12,7 @@ import java.time.Duration; public class AuthRedisStateCache implements AuthStateCache { - private final SocialProperties socialProperties; - private final RedisTemplate redisTemplate; - - private ValueOperations valueOperations; - - @PostConstruct - public void init() { - valueOperations = redisTemplate.opsForValue(); - } - - - public AuthRedisStateCache() { - this.socialProperties = new SocialProperties(); - redisTemplate = new RedisTemplate<>(); - } + private SocialProperties socialProperties; /** * 存入缓存 diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java index b3a1cd1f..64e84e79 100644 --- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java @@ -19,17 +19,17 @@ public class SocialUtils { AuthRequest authRequest = null; switch (source.toLowerCase()) { case "dingtalk" -> - authRequest = new AuthDingTalkRequest(AuthConfig.builder(). - clientId(clientId). - clientSecret(clientSecret) - .redirectUri(redirectUri). - build()); + authRequest = new AuthDingTalkRequest(AuthConfig.builder() + .clientId(clientId) + .clientSecret(clientSecret) + .redirectUri(redirectUri) + .build()); case "baidu" -> - authRequest = new AuthBaiduRequest(AuthConfig.builder(). - clientId(clientId). - clientSecret(clientSecret) - .redirectUri(redirectUri). - build()); + authRequest = new AuthBaiduRequest(AuthConfig.builder() + .clientId(clientId) + .clientSecret(clientSecret) + .redirectUri(redirectUri) + .build()); case "github" -> authRequest = new AuthGithubRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret) .redirectUri(redirectUri).build()); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SocialUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SocialUserController.java deleted file mode 100644 index 91994062..00000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SocialUserController.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.dromara.system.controller.system; - -import java.util.List; - -import lombok.RequiredArgsConstructor; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.*; -import cn.dev33.satoken.annotation.SaCheckPermission; -import org.springframework.web.bind.annotation.*; -import org.springframework.validation.annotation.Validated; -import org.dromara.common.idempotent.annotation.RepeatSubmit; -import org.dromara.common.log.annotation.Log; -import org.dromara.common.web.core.BaseController; -import org.dromara.common.mybatis.core.page.PageQuery; -import org.dromara.common.core.domain.R; -import org.dromara.common.core.validate.AddGroup; -import org.dromara.common.core.validate.EditGroup; -import org.dromara.common.log.enums.BusinessType; -import org.dromara.common.excel.utils.ExcelUtil; -import org.dromara.system.domain.vo.SocialUserVo; -import org.dromara.system.domain.bo.SocialUserBo; -import org.dromara.system.service.ISocialUserService; -import org.dromara.common.mybatis.core.page.TableDataInfo; - -/** - * 社会化关系 - * - * @author thiszhc - * @date 2023-06-12 - */ -@Validated -@RequiredArgsConstructor -@RestController -@RequestMapping("/system/socialUser") -public class SocialUserController extends BaseController { - - private final ISocialUserService socialUserService; - - /** - * 查询社会化关系列表 - */ - @SaCheckPermission("system:user:list") - @GetMapping("/list") - public TableDataInfo list(SocialUserBo bo, PageQuery pageQuery) { - return socialUserService.queryPageList(bo, pageQuery); - } - - /** - * 导出社会化关系列表 - */ - @SaCheckPermission("system:user:export") - @Log(title = "社会化关系", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(SocialUserBo bo, HttpServletResponse response) { - List list = socialUserService.queryList(bo); - ExcelUtil.exportExcel(list, "社会化关系", SocialUserVo.class, response); - } - - /** - * 获取社会化关系详细信息 - * - * @param id 主键 - */ - @SaCheckPermission("system:user:query") - @GetMapping("/{id}") - public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable Long id) { - return R.ok(socialUserService.queryById(id)); - } - - /** - * 新增社会化关系 - */ - @SaCheckPermission("system:user:add") - @Log(title = "社会化关系", businessType = BusinessType.INSERT) - @RepeatSubmit() - @PostMapping() - public R add(@Validated(AddGroup.class) @RequestBody SocialUserBo bo) { - return toAjax(socialUserService.insertByBo(bo)); - } - - /** - * 修改社会化关系 - */ - @SaCheckPermission("system:user:edit") - @Log(title = "社会化关系", businessType = BusinessType.UPDATE) - @RepeatSubmit() - @PutMapping() - public R edit(@Validated(EditGroup.class) @RequestBody SocialUserBo bo) { - return toAjax(socialUserService.updateByBo(bo)); - } - - /** - * 删除社会化关系 - * - * @param ids 主键串 - */ - @SaCheckPermission("system:user:remove") - @Log(title = "社会化关系", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public R remove(@NotEmpty(message = "主键不能为空") - @PathVariable Long[] ids) { - return toAjax(socialUserService.deleteWithValidByIds(List.of(ids), true)); - } -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISocialUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISocialUserService.java index f16cf164..d9e87f7d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISocialUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISocialUserService.java @@ -19,35 +19,11 @@ import java.util.List; */ public interface ISocialUserService { - /** - * 查询授权关系 - */ - SocialUserVo queryById(Long id); - - /** - * 查询授权列表 - */ - TableDataInfo queryPageList(SocialUserBo bo, PageQuery pageQuery); - - /** - * 查询授权列表 - */ - List queryList(SocialUserBo bo); - /** * 新增授权关系 */ Boolean insertByBo(SocialUserBo bo); - /** - * 修改授权关系 - */ - Boolean updateByBo(SocialUserBo bo); - - /** - * 校验并批量删除社会化关系信息 - */ - Boolean deleteWithValidByIds(Collection ids, Boolean isValid); /** * 删除社会化关系信息 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SocialUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SocialUserServiceImpl.java index c130fb7e..fc342445 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SocialUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SocialUserServiceImpl.java @@ -33,56 +33,6 @@ public class SocialUserServiceImpl implements ISocialUserService { private final SocialUserMapper baseMapper; - /** - * 查询社会化关系 - */ - @Override - public SocialUserVo queryById(Long id) { - return baseMapper.selectVoById(id); - } - - /** - * 查询社会化关系列表 - */ - @Override - public TableDataInfo queryPageList(SocialUserBo bo, PageQuery pageQuery) { - LambdaQueryWrapper lqw = buildQueryWrapper(bo); - Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); - return TableDataInfo.build(result); - } - - /** - * 查询社会化关系列表 - */ - @Override - public List queryList(SocialUserBo bo) { - LambdaQueryWrapper lqw = buildQueryWrapper(bo); - return baseMapper.selectVoList(lqw); - } - - private LambdaQueryWrapper buildQueryWrapper(SocialUserBo bo) { - Map params = bo.getParams(); - LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); - lqw.eq(StringUtils.isNotBlank(bo.getAuthId()), SocialUser::getAuthId, bo.getAuthId()); - lqw.eq(StringUtils.isNotBlank(bo.getSource()), SocialUser::getSource, bo.getSource()); - lqw.eq(StringUtils.isNotBlank(bo.getAccessToken()), SocialUser::getAccessToken, bo.getAccessToken()); - lqw.eq(bo.getExpireIn() != 0, SocialUser::getExpireIn, bo.getExpireIn()); - lqw.eq(StringUtils.isNotBlank(bo.getRefreshToken()), SocialUser::getRefreshToken, bo.getRefreshToken()); - lqw.eq(StringUtils.isNotBlank(bo.getOpenId()), SocialUser::getOpenId, bo.getOpenId()); - lqw.eq(StringUtils.isNotBlank(bo.getScope()), SocialUser::getScope, bo.getScope()); - lqw.eq(StringUtils.isNotBlank(bo.getAccessCode()), SocialUser::getAccessCode, bo.getAccessCode()); - lqw.eq(StringUtils.isNotBlank(bo.getUnionId()), SocialUser::getUnionId, bo.getUnionId()); - lqw.eq(StringUtils.isNotBlank(bo.getScope()), SocialUser::getScope, bo.getScope()); - lqw.eq(StringUtils.isNotBlank(bo.getTokenType()), SocialUser::getTokenType, bo.getTokenType()); - lqw.eq(StringUtils.isNotBlank(bo.getIdToken()), SocialUser::getIdToken, bo.getIdToken()); - lqw.eq(StringUtils.isNotBlank(bo.getMacAlgorithm()), SocialUser::getMacAlgorithm, bo.getMacAlgorithm()); - lqw.eq(StringUtils.isNotBlank(bo.getMacKey()), SocialUser::getMacKey, bo.getMacKey()); - lqw.eq(StringUtils.isNotBlank(bo.getCode()), SocialUser::getCode, bo.getCode()); - lqw.eq(StringUtils.isNotBlank(bo.getOauthToken()), SocialUser::getOauthToken, bo.getOauthToken()); - lqw.eq(StringUtils.isNotBlank(bo.getOauthTokenSecret()), SocialUser::getOauthTokenSecret, bo.getOauthTokenSecret()); - return lqw; - } - /** * 新增社会化关系 */ @@ -97,15 +47,6 @@ public class SocialUserServiceImpl implements ISocialUserService { return flag; } - /** - * 修改社会化关系 - */ - @Override - public Boolean updateByBo(SocialUserBo bo) { - SocialUser update = MapstructUtils.convert(bo, SocialUser.class); - validEntityBeforeSave(update); - return baseMapper.updateById(update) > 0; - } /** * 保存前的数据校验 @@ -114,16 +55,6 @@ public class SocialUserServiceImpl implements ISocialUserService { //TODO 做一些数据校验,如唯一约束 } - /** - * 批量删除社会化关系 - */ - @Override - public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if (isValid) { - //TODO 做一些业务上的校验,判断是否需要校验 - } - return baseMapper.deleteBatchIds(ids) > 0; - } /** * 删除社会化关系 diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SocialUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SocialUserMapper.xml index fb636b16..0c50ee6e 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SocialUserMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SocialUserMapper.xml @@ -8,61 +8,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - select id, - user_id, - tenant_id, - auth_id, - source, - open_id, - access_token, - expire_in, - refresh_token, - access_code, - union_id, - scope, - token_type, - id_token, - mac_algorithm, - mac_key, - code, - oauth_token, - oauth_token_secret, - create_dept, - create_by, - create_time, - update_by, - update_time - from social_user - - - - - - - - - diff --git a/script/sql/ry_vue_5.X.sql b/script/sql/ry_vue_5.X.sql index 8c10bb2c..94b8765e 100644 --- a/script/sql/ry_vue_5.X.sql +++ b/script/sql/ry_vue_5.X.sql @@ -1,43 +1,40 @@ - -- ---------------------------- -- 第三方平台授权表 -- ---------------------------- -CREATE TABLE `social_user` +DROP TABLE IF EXISTS social_user; +CREATE TABLE social_user ( - `id` bigint unsigned NOT NULL COMMENT '主键', - `user_id` bigint NOT NULL COMMENT '用户ID', - `tenant_id` varchar(20) DEFAULT NULL COMMENT '租户id', - `auth_id` varchar(255) NOT NULL COMMENT '授权+授权openid', - `source` varchar(255) NOT NULL COMMENT '用户来源', - `open_id` varchar(255) DEFAULT NULL COMMENT '原生open id', - `user_name` varchar(30) NOT NULL COMMENT '登录账号', - `nick_name` varchar(30) DEFAULT '' COMMENT '用户昵称', - `email` varchar(255) DEFAULT '' COMMENT '用户邮箱', - `avatar` varchar(500) DEFAULT '' COMMENT '头像地址', - `access_token` varchar(255) NOT NULL COMMENT '用户的授权令牌', - `expire_in` int DEFAULT NULL COMMENT '用户的授权令牌的有效期,部分平台可能没有', - `refresh_token` varchar(255) DEFAULT NULL COMMENT '刷新令牌,部分平台可能没有', - `access_code` varchar(255) DEFAULT NULL COMMENT '平台的授权信息,部分平台可能没有', - `union_id` varchar(255) DEFAULT NULL COMMENT '用户的 unionid', - `scope` varchar(255) DEFAULT NULL COMMENT '授予的权限,部分平台可能没有', - `token_type` varchar(255) DEFAULT NULL COMMENT '个别平台的授权信息,部分平台可能没有', - `id_token` varchar(255) DEFAULT NULL COMMENT 'id token,部分平台可能没有', - `mac_algorithm` varchar(255) DEFAULT NULL COMMENT '小米平台用户的附带属性,部分平台可能没有', - `mac_key` varchar(255) DEFAULT NULL COMMENT '小米平台用户的附带属性,部分平台可能没有', - `code` varchar(255) DEFAULT NULL COMMENT '用户的授权code,部分平台可能没有', - `oauth_token` varchar(255) DEFAULT NULL COMMENT 'Twitter平台用户的附带属性,部分平台可能没有', - `oauth_token_secret` varchar(255) DEFAULT NULL COMMENT 'Twitter平台用户的附带属性,部分平台可能没有', - `create_dept` bigint DEFAULT NULL COMMENT '创建部门', - `create_by` bigint NOT NULL COMMENT '创建人', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_by` bigint NOT NULL COMMENT '更新人', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci - ROW_FORMAT = DYNAMIC COMMENT ='社会化关系表'; + id BIGINT UNSIGNED NOT NULL COMMENT '主键', + user_id BIGINT NOT NULL COMMENT '用户ID', + tenant_id VARCHAR(20) DEFAULT NULL COMMENT '租户id', + auth_id VARCHAR(255) NOT NULL COMMENT '授权+授权openid', + source VARCHAR(255) NOT NULL COMMENT '用户来源', + open_id VARCHAR(255) DEFAULT NULL COMMENT '原生open id', + user_name VARCHAR(30) NOT NULL COMMENT '登录账号', + nick_name VARCHAR(30) DEFAULT '' COMMENT '用户昵称', + email VARCHAR(255) DEFAULT '' COMMENT '用户邮箱', + avatar VARCHAR(500) DEFAULT '' COMMENT '头像地址', + access_token VARCHAR(255) NOT NULL COMMENT '用户的授权令牌', + expire_in INT DEFAULT NULL COMMENT '用户的授权令牌的有效期,部分平台可能没有', + refresh_token VARCHAR(255) DEFAULT NULL COMMENT '刷新令牌,部分平台可能没有', + access_code VARCHAR(255) DEFAULT NULL COMMENT '平台的授权信息,部分平台可能没有', + union_id VARCHAR(255) DEFAULT NULL COMMENT '用户的 unionid', + scope VARCHAR(255) DEFAULT NULL COMMENT '授予的权限,部分平台可能没有', + token_type VARCHAR(255) DEFAULT NULL COMMENT '个别平台的授权信息,部分平台可能没有', + id_token VARCHAR(255) DEFAULT NULL COMMENT 'id token,部分平台可能没有', + mac_algorithm VARCHAR(255) DEFAULT NULL COMMENT '小米平台用户的附带属性,部分平台可能没有', + mac_key VARCHAR(255) DEFAULT NULL COMMENT '小米平台用户的附带属性,部分平台可能没有', + code VARCHAR(255) DEFAULT NULL COMMENT '用户的授权code,部分平台可能没有', + oauth_token VARCHAR(255) DEFAULT NULL COMMENT 'Twitter平台用户的附带属性,部分平台可能没有', + oauth_token_secret VARCHAR(255) DEFAULT NULL COMMENT 'Twitter平台用户的附带属性,部分平台可能没有', + create_dept bigint(20) comment '创建部门', + create_by bigint(20) comment '创建者', + create_time datetime comment '创建时间', + update_by bigint(20) comment '更新者', + update_time datetime comment '更新时间', + del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)', + PRIMARY KEY (id) +) ENGINE = InnoDB COMMENT ='社会化关系表'; -- ---------------------------- -- 租户表