Merge remote-tracking branch 'RuoYi-Vue-Plus/5.X' into 5.X-client

# Conflicts:
#	ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java
#	ruoyi-admin/src/main/java/org/dromara/web/service/SysLoginService.java
#	script/sql/ry_vue_5.X.sql
This commit is contained in:
zlyx 2023-06-20 17:40:00 +08:00
commit 95c5156343
31 changed files with 2530 additions and 296 deletions

View File

@ -39,6 +39,7 @@
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
<lombok.version>1.18.26</lombok.version>
<bouncycastle.version>1.72</bouncycastle.version>
<justauth.version>1.16.5</justauth.version>
<!-- 离线IP地址定位库 -->
<ip2region.version>2.7.0</ip2region.version>
@ -110,6 +111,13 @@
<scope>import</scope>
</dependency>
<!-- JustAuth 的依赖配置-->
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>${justauth.version}</version>
</dependency>
<!-- common 的依赖配置-->
<dependency>
<groupId>org.dromara</groupId>

View File

@ -43,6 +43,12 @@
<artifactId>ruoyi-common-doc</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-social</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-system</artifactId>
@ -76,6 +82,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
</dependency>
<!-- skywalking 整合 logback -->
<!-- <dependency>-->
<!-- <groupId>org.apache.skywalking</groupId>-->

View File

@ -2,15 +2,28 @@ package org.dromara.web.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.model.LoginBody;
import org.dromara.common.core.domain.model.RegisterBody;
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.properties.SocialLoginConfigProperties;
import org.dromara.common.social.config.properties.SocialProperties;
import org.dromara.common.social.utils.SocialUtils;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.bo.SysTenantBo;
import org.dromara.system.domain.vo.SysTenantVo;
import org.dromara.system.service.ISysSocialService;
import org.dromara.system.service.ISysConfigService;
import org.dromara.system.service.ISysTenantService;
import org.dromara.web.domain.vo.LoginTenantVo;
@ -40,33 +53,138 @@ import java.util.List;
@RequestMapping("/auth")
public class AuthController {
private final SocialProperties socialProperties;
private final SysLoginService loginService;
private final SysRegisterService registerService;
private final ISysConfigService configService;
private final ISysTenantService tenantService;
private final ISysSocialService socialUserService;
/**
* 登录方法
*
* @param loginBody 登录信息
* @param body 登录信息
* @return 结果
*/
@PostMapping("/login")
public R<LoginVo> login(@Validated @RequestBody LoginBody loginBody) {
// 校验类型和id
String clientId = loginBody.getClientId();
String grantType = loginBody.getGrantType();
IAuthStrategy authStrategy = AuthFactory.instance(grantType);
// 校验请求参数
authStrategy.validate(loginBody);
// 校验授权类型和id
loginService.checkClientType(clientId, grantType);
// 校验租户
loginService.checkTenant(loginBody.getTenantId());
// 登录
return R.ok(authStrategy.login(clientId, loginBody));
public R<LoginVo> login(@Validated @RequestBody LoginBody body) {
LoginVo loginVo = new LoginVo();
// 生成令牌
String token = loginService.login(
body.getTenantId(),
body.getUsername(), body.getPassword(),
body.getCode(), body.getUuid());
loginVo.setToken(token);
return R.ok(loginVo);
}
/**
* 短信登录
*
* @param body 登录信息
* @return 结果
*/
@PostMapping("/smsLogin")
public R<LoginVo> smsLogin(@Validated @RequestBody SmsLoginBody body) {
LoginVo loginVo = new LoginVo();
// 生成令牌
String token = loginService.smsLogin(
body.getTenantId(),
body.getPhonenumber(),
body.getSmsCode());
loginVo.setToken(token);
return R.ok(loginVo);
}
/**
* 邮件登录
*
* @param body 登录信息
* @return 结果
*/
@PostMapping("/emailLogin")
public R<LoginVo> emailLogin(@Validated @RequestBody EmailLoginBody body) {
LoginVo loginVo = new LoginVo();
// 生成令牌
String token = loginService.emailLogin(
body.getTenantId(),
body.getEmail(),
body.getEmailCode());
loginVo.setToken(token);
return R.ok(loginVo);
}
/**
* 小程序登录(示例)
*
* @param xcxCode 小程序code
* @return 结果
*/
@PostMapping("/xcxLogin")
public R<LoginVo> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
LoginVo loginVo = new LoginVo();
// 生成令牌
String token = loginService.xcxLogin(xcxCode);
loginVo.setToken(token);
return R.ok(loginVo);
}
/**
* 认证授权
*
* @param source 登录来源
* @return 结果
*/
@GetMapping("/binding/{source}")
public R<String> authBinding(@PathVariable("source") String source) {
SocialLoginConfigProperties obj = socialProperties.getType().get(source);
if (ObjectUtil.isNull(obj)) {
return R.fail(source + "平台账号暂不支持");
}
AuthRequest authRequest = SocialUtils.getAuthRequest(source,
obj.getClientId(),
obj.getClientSecret(),
obj.getRedirectUri());
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
return R.ok(authorizeUrl);
}
/**
* 第三方登录回调业务处理
*
* @param source 登录来源
* @param callback 授权响应实体
* @return 结果
*/
@SuppressWarnings("unchecked")
@GetMapping("/social-login/{source}")
public R<String> socialLogin(@PathVariable("source") String source, AuthCallback callback) {
SocialLoginConfigProperties obj = socialProperties.getType().get(source);
if (ObjectUtil.isNull(obj)) {
return R.fail(source + "平台账号暂不支持");
}
AuthRequest authRequest = SocialUtils.getAuthRequest(source,
obj.getClientId(),
obj.getClientSecret(),
obj.getRedirectUri());
AuthResponse<AuthUser> response = authRequest.login(callback);
return loginService.socialLogin(source, response);
}
/**
* 取消授权
*
* @param socialId socialId
*/
@DeleteMapping(value = "/unlock/{socialId}")
public R<Void> unlockSocial(@PathVariable Long socialId) {
Boolean rows = socialUserService.deleteWithValidById(socialId);
return rows ? R.ok() : R.fail("取消授权失败");
}
/**
* 退出登录
*/

View File

@ -7,6 +7,8 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthUser;
import org.dromara.common.core.constant.Constants;
import org.dromara.common.core.constant.GlobalConstants;
import org.dromara.common.core.constant.TenantConstants;
@ -24,10 +26,13 @@ import org.dromara.common.tenant.exception.TenantException;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.SysClient;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
import org.dromara.system.domain.vo.SysTenantVo;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.mapper.SysClientMapper;
import org.dromara.system.mapper.SysUserMapper;
import org.dromara.system.service.ISysSocialService;
import org.dromara.system.service.ISysPermissionService;
import org.dromara.system.service.ISysTenantService;
import org.springframework.beans.factory.annotation.Value;
@ -56,9 +61,68 @@ public class SysLoginService {
private final ISysTenantService tenantService;
private final ISysPermissionService permissionService;
private final ISysSocialService sysSocialService;
private final SysUserMapper userMapper;
private final SysClientMapper clientMapper;
/**
* 社交登录
*
* @param source 登录来源
* @param authUser 授权响应实体
* @return 统一响应实体
*/
public R<String> socialLogin(String source, AuthResponse<AuthUser> authUser) {
// 判断授权响应是否成功
if (!authUser.ok()) {
return R.fail("对不起,授权信息验证不通过,请退出重试!");
}
AuthUser authUserData = authUser.getData();
SysSocialVo social = sysSocialService.selectByAuthId(authUserData.getSource() + authUserData.getUuid());
if (ObjectUtil.isNotNull(social)) {
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getUserId, social.getUserId()));
// 执行登录和记录登录信息操作
return loginAndRecord(user.getTenantId(), user.getUserName(), authUserData);
} else {
// 判断是否已登录
if (!StpUtil.isLogin()) {
return R.fail("授权失败,请先登录才能绑定");
}
SysSocialBo bo = new SysSocialBo();
bo.setUserId(LoginHelper.getUserId());
bo.setAuthId(authUserData.getSource() + authUserData.getUuid());
bo.setSource(authUserData.getSource());
bo.setUserName(authUserData.getUsername());
bo.setNickName(authUserData.getNickname());
bo.setAvatar(authUserData.getAvatar());
bo.setOpenId(authUserData.getUuid());
BeanUtils.copyProperties(authUserData.getToken(), bo);
sysSocialService.insertByBo(bo);
SysUserVo sysUser = loadUserByUsername(LoginHelper.getTenantId(), LoginHelper.getUsername());
// 执行登录和记录登录信息操作
return loginAndRecord(sysUser.getTenantId(), sysUser.getUserName(), authUserData);
}
}
/**
* 执行登录和记录登录信息操作
*
* @param tenantId 租户ID
* @param userName 用户名
* @param authUser 授权用户信息
* @return 统一响应实体
*/
private R<String> loginAndRecord(String tenantId, String userName, AuthUser authUser) {
checkTenant(tenantId);
SysUserVo user = loadUserByUsername(tenantId, userName);
LoginHelper.loginByDevice(buildLoginUser(user), DeviceType.SOCIAL);
recordLogininfor(user.getTenantId(), userName, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
recordLoginInfo(user.getUserId());
return R.ok(StpUtil.getTokenValue());
}
/**
* 退出登录
*/
@ -93,10 +157,123 @@ public class SysLoginService {
SpringUtils.context().publishEvent(logininforEvent);
}
/**
* 校验短信验证码
*/
private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) {
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber);
if (StringUtils.isBlank(code)) {
recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
throw new CaptchaExpireException();
}
return code.equals(smsCode);
}
/**
* 校验邮箱验证码
*/
private boolean validateEmailCode(String tenantId, String email, String emailCode) {
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + email);
if (StringUtils.isBlank(code)) {
recordLogininfor(tenantId, email, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
throw new CaptchaExpireException();
}
return code.equals(emailCode);
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
*/
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
String captcha = RedisUtils.getCacheObject(verifyKey);
RedisUtils.deleteObject(verifyKey);
if (captcha == null) {
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha)) {
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
throw new CaptchaException();
}
}
private SysUserVo loadUserByUsername(String tenantId, String username) {
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getUserName, SysUser::getStatus)
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
.eq(SysUser::getUserName, username));
if (ObjectUtil.isNull(user)) {
log.info("登录用户:{} 不存在.", username);
throw new UserException("user.not.exists", username);
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", username);
throw new UserException("user.blocked", username);
}
if (TenantHelper.isEnable()) {
return userMapper.selectTenantUserByUserName(username, tenantId);
}
return userMapper.selectUserByUserName(username);
}
private SysUserVo loadUserByPhonenumber(String tenantId, String phonenumber) {
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getPhonenumber, SysUser::getStatus)
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
.eq(SysUser::getPhonenumber, phonenumber));
if (ObjectUtil.isNull(user)) {
log.info("登录用户:{} 不存在.", phonenumber);
throw new UserException("user.not.exists", phonenumber);
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", phonenumber);
throw new UserException("user.blocked", phonenumber);
}
if (TenantHelper.isEnable()) {
return userMapper.selectTenantUserByPhonenumber(phonenumber, tenantId);
}
return userMapper.selectUserByPhonenumber(phonenumber);
}
private SysUserVo loadUserByEmail(String tenantId, String email) {
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getEmail, SysUser::getStatus)
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
.eq(SysUser::getEmail, email));
if (ObjectUtil.isNull(user)) {
log.info("登录用户:{} 不存在.", email);
throw new UserException("user.not.exists", email);
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", email);
throw new UserException("user.blocked", email);
}
if (TenantHelper.isEnable()) {
return userMapper.selectTenantUserByEmail(email, tenantId);
}
return userMapper.selectUserByEmail(email);
}
private SysUserVo loadUserByOpenid(String openid) {
// 使用 openid 查询绑定用户 如未绑定用户 则根据业务自行处理 例如 创建默认用户
// todo 自行实现 userService.selectUserByOpenid(openid);
SysUserVo user = new SysUserVo();
if (ObjectUtil.isNull(user)) {
log.info("登录用户:{} 不存在.", openid);
// todo 用户不存在 业务逻辑自行实现
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", openid);
// todo 用户已被停用 业务逻辑自行实现
}
return user;
}
/**
* 构建登录用户
*/
public LoginUser buildLoginUser(SysUserVo user) {
private LoginUser buildLoginUser(SysUserVo user) {
LoginUser loginUser = new LoginUser();
loginUser.setTenantId(user.getTenantId());
loginUser.setUserId(user.getUserId());

View File

@ -177,3 +177,65 @@ sms:
sdkAppId: appid
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
territory: ap-guangzhou
--- # 三方授权
justauth:
enabled: true
type:
qq:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=qq
union-id: false
weibo:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=weibo
gitee:
client-id: 914******************98
client-secret: 02*****************ac
redirect-uri: http://localhost:80/social-login?source=gitee
dingtalk:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=dingtalk
baidu:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=baidu
csdn:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=csdn
coding:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=coding
coding-group-name: xx
oschina:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=oschina
alipay:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=alipay
alipay-public-key: MIIB**************DAQAB
wechat_open:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_open
wechat_mp:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_mp
wechat_enterprise:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_enterprise
agent-id: 1000002
gitlab:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=gitlab

View File

@ -180,3 +180,64 @@ sms:
sdkAppId: appid
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
territory: ap-guangzhou
--- # 三方授权
justauth:
enabled: true
type:
qq:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=qq
union-id: false
weibo:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=weibo
gitee:
client-id: 914******************98
client-secret: 02*****************ac
redirect-uri: http://localhost:80/social-login?source=gitee
dingtalk:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=dingtalk
baidu:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=baidu
csdn:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=csdn
coding:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=coding
coding-group-name: xx
oschina:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=oschina
alipay:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=alipay
alipay-public-key: MIIB**************DAQAB
wechat_open:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_open
wechat_mp:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_mp
wechat_enterprise:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=wechat_enterprise
agent-id: 1000002
gitlab:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: http://localhost:80/social-login?source=gitlab

View File

@ -11,6 +11,7 @@
<modules>
<module>ruoyi-common-bom</module>
<module>ruoyi-common-social</module>
<module>ruoyi-common-core</module>
<module>ruoyi-common-doc</module>
<module>ruoyi-common-excel</module>

View File

@ -117,6 +117,12 @@
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-social</artifactId>
<version>${revision}</version>
</dependency>
<!-- web服务 -->
<dependency>
<groupId>org.dromara</groupId>

View File

@ -26,7 +26,12 @@ public enum DeviceType {
/**
* 小程序端
*/
XCX("xcx");
XCX("xcx"),
/**
* social第三方端
*/
SOCIAL("social");
private final String device;
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-common-social</artifactId>
<description>
ruoyi-common-social 授权认证
</description>
<dependencies>
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-redis</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,23 @@
package org.dromara.common.social.config;
import me.zhyd.oauth.cache.AuthStateCache;
import org.dromara.common.social.config.properties.SocialProperties;
import org.dromara.common.social.utils.AuthRedisStateCache;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
/**
* Social 配置属性
* @author thiszhc
*/
@AutoConfiguration
@EnableConfigurationProperties(SocialProperties.class)
public class SocialConfig {
@Bean
public AuthStateCache authStateCache(SocialProperties socialProperties) {
return new AuthRedisStateCache(socialProperties);
}
}

View File

@ -0,0 +1,63 @@
package org.dromara.common.social.config.properties;
import lombok.Data;
/**
* 社交登录配置
*
* @author thiszhc
*/
@Data
public class SocialLoginConfigProperties {
/**
* 应用 ID
*/
private String clientId;
/**
* 应用密钥
*/
private String clientSecret;
/**
* 回调地址
*/
private String redirectUri;
/**
* 是否获取unionId
*/
private boolean unionId;
/**
* Coding 企业名称
*/
private String codingGroupName;
/**
* 支付宝公钥
*/
private String alipayPublicKey;
/**
* 企业微信应用ID
*/
private String agentId;
/**
* stackoverflow api key
*/
private String stackOverflowKey;
/**
* 设备ID
*/
private String deviceId;
/**
* 客户端系统类型
*/
private String clientOsType;
}

View File

@ -0,0 +1,40 @@
package org.dromara.common.social.config.properties;
import lombok.Data;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* Social 配置属性
*
* @author thiszhc
*/
@Data
@Component
@ConfigurationProperties(prefix = "justauth")
public class SocialProperties {
/**
* 是否启用
*/
private boolean enabled;
/**
* 授权类型
*/
private Map<String, SocialLoginConfigProperties> type;
/**
* 授权过期时间
*/
private long timeout;
/**
* 授权缓存配置
*/
private CacheProperties cache = new CacheProperties();
}

View File

@ -0,0 +1,59 @@
package org.dromara.common.social.utils;
import lombok.AllArgsConstructor;
import me.zhyd.oauth.cache.AuthStateCache;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.social.config.properties.SocialProperties;
import java.time.Duration;
@AllArgsConstructor
public class AuthRedisStateCache implements AuthStateCache {
private final SocialProperties socialProperties;
/**
* 存入缓存
*
* @param key 缓存key
* @param value 缓存内容
*/
@Override
public void cache(String key, String value) {
RedisUtils.setCacheObject(key, value, Duration.ofMillis(socialProperties.getTimeout()));
}
/**
* 存入缓存
*
* @param key 缓存key
* @param value 缓存内容
* @param timeout 指定缓存过期时间(毫秒)
*/
@Override
public void cache(String key, String value, long timeout) {
RedisUtils.setCacheObject(key, value, Duration.ofMillis(timeout));
}
/**
* 获取缓存内容
*
* @param key 缓存key
* @return 缓存内容
*/
@Override
public String get(String key) {
return RedisUtils.getCacheObject(key);
}
/**
* 是否存在key如果对应key的value值已过期也返回false
*
* @param key 缓存key
* @return true存在key并且value没过期falsekey不存在或者已过期
*/
@Override
public boolean containsKey(String key) {
return RedisUtils.hasKey(key);
}
}

View File

@ -0,0 +1,116 @@
package org.dromara.common.social.utils;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.request.*;
/**
* 认证授权工具类
*
* @author thiszhc
*/
public class SocialUtils {
public static AuthRequest getAuthRequest(String source, String clientId,
String clientSecret, String redirectUri) throws AuthException {
AuthRequest authRequest = null;
switch (source.toLowerCase()) {
case "dingtalk" ->
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());
case "github" ->
authRequest = new AuthGithubRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "gitee" ->
authRequest = new AuthGiteeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "weibo" ->
authRequest = new AuthWeiboRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "coding" ->
authRequest = new AuthCodingRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "oschina" ->
authRequest = new AuthOschinaRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "alipay" ->
// 支付宝在创建回调地址时不允许使用localhost或者127.0.0.1所以这儿的回调地址使用的局域网内的ip
authRequest = new AuthAlipayRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.alipayPublicKey("").redirectUri(redirectUri).build());
case "qq" ->
authRequest = new AuthQqRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "wechat_open" -> authRequest = new AuthWeChatOpenRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build());
case "csdn" ->
authRequest = new AuthCsdnRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "taobao" ->
authRequest = new AuthTaobaoRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "douyin" ->
authRequest = new AuthDouyinRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "linkedin" ->
authRequest = new AuthLinkedinRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "microsoft" -> authRequest = new AuthMicrosoftRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build());
case "mi" ->
authRequest = new AuthMiRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "toutiao" ->
authRequest = new AuthToutiaoRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "teambition" -> authRequest = new AuthTeambitionRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build());
case "pinterest" -> authRequest = new AuthPinterestRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).build());
case "renren" ->
authRequest = new AuthRenrenRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "stack_overflow" -> authRequest = new AuthStackOverflowRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).stackOverflowKey("").build());
case "huawei" ->
authRequest = new AuthHuaweiRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "wechat_enterprise" ->
authRequest = new AuthWeChatEnterpriseQrcodeRequest(AuthConfig.builder().clientId(clientId)
.clientSecret(clientSecret).redirectUri(redirectUri).agentId("").build());
case "kujiale" ->
authRequest = new AuthKujialeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "gitlab" ->
authRequest = new AuthGitlabRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "meituan" ->
authRequest = new AuthMeituanRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "eleme" ->
authRequest = new AuthElemeRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "wechat_mp" ->
authRequest = new AuthWeChatMpRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
case "aliyun" ->
authRequest = new AuthAliyunRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
.redirectUri(redirectUri).build());
default -> {
}
}
if (null == authRequest) {
throw new AuthException("未获取到有效的Auth配置");
}
return authRequest;
}
}

View File

@ -0,0 +1,52 @@
package org.dromara.system.controller.system;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.system.domain.vo.SysSocialVo;
import org.dromara.system.service.ISysSocialService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 社会化关系
*
* @author thiszhc
* @date 2023-06-16
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/social")
public class SysSocialController extends BaseController {
private final ISysSocialService socialUserService;
/**
* 查询社会化关系列表
*/
@GetMapping("/list")
public R<List<SysSocialVo>> list() {
return R.ok(socialUserService.queryListByUserId(LoginHelper.getUserId()));
}
/**
* 获取社会化关系详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<SysSocialVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable String id) {
return R.ok(socialUserService.queryById(id));
}
}

View File

@ -0,0 +1,136 @@
package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.tenant.core.TenantEntity;
import java.io.Serial;
/**
* 社会化关系对象 sys_social
*
* @author thiszhc
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_social")
public class SysSocial extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id")
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 的唯一ID
*/
private String authId;
/**
* 用户来源
*/
private String source;
/**
* 用户的授权令牌
*/
private String accessToken;
/**
* 用户的授权令牌的有效期部分平台可能没有
*/
private int expireIn;
/**
* 刷新令牌部分平台可能没有
*/
private String refreshToken;
/**
* 用户的 open id
*/
private String openId;
/**
* 授权的第三方账号
*/
private String userName;
/**
* 授权的第三方昵称
*/
private String nickName;
/**
* 授权的第三方邮箱
*/
private String email;
/**
* 授权的第三方头像地址
*/
private String avatar;
/**
* 平台的授权信息部分平台可能没有
*/
private String accessCode;
/**
* 用户的 unionid
*/
private String unionId;
/**
* 授予的权限部分平台可能没有
*/
private String scope;
/**
* 个别平台的授权信息部分平台可能没有
*/
private String tokenType;
/**
* id token部分平台可能没有
*/
private String idToken;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
private String macAlgorithm;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
private String macKey;
/**
* 用户的授权code部分平台可能没有
*/
private String code;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
private String oauthToken;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
private String oauthTokenSecret;
}

View File

@ -0,0 +1,142 @@
package org.dromara.system.domain.bo;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.tenant.core.TenantEntity;
import org.dromara.system.domain.SysSocial;
/**
* 社会化关系业务对象 sys_social
*
* @author Lion Li
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SysSocial.class, reverseConvertGenerate = false)
public class SysSocialBo extends TenantEntity {
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
private Long id;
/**
* 的唯一ID
*/
@NotBlank(message = "的唯一ID不能为空", groups = { AddGroup.class, EditGroup.class })
private String authId;
/**
* 用户来源
*/
@NotBlank(message = "用户来源不能为空", groups = { AddGroup.class, EditGroup.class })
private String source;
/**
* 用户的授权令牌
*/
@NotBlank(message = "用户的授权令牌不能为空", groups = { AddGroup.class, EditGroup.class })
private String accessToken;
/**
* 用户的授权令牌的有效期部分平台可能没有
*/
private int expireIn;
/**
* 刷新令牌部分平台可能没有
*/
private String refreshToken;
/**
* 用户的 open id
*/
@NotBlank(message = "用户的 open id不能为空", groups = { AddGroup.class, EditGroup.class })
private String openId;
/**
* 用户的 ID
*/
@NotBlank(message = "用户的 ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long userId;
/**
* 平台的授权信息部分平台可能没有
*/
private String accessCode;
/**
* 用户的 unionid
*/
private String unionId;
/**
* 授予的权限部分平台可能没有
*/
private String scope;
/**
* 授权的第三方账号
*/
private String userName;
/**
* 授权的第三方昵称
*/
private String nickName;
/**
* 授权的第三方邮箱
*/
private String email;
/**
* 授权的第三方头像地址
*/
private String avatar;
/**
* 个别平台的授权信息部分平台可能没有
*/
private String tokenType;
/**
* id token部分平台可能没有
*/
private String idToken;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
private String macAlgorithm;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
private String macKey;
/**
* 用户的授权code部分平台可能没有
*/
private String code;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
private String oauthToken;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
private String oauthTokenSecret;
}

View File

@ -0,0 +1,165 @@
package org.dromara.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.system.domain.SysSocial;
import java.io.Serial;
import java.io.Serializable;
/**
* 社会化关系视图对象 sys_social
*
* @author thiszhc
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SysSocial.class)
public class SysSocialVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long id;
/**
* 用户ID
*/
@ExcelProperty(value = "用户ID")
private Long userId;
/**
* 租户ID
*/
private String tenantId;
/**
* 的唯一ID
*/
@ExcelProperty(value = "授权UUID")
private String authId;
/**
* 用户来源
*/
@ExcelProperty(value = "用户来源")
private String source;
/**
* 用户的授权令牌
*/
@ExcelProperty(value = "用户的授权令牌")
private String accessToken;
/**
* 用户的授权令牌的有效期部分平台可能没有
*/
@ExcelProperty(value = "用户的授权令牌的有效期,部分平台可能没有")
private int expireIn;
/**
* 刷新令牌部分平台可能没有
*/
@ExcelProperty(value = "刷新令牌,部分平台可能没有")
private String refreshToken;
/**
* 用户的 open id
*/
@ExcelProperty(value = "用户的 open id")
private String openId;
/**
* 授权的第三方账号
*/
@ExcelProperty(value = "授权的第三方账号")
private String userName;
/**
* 授权的第三方昵称
*/
@ExcelProperty(value = "授权的第三方昵称")
private String nickName;
/**
* 授权的第三方邮箱
*/
@ExcelProperty(value = "授权的第三方邮箱")
private String email;
/**
* 授权的第三方头像地址
*/
@ExcelProperty(value = "授权的第三方头像地址")
private String avatar;
/**
* 平台的授权信息部分平台可能没有
*/
@ExcelProperty(value = "平台的授权信息,部分平台可能没有")
private String accessCode;
/**
* 用户的 unionid
*/
@ExcelProperty(value = "用户的 unionid")
private String unionId;
/**
* 授予的权限部分平台可能没有
*/
@ExcelProperty(value = "授予的权限,部分平台可能没有")
private String scope;
/**
* 个别平台的授权信息部分平台可能没有
*/
@ExcelProperty(value = "个别平台的授权信息,部分平台可能没有")
private String tokenType;
/**
* id token部分平台可能没有
*/
@ExcelProperty(value = "id token部分平台可能没有")
private String idToken;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
@ExcelProperty(value = "小米平台用户的附带属性,部分平台可能没有")
private String macAlgorithm;
/**
* 小米平台用户的附带属性部分平台可能没有
*/
@ExcelProperty(value = "小米平台用户的附带属性,部分平台可能没有")
private String macKey;
/**
* 用户的授权code部分平台可能没有
*/
@ExcelProperty(value = "用户的授权code部分平台可能没有")
private String code;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
@ExcelProperty(value = "Twitter平台用户的附带属性部分平台可能没有")
private String oauthToken;
/**
* Twitter平台用户的附带属性部分平台可能没有
*/
@ExcelProperty(value = "Twitter平台用户的附带属性部分平台可能没有")
private String oauthTokenSecret;
}

View File

@ -0,0 +1,14 @@
package org.dromara.system.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.system.domain.SysSocial;
import org.dromara.system.domain.vo.SysSocialVo;
/**
* 社会化关系Mapper接口
*
* @author thiszhc
*/
public interface SysSocialMapper extends BaseMapperPlus<SysSocial, SysSocialVo> {
}

View File

@ -0,0 +1,51 @@
package org.dromara.system.service;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
import java.util.List;
/**
* 社会化关系Service接口
*
* @author thiszhc
*/
public interface ISysSocialService {
/**
* 查询社会化关系
*/
SysSocialVo queryById(String id);
/**
* 查询社会化关系列表
*/
List<SysSocialVo> queryList();
/**
* 查询社会化关系列表
*/
List<SysSocialVo> queryListByUserId(Long userId);
/**
* 新增授权关系
*/
Boolean insertByBo(SysSocialBo bo);
/**
* 删除社会化关系信息
*/
Boolean deleteWithValidById(Long id);
/**
* 根据 authId 查询 SysSocial 表和 SysUser 返回 SysSocialAuthResult 映射的对象
* @param authId 认证ID
* @return SysSocial
*/
SysSocialVo selectByAuthId(String authId);
}

View File

@ -0,0 +1,97 @@
package org.dromara.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.system.domain.SysSocial;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
import org.dromara.system.mapper.SysSocialMapper;
import org.dromara.system.service.ISysSocialService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 社会化关系Service业务层处理
*
* @author thiszhc
* @date 2023-06-12
*/
@RequiredArgsConstructor
@Service
public class SysSocialServiceImpl implements ISysSocialService {
private final SysSocialMapper baseMapper;
/**
* 查询社会化关系
*/
@Override
public SysSocialVo queryById(String id) {
return baseMapper.selectVoById(id);
}
/**
* 授权列表
*/
@Override
public List<SysSocialVo> queryList() {
return baseMapper.selectVoList();
}
@Override
public List<SysSocialVo> queryListByUserId(Long userId) {
return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getUserId, userId));
}
/**
* 新增社会化关系
*/
@Override
public Boolean insertByBo(SysSocialBo bo) {
SysSocial add = MapstructUtils.convert(bo, SysSocial.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
if (add != null) {
bo.setId(add.getId());
} else {
return false;
}
}
return flag;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(SysSocial entity) {
//TODO 做一些数据校验,如唯一约束
}
/**
* 删除社会化关系
*/
@Override
public Boolean deleteWithValidById(Long id) {
return baseMapper.deleteById(id) > 0;
}
/**
* 根据 authId 查询用户信息
*
* @param authId 认证id
* @return 授权信息
*/
@Override
public SysSocialVo selectByAuthId(String authId) {
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId));
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SysSocialMapper">
</mapper>

View File

@ -1,3 +1,73 @@
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
create table sys_social
(
id number(20) not null,
user_id number(20) not null,
tenant_id varchar(20) default null,
auth_id varchar(255) not null,
source varchar(255) not null,
open_id varchar(255) default null,
user_name varchar(30) not null,
nick_name varchar(30) default '',
email varchar(255) default '',
avatar varchar(500) default '',
access_token varchar(255) not null,
expire_in number(100) default null,
refresh_token varchar(255) default null,
access_code varchar(255) default null,
union_id varchar(255) default null,
scope varchar(255) default null,
token_type varchar(255) default null,
id_token varchar(255) default null,
mac_algorithm varchar(255) default null,
mac_key varchar(255) default null,
code varchar(255) default null,
oauth_token varchar(255) default null,
oauth_token_secret varchar(255) default null,
create_dept number(20),
create_by number(20),
create_time date,
update_by number(20),
update_time date,
del_flag char(1) default '0'
);
alter table sys_social add constraint pk_sys_social primary key (id);
comment on table sys_social is '社会化关系表';
comment on column sys_social.id is '主键';
comment on column sys_social.user_id is '用户ID';
comment on column sys_social.tenant_id is '租户id';
comment on column sys_social.auth_id is '授权+授权openid';
comment on column sys_social.source is '用户来源';
comment on column sys_social.open_id is '原生openid';
comment on column sys_social.user_name is '登录账号';
comment on column sys_social.nick_name is '用户昵称';
comment on column sys_social.email is '用户邮箱';
comment on column sys_social.avatar is '头像地址';
comment on column sys_social.access_token is '用户的授权令牌';
comment on column sys_social.expire_in is '用户的授权令牌的有效期,部分平台可能没有';
comment on column sys_social.refresh_token is '刷新令牌,部分平台可能没有';
comment on column sys_social.access_code is '平台的授权信息,部分平台可能没有';
comment on column sys_social.union_id is '用户的 unionid';
comment on column sys_social.scope is '授予的权限,部分平台可能没有';
comment on column sys_social.token_type is '个别平台的授权信息,部分平台可能没有';
comment on column sys_social.id_token is 'id token部分平台可能没有';
comment on column sys_social.mac_algorithm is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.mac_key is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.code is '用户的授权code部分平台可能没有';
comment on column sys_social.oauth_token is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.oauth_token_secret is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.create_dept is '创建部门';
comment on column sys_social.create_by is '创建者';
comment on column sys_social.create_time is '创建时间';
comment on column sys_social.update_by is '更新者';
comment on column sys_social.update_time is '更新时间';
comment on column sys_social.del_flag is '删除标志0代表存在 2代表删除';
-- ----------------------------
-- 租户表
-- ----------------------------

View File

@ -1,3 +1,71 @@
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
create table sys_social
(
id int8 not null,
user_id int8 not null,
tenant_id varchar(20) default null::varchar,
auth_id varchar(255) not null,
source varchar(255) not null,
open_id varchar(255) default null::varchar,
user_name varchar(30) not null,
nick_name varchar(30) default ''::varchar,
email varchar(255) default ''::varchar,
avatar varchar(500) default ''::varchar,
access_token varchar(255) not null,
expire_in int8 default null::varchar,
refresh_token varchar(255) default null::varchar,
access_code varchar(255) default null::varchar,
union_id varchar(255) default null::varchar,
scope varchar(255) default null::varchar,
token_type varchar(255) default null::varchar,
id_token varchar(255) default null::varchar,
mac_algorithm varchar(255) default null::varchar,
mac_key varchar(255) default null::varchar,
code varchar(255) default null::varchar,
oauth_token varchar(255) default null::varchar,
oauth_token_secret varchar(255) default null::varchar,
create_dept int8,
create_by int8,
create_time timestamp,
update_by int8,
update_time timestamp,
del_flag char default '0'::bpchar,
constraint "pk_sys_social" primary key (id)
);
comment on table sys_social is '社会化关系表';
comment on column sys_social.id is '主键';
comment on column sys_social.user_id is '用户ID';
comment on column sys_social.tenant_id is '租户id';
comment on column sys_social.auth_id is '授权+授权openid';
comment on column sys_social.source is '用户来源';
comment on column sys_social.open_id is '原生openid';
comment on column sys_social.user_name is '登录账号';
comment on column sys_social.nick_name is '用户昵称';
comment on column sys_social.email is '用户邮箱';
comment on column sys_social.avatar is '头像地址';
comment on column sys_social.access_token is '用户的授权令牌';
comment on column sys_social.expire_in is '用户的授权令牌的有效期,部分平台可能没有';
comment on column sys_social.refresh_token is '刷新令牌,部分平台可能没有';
comment on column sys_social.access_code is '平台的授权信息,部分平台可能没有';
comment on column sys_social.union_id is '用户的 unionid';
comment on column sys_social.scope is '授予的权限,部分平台可能没有';
comment on column sys_social.token_type is '个别平台的授权信息,部分平台可能没有';
comment on column sys_social.id_token is 'id token部分平台可能没有';
comment on column sys_social.mac_algorithm is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.mac_key is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.code is '用户的授权code部分平台可能没有';
comment on column sys_social.oauth_token is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.oauth_token_secret is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.create_dept is '创建部门';
comment on column sys_social.create_by is '创建者';
comment on column sys_social.create_time is '创建时间';
comment on column sys_social.update_by is '更新者';
comment on column sys_social.update_time is '更新时间';
comment on column sys_social.del_flag is '删除标志0代表存在 2代表删除';
-- ----------------------------
-- 租户表
-- ----------------------------

View File

@ -1,3 +1,41 @@
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
drop table if exists sys_social;
create table sys_social
(
id bigint 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 = '社会化关系表';
-- ----------------------------
-- 租户表
-- ----------------------------
@ -32,7 +70,7 @@ create table sys_tenant
-- 初始化-租户表数据
-- ----------------------------
insert into sys_tenant values(1, '000000', '管理组', '15888888888', 'XXX有限公司', NULL, NULL, '多租户通用后台管理管理系统', NULL, NULL, NULL, NULL, -1, '0', '0', 103, 1, sysdate(), NULL, NULL);
insert into sys_tenant values(1, '000000', '管理组', '15888888888', 'XXX有限公司', null, null, '多租户通用后台管理管理系统', null, null, null, null, -1, '0', '0', 103, 1, sysdate(), null, null);
-- ----------------------------
@ -801,11 +839,11 @@ create table sys_oss_config (
primary key (oss_config_id)
) engine=innodb comment='对象存储配置表';
insert into sys_oss_config values (1, '000000', 'minio', 'ruoyi', 'ruoyi123', 'ruoyi', '', '127.0.0.1:9000', '','N', '', '1' ,'0', '', 103, 1, sysdate(), 1, sysdate(), NULL);
insert into sys_oss_config values (2, '000000', 'qiniu', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 's3-cn-north-1.qiniucs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), NULL);
insert into sys_oss_config values (3, '000000', 'aliyun', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 'oss-cn-beijing.aliyuncs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), NULL);
insert into sys_oss_config values (4, '000000', 'qcloud', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi-1250000000', '', 'cos.ap-beijing.myqcloud.com', '','N', 'ap-beijing', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), NULL);
insert into sys_oss_config values (5, '000000', 'image', 'ruoyi', 'ruoyi123', 'ruoyi', 'image', '127.0.0.1:9000', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), NULL);
insert into sys_oss_config values (1, '000000', 'minio', 'ruoyi', 'ruoyi123', 'ruoyi', '', '127.0.0.1:9000', '','N', '', '1' ,'0', '', 103, 1, sysdate(), 1, sysdate(), null);
insert into sys_oss_config values (2, '000000', 'qiniu', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 's3-cn-north-1.qiniucs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null);
insert into sys_oss_config values (3, '000000', 'aliyun', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 'oss-cn-beijing.aliyuncs.com', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null);
insert into sys_oss_config values (4, '000000', 'qcloud', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi-1250000000', '', 'cos.ap-beijing.myqcloud.com', '','N', 'ap-beijing', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null);
insert into sys_oss_config values (5, '000000', 'image', 'ruoyi', 'ruoyi123', 'ruoyi', 'image', '127.0.0.1:9000', '','N', '', '1' ,'1', '', 103, 1, sysdate(), 1, sysdate(), null);
-- ----------------------------
-- 系统授权表

View File

@ -1,3 +1,223 @@
create table sys_social
(
id bigint NOT NULL,
user_id bigint NOT NULL,
tenant_id nvarchar(20) NULL,
auth_id nvarchar(255) NOT NULL,
source nvarchar(255) NOT NULL,
open_id nvarchar(255) NULL,
user_name nvarchar(30) NOT NULL,
nick_name nvarchar(30) DEFAULT ('') NULL,
email nvarchar(255) DEFAULT ('') NULL,
avatar nvarchar(500) DEFAULT ('') NULL,
access_token nvarchar(255) NOT NULL,
expire_in bigint NULL,
refresh_token nvarchar(255) NULL,
access_code nvarchar(255) NULL,
union_id nvarchar(255) NULL,
scope nvarchar(255) NULL,
token_type nvarchar(255) NULL,
id_token nvarchar(255) NULL,
mac_algorithm nvarchar(255) NULL,
mac_key nvarchar(255) NULL,
code nvarchar(255) NULL,
oauth_token nvarchar(255) NULL,
oauth_token_secret nvarchar(255) NULL,
create_dept bigint,
create_by bigint,
create_time datetime2(7),
update_by bigint,
update_time datetime2(7),
del_flag nchar DEFAULT ('0') NULL,
CONSTRAINT PK__sys_social__B21E8F2427725F8A PRIMARY KEY CLUSTERED (id)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
)
ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'id' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'主键' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户ID' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'租户id' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'tenant_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'授权+授权openid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'auth_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户来源' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'source'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'原生openid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'open_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'登录账号' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_name'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户昵称' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'nick_name'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户邮箱' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'email'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'头像地址' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'avatar'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权令牌' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权令牌的有效期,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'expire_in'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'刷新令牌,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'refresh_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'平台的授权信息,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_code'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的 unionid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'union_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'授予的权限,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'scope'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'个别平台的授权信息,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'token_type'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'id token部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_algorithm'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_key'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权code部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'code'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token_secret'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'删除标志0代表存在 2代表删除' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'del_flag'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建部门' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_dept'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建者' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_by'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建时间' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_time'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'更新者' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_by'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'更新时间' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_time'
GO
CREATE TABLE sys_tenant
(
id bigint NOT NULL,

View File

@ -3,3 +3,72 @@ ALTER TABLE gen_table ADD (data_name VARCHAR2(200) DEFAULT '');
COMMENT ON COLUMN gen_table.data_name IS '数据源名称';
UPDATE sys_menu SET path = 'powerjob', component = 'monitor/powerjob/index', perms = 'monitor:powerjob:list', remark = 'powerjob控制台菜单' WHERE menu_id = 120;
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
create table sys_social
(
id number(20) not null,
user_id number(20) not null,
tenant_id varchar(20) default null,
auth_id varchar(255) not null,
source varchar(255) not null,
open_id varchar(255) default null,
user_name varchar(30) not null,
nick_name varchar(30) default '',
email varchar(255) default '',
avatar varchar(500) default '',
access_token varchar(255) not null,
expire_in number(100) default null,
refresh_token varchar(255) default null,
access_code varchar(255) default null,
union_id varchar(255) default null,
scope varchar(255) default null,
token_type varchar(255) default null,
id_token varchar(255) default null,
mac_algorithm varchar(255) default null,
mac_key varchar(255) default null,
code varchar(255) default null,
oauth_token varchar(255) default null,
oauth_token_secret varchar(255) default null,
create_dept number(20),
create_by number(20),
create_time date,
update_by number(20),
update_time date,
del_flag char(1) default '0'
);
alter table sys_social add constraint pk_sys_social primary key (id);
comment on table sys_social is '社会化关系表';
comment on column sys_social.id is '主键';
comment on column sys_social.user_id is '用户ID';
comment on column sys_social.tenant_id is '租户id';
comment on column sys_social.auth_id is '授权+授权openid';
comment on column sys_social.source is '用户来源';
comment on column sys_social.open_id is '原生openid';
comment on column sys_social.user_name is '登录账号';
comment on column sys_social.nick_name is '用户昵称';
comment on column sys_social.email is '用户邮箱';
comment on column sys_social.avatar is '头像地址';
comment on column sys_social.access_token is '用户的授权令牌';
comment on column sys_social.expire_in is '用户的授权令牌的有效期,部分平台可能没有';
comment on column sys_social.refresh_token is '刷新令牌,部分平台可能没有';
comment on column sys_social.access_code is '平台的授权信息,部分平台可能没有';
comment on column sys_social.union_id is '用户的 unionid';
comment on column sys_social.scope is '授予的权限,部分平台可能没有';
comment on column sys_social.token_type is '个别平台的授权信息,部分平台可能没有';
comment on column sys_social.id_token is 'id token部分平台可能没有';
comment on column sys_social.mac_algorithm is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.mac_key is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.code is '用户的授权code部分平台可能没有';
comment on column sys_social.oauth_token is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.oauth_token_secret is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.create_dept is '创建部门';
comment on column sys_social.create_by is '创建者';
comment on column sys_social.create_time is '创建时间';
comment on column sys_social.update_by is '更新者';
comment on column sys_social.update_time is '更新时间';
comment on column sys_social.del_flag is '删除标志0代表存在 2代表删除';

View File

@ -3,3 +3,71 @@ ALTER TABLE gen_table ADD data_name varchar(200) default ''::varchar;
COMMENT ON COLUMN gen_table.data_name IS '数据源名称';
UPDATE sys_menu SET path = 'powerjob', component = 'monitor/powerjob/index', perms = 'monitor:powerjob:list', remark = 'powerjob控制台菜单' WHERE menu_id = 120;
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
create table sys_social
(
id int8 not null,
user_id int8 not null,
tenant_id varchar(20) default null::varchar,
auth_id varchar(255) not null,
source varchar(255) not null,
open_id varchar(255) default null::varchar,
user_name varchar(30) not null,
nick_name varchar(30) default ''::varchar,
email varchar(255) default ''::varchar,
avatar varchar(500) default ''::varchar,
access_token varchar(255) not null,
expire_in int8 default null::varchar,
refresh_token varchar(255) default null::varchar,
access_code varchar(255) default null::varchar,
union_id varchar(255) default null::varchar,
scope varchar(255) default null::varchar,
token_type varchar(255) default null::varchar,
id_token varchar(255) default null::varchar,
mac_algorithm varchar(255) default null::varchar,
mac_key varchar(255) default null::varchar,
code varchar(255) default null::varchar,
oauth_token varchar(255) default null::varchar,
oauth_token_secret varchar(255) default null::varchar,
create_dept int8,
create_by int8,
create_time timestamp,
update_by int8,
update_time timestamp,
del_flag char default '0'::bpchar,
constraint "pk_sys_social" primary key (id)
);
comment on table sys_social is '社会化关系表';
comment on column sys_social.id is '主键';
comment on column sys_social.user_id is '用户ID';
comment on column sys_social.tenant_id is '租户id';
comment on column sys_social.auth_id is '授权+授权openid';
comment on column sys_social.source is '用户来源';
comment on column sys_social.open_id is '原生openid';
comment on column sys_social.user_name is '登录账号';
comment on column sys_social.nick_name is '用户昵称';
comment on column sys_social.email is '用户邮箱';
comment on column sys_social.avatar is '头像地址';
comment on column sys_social.access_token is '用户的授权令牌';
comment on column sys_social.expire_in is '用户的授权令牌的有效期,部分平台可能没有';
comment on column sys_social.refresh_token is '刷新令牌,部分平台可能没有';
comment on column sys_social.access_code is '平台的授权信息,部分平台可能没有';
comment on column sys_social.union_id is '用户的 unionid';
comment on column sys_social.scope is '授予的权限,部分平台可能没有';
comment on column sys_social.token_type is '个别平台的授权信息,部分平台可能没有';
comment on column sys_social.id_token is 'id token部分平台可能没有';
comment on column sys_social.mac_algorithm is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.mac_key is '小米平台用户的附带属性,部分平台可能没有';
comment on column sys_social.code is '用户的授权code部分平台可能没有';
comment on column sys_social.oauth_token is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.oauth_token_secret is 'Twitter平台用户的附带属性部分平台可能没有';
comment on column sys_social.create_dept is '创建部门';
comment on column sys_social.create_by is '创建者';
comment on column sys_social.create_time is '创建时间';
comment on column sys_social.update_by is '更新者';
comment on column sys_social.update_time is '更新时间';
comment on column sys_social.del_flag is '删除标志0代表存在 2代表删除';

View File

@ -10,3 +10,222 @@ GO
UPDATE sys_menu SET path = 'powerjob', component = 'monitor/powerjob/index', perms = 'monitor:powerjob:list', remark = 'powerjob控制台菜单' WHERE menu_id = 120
GO
create table sys_social
(
id bigint NOT NULL,
user_id bigint NOT NULL,
tenant_id nvarchar(20) NULL,
auth_id nvarchar(255) NOT NULL,
source nvarchar(255) NOT NULL,
open_id nvarchar(255) NULL,
user_name nvarchar(30) NOT NULL,
nick_name nvarchar(30) DEFAULT ('') NULL,
email nvarchar(255) DEFAULT ('') NULL,
avatar nvarchar(500) DEFAULT ('') NULL,
access_token nvarchar(255) NOT NULL,
expire_in bigint NULL,
refresh_token nvarchar(255) NULL,
access_code nvarchar(255) NULL,
union_id nvarchar(255) NULL,
scope nvarchar(255) NULL,
token_type nvarchar(255) NULL,
id_token nvarchar(255) NULL,
mac_algorithm nvarchar(255) NULL,
mac_key nvarchar(255) NULL,
code nvarchar(255) NULL,
oauth_token nvarchar(255) NULL,
oauth_token_secret nvarchar(255) NULL,
create_dept bigint,
create_by bigint,
create_time datetime2(7),
update_by bigint,
update_time datetime2(7),
del_flag nchar DEFAULT ('0') NULL,
CONSTRAINT PK__sys_social__B21E8F2427725F8A PRIMARY KEY CLUSTERED (id)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
)
ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'id' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'主键' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户ID' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'租户id' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'tenant_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'授权+授权openid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'auth_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户来源' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'source'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'原生openid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'open_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'登录账号' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_name'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户昵称' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'nick_name'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户邮箱' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'email'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'头像地址' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'avatar'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权令牌' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权令牌的有效期,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'expire_in'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'刷新令牌,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'refresh_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'平台的授权信息,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_code'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的 unionid' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'union_id'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'授予的权限,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'scope'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'个别平台的授权信息,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'token_type'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'id token部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_algorithm'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性,部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_key'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'用户的授权code部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'code'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性部分平台可能没有' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token_secret'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'删除标志0代表存在 2代表删除' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'del_flag'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建部门' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_dept'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建者' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_by'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'创建时间' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_time'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'更新者' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_by'
GO
EXEC sys.sp_addextendedproperty
'MS_Description', N'更新时间' ,
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_time'
GO

View File

@ -1,3 +1,41 @@
ALTER TABLE gen_table ADD COLUMN data_name varchar(200) NULL DEFAULT '' COMMENT '数据源名称' AFTER table_id;
UPDATE sys_menu SET path = 'powerjob', component = 'monitor/powerjob/index', perms = 'monitor:powerjob:list', remark = 'powerjob控制台菜单' WHERE menu_id = 120
-- ----------------------------
-- 第三方平台授权表
-- ----------------------------
drop table if exists sys_social;
create table sys_social
(
id bigint 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 = '社会化关系表';