diff --git a/pom.xml b/pom.xml
index 8a8ead1da..919dc0380 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,7 @@
0.2.0
1.18.26
1.72
+ 1.16.5
2.7.0
@@ -110,6 +111,13 @@
import
+
+
+ me.zhyd.oauth
+ JustAuth
+ ${justauth.version}
+
+
org.dromara
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index af5f23967..39731b1aa 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
@@ -76,6 +82,12 @@
test
+
+ me.zhyd.oauth
+ JustAuth
+
+
+
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 b182f96fe..eae92f486 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
@@ -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 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 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 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 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 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 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 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 response = authRequest.login(callback);
+ return loginService.socialLogin(source, response);
+ }
+
+ /**
+ * 取消授权
+ *
+ * @param socialId socialId
+ */
+ @DeleteMapping(value = "/unlock/{socialId}")
+ public R unlockSocial(@PathVariable Long socialId) {
+ Boolean rows = socialUserService.deleteWithValidById(socialId);
+ return rows ? R.ok() : R.fail("取消授权失败");
+ }
+
+
/**
* 退出登录
*/
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 38dd37631..a9ccc25df 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
@@ -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 socialLogin(String source, AuthResponse 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()
+ .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 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()
+ .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()
+ .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()
+ .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());
diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml
index 0d895fac5..d2109ffae 100644
--- a/ruoyi-admin/src/main/resources/application-dev.yml
+++ b/ruoyi-admin/src/main/resources/application-dev.yml
@@ -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
diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml
index 836fc2207..0dc27b0b3 100644
--- a/ruoyi-admin/src/main/resources/application-prod.yml
+++ b/ruoyi-admin/src/main/resources/application-prod.yml
@@ -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
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 0428aea78..45493d3e9 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -11,6 +11,7 @@
ruoyi-common-bom
+ ruoyi-common-social
ruoyi-common-core
ruoyi-common-doc
ruoyi-common-excel
diff --git a/ruoyi-common/ruoyi-common-bom/pom.xml b/ruoyi-common/ruoyi-common-bom/pom.xml
index 8a9e25a95..cac678c22 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-core/src/main/java/org/dromara/common/core/enums/DeviceType.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/DeviceType.java
index 09bf44b6d..dbadfc2de 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/DeviceType.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/DeviceType.java
@@ -26,7 +26,12 @@ public enum DeviceType {
/**
* 小程序端
*/
- XCX("xcx");
+ XCX("xcx"),
+
+ /**
+ * social第三方端
+ */
+ SOCIAL("social");
private final String device;
}
diff --git a/ruoyi-common/ruoyi-common-social/pom.xml b/ruoyi-common/ruoyi-common-social/pom.xml
new file mode 100644
index 000000000..77135a6d3
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/pom.xml
@@ -0,0 +1,29 @@
+
+
+
+ org.dromara
+ ruoyi-common
+ ${revision}
+
+ 4.0.0
+
+ ruoyi-common-social
+
+
+ ruoyi-common-social 授权认证
+
+
+
+
+ me.zhyd.oauth
+ JustAuth
+
+
+
+ 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
new file mode 100644
index 000000000..454159078
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/SocialConfig.java
@@ -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);
+ }
+
+}
diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java
new file mode 100644
index 000000000..69d453c58
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java
@@ -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;
+
+}
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
new file mode 100644
index 000000000..273fe7b70
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java
@@ -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 type;
+
+ /**
+ * 授权过期时间
+ */
+ private long timeout;
+
+ /**
+ * 授权缓存配置
+ */
+ private CacheProperties cache = new CacheProperties();
+
+}
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
new file mode 100644
index 000000000..d2a484313
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
@@ -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没过期;false:key不存在或者已过期
+ */
+ @Override
+ public boolean containsKey(String key) {
+ return RedisUtils.hasKey(key);
+ }
+}
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
new file mode 100644
index 000000000..a11520b08
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java
@@ -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;
+ }
+}
+
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysSocialController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysSocialController.java
new file mode 100644
index 000000000..48755085c
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysSocialController.java
@@ -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() {
+ return R.ok(socialUserService.queryListByUserId(LoginHelper.getUserId()));
+ }
+
+
+ /**
+ * 获取社会化关系详细信息
+ *
+ * @param id 主键
+ */
+ @GetMapping("/{id}")
+ public R getInfo(@NotNull(message = "主键不能为空")
+ @PathVariable String id) {
+ return R.ok(socialUserService.queryById(id));
+ }
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysSocial.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysSocial.java
new file mode 100644
index 000000000..10f2936c1
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysSocial.java
@@ -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;
+
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysSocialBo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysSocialBo.java
new file mode 100644
index 000000000..d3b32e00e
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysSocialBo.java
@@ -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;
+
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysSocialVo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysSocialVo.java
new file mode 100644
index 000000000..2a72efe04
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysSocialVo.java
@@ -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;
+
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysSocialMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysSocialMapper.java
new file mode 100644
index 000000000..b94206137
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysSocialMapper.java
@@ -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 {
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysSocialService.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysSocialService.java
new file mode 100644
index 000000000..9c8275efd
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysSocialService.java
@@ -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 queryList();
+
+ /**
+ * 查询社会化关系列表
+ */
+ List queryListByUserId(Long userId);
+
+ /**
+ * 新增授权关系
+ */
+ Boolean insertByBo(SysSocialBo bo);
+
+
+ /**
+ * 删除社会化关系信息
+ */
+ Boolean deleteWithValidById(Long id);
+
+
+ /**
+ * 根据 authId 查询 SysSocial 表和 SysUser 表,返回 SysSocialAuthResult 映射的对象
+ * @param authId 认证ID
+ * @return SysSocial
+ */
+ SysSocialVo selectByAuthId(String authId);
+
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysSocialServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysSocialServiceImpl.java
new file mode 100644
index 000000000..065dea0da
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysSocialServiceImpl.java
@@ -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 queryList() {
+ return baseMapper.selectVoList();
+ }
+
+ @Override
+ public List queryListByUserId(Long userId) {
+ return baseMapper.selectVoList(new LambdaQueryWrapper().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().eq(SysSocial::getAuthId, authId));
+ }
+
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysSocialMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysSocialMapper.xml
new file mode 100644
index 000000000..baa4b5946
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysSocialMapper.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/script/sql/oracle/oracle_ry_vue_5.X.sql b/script/sql/oracle/oracle_ry_vue_5.X.sql
index 396874d25..c844bfb1e 100644
--- a/script/sql/oracle/oracle_ry_vue_5.X.sql
+++ b/script/sql/oracle/oracle_ry_vue_5.X.sql
@@ -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代表删除)';
+
+
-- ----------------------------
-- 租户表
-- ----------------------------
diff --git a/script/sql/postgres/postgres_ry_vue_5.X.sql b/script/sql/postgres/postgres_ry_vue_5.X.sql
index 603c60616..efcc95551 100644
--- a/script/sql/postgres/postgres_ry_vue_5.X.sql
+++ b/script/sql/postgres/postgres_ry_vue_5.X.sql
@@ -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代表删除)';
+
-- ----------------------------
-- 租户表
-- ----------------------------
diff --git a/script/sql/ry_vue_5.X.sql b/script/sql/ry_vue_5.X.sql
index f964ae1f5..a6fbf0c6f 100644
--- a/script/sql/ry_vue_5.X.sql
+++ b/script/sql/ry_vue_5.X.sql
@@ -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);
-- ----------------------------
@@ -61,23 +99,23 @@ create table sys_tenant_package (
-- ----------------------------
drop table if exists sys_dept;
create table sys_dept (
- dept_id bigint(20) not null comment '部门id',
- tenant_id varchar(20) default '000000' comment '租户编号',
- parent_id bigint(20) default 0 comment '父部门id',
- ancestors varchar(500) default '' comment '祖级列表',
- dept_name varchar(30) default '' comment '部门名称',
- order_num int(4) default 0 comment '显示顺序',
- leader varchar(20) default null comment '负责人',
- phone varchar(11) default null comment '联系电话',
- email varchar(50) default null comment '邮箱',
- status char(1) default '0' comment '部门状态(0正常 1停用)',
- del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- primary key (dept_id)
+ dept_id bigint(20) not null comment '部门id',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ parent_id bigint(20) default 0 comment '父部门id',
+ ancestors varchar(500) default '' comment '祖级列表',
+ dept_name varchar(30) default '' comment '部门名称',
+ order_num int(4) default 0 comment '显示顺序',
+ leader varchar(20) default null comment '负责人',
+ phone varchar(11) default null comment '联系电话',
+ email varchar(50) default null comment '邮箱',
+ status char(1) default '0' comment '部门状态(0正常 1停用)',
+ del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ primary key (dept_id)
) engine=innodb comment = '部门表';
-- ----------------------------
@@ -102,28 +140,28 @@ insert into sys_dept values(109, '000000', 102, '0,100,102', '财务部门',
-- ----------------------------
drop table if exists sys_user;
create table sys_user (
- user_id bigint(20) not null comment '用户ID',
- tenant_id varchar(20) default '000000' comment '租户编号',
- dept_id bigint(20) default null comment '部门ID',
- user_name varchar(30) not null comment '用户账号',
- nick_name varchar(30) not null comment '用户昵称',
- user_type varchar(10) default 'sys_user' comment '用户类型(sys_user系统用户)',
- email varchar(50) default '' comment '用户邮箱',
- phonenumber varchar(11) default '' comment '手机号码',
- sex char(1) default '0' comment '用户性别(0男 1女 2未知)',
- avatar bigint(20) comment '头像地址',
- password varchar(100) default '' comment '密码',
- status char(1) default '0' comment '帐号状态(0正常 1停用)',
- del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
- login_ip varchar(128) default '' comment '最后登录IP',
- login_date datetime comment '最后登录时间',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (user_id)
+ user_id bigint(20) not null comment '用户ID',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ dept_id bigint(20) default null comment '部门ID',
+ user_name varchar(30) not null comment '用户账号',
+ nick_name varchar(30) not null comment '用户昵称',
+ user_type varchar(10) default 'sys_user' comment '用户类型(sys_user系统用户)',
+ email varchar(50) default '' comment '用户邮箱',
+ phonenumber varchar(11) default '' comment '手机号码',
+ sex char(1) default '0' comment '用户性别(0男 1女 2未知)',
+ avatar bigint(20) comment '头像地址',
+ password varchar(100) default '' comment '密码',
+ status char(1) default '0' comment '帐号状态(0正常 1停用)',
+ del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
+ login_ip varchar(128) default '' comment '最后登录IP',
+ login_date datetime comment '最后登录时间',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (user_id)
) engine=innodb comment = '用户信息表';
-- ----------------------------
@@ -139,19 +177,19 @@ insert into sys_user values(2, '000000', 105, 'lionli', '疯狂的狮子Li', 'sy
drop table if exists sys_post;
create table sys_post
(
- post_id bigint(20) not null comment '岗位ID',
- tenant_id varchar(20) default '000000' comment '租户编号',
- post_code varchar(64) not null comment '岗位编码',
- post_name varchar(50) not null comment '岗位名称',
- post_sort int(4) not null comment '显示顺序',
- status char(1) not null comment '状态(0正常 1停用)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (post_id)
+ post_id bigint(20) not null comment '岗位ID',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ post_code varchar(64) not null comment '岗位编码',
+ post_name varchar(50) not null comment '岗位名称',
+ post_sort int(4) not null comment '显示顺序',
+ status char(1) not null comment '状态(0正常 1停用)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (post_id)
) engine=innodb comment = '岗位信息表';
-- ----------------------------
@@ -168,23 +206,23 @@ insert into sys_post values(4, '000000', 'user', '普通员工', 4, '0', 103, 1
-- ----------------------------
drop table if exists sys_role;
create table sys_role (
- role_id bigint(20) not null comment '角色ID',
- tenant_id varchar(20) default '000000' comment '租户编号',
- role_name varchar(30) not null comment '角色名称',
- role_key varchar(100) not null comment '角色权限字符串',
- role_sort int(4) not null comment '显示顺序',
- data_scope char(1) default '1' comment '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)',
- menu_check_strictly tinyint(1) default 1 comment '菜单树选择项是否关联显示',
- dept_check_strictly tinyint(1) default 1 comment '部门树选择项是否关联显示',
- status char(1) not null comment '角色状态(0正常 1停用)',
- del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (role_id)
+ role_id bigint(20) not null comment '角色ID',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ role_name varchar(30) not null comment '角色名称',
+ role_key varchar(100) not null comment '角色权限字符串',
+ role_sort int(4) not null comment '显示顺序',
+ data_scope char(1) default '1' comment '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)',
+ menu_check_strictly tinyint(1) default 1 comment '菜单树选择项是否关联显示',
+ dept_check_strictly tinyint(1) default 1 comment '部门树选择项是否关联显示',
+ status char(1) not null comment '角色状态(0正常 1停用)',
+ del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (role_id)
) engine=innodb comment = '角色信息表';
-- ----------------------------
@@ -199,27 +237,27 @@ insert into sys_role values(2, '000000', '普通角色', 'common', 2, 2, 1, 1
-- ----------------------------
drop table if exists sys_menu;
create table sys_menu (
- menu_id bigint(20) not null comment '菜单ID',
- menu_name varchar(50) not null comment '菜单名称',
- parent_id bigint(20) default 0 comment '父菜单ID',
- order_num int(4) default 0 comment '显示顺序',
- path varchar(200) default '' comment '路由地址',
- component varchar(255) default null comment '组件路径',
- query_param varchar(255) default null comment '路由参数',
- is_frame int(1) default 1 comment '是否为外链(0是 1否)',
- is_cache int(1) default 0 comment '是否缓存(0缓存 1不缓存)',
- menu_type char(1) default '' comment '菜单类型(M目录 C菜单 F按钮)',
- visible char(1) default 0 comment '显示状态(0显示 1隐藏)',
- status char(1) default 0 comment '菜单状态(0正常 1停用)',
- perms varchar(100) default null comment '权限标识',
- icon varchar(100) default '#' comment '菜单图标',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default '' comment '备注',
- primary key (menu_id)
+ menu_id bigint(20) not null comment '菜单ID',
+ menu_name varchar(50) not null comment '菜单名称',
+ parent_id bigint(20) default 0 comment '父菜单ID',
+ order_num int(4) default 0 comment '显示顺序',
+ path varchar(200) default '' comment '路由地址',
+ component varchar(255) default null comment '组件路径',
+ query_param varchar(255) default null comment '路由参数',
+ is_frame int(1) default 1 comment '是否为外链(0是 1否)',
+ is_cache int(1) default 0 comment '是否缓存(0缓存 1不缓存)',
+ menu_type char(1) default '' comment '菜单类型(M目录 C菜单 F按钮)',
+ visible char(1) default 0 comment '显示状态(0显示 1隐藏)',
+ status char(1) default 0 comment '菜单状态(0正常 1停用)',
+ perms varchar(100) default null comment '权限标识',
+ icon varchar(100) default '#' comment '菜单图标',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default '' comment '备注',
+ primary key (menu_id)
) engine=innodb comment = '菜单权限表';
-- ----------------------------
@@ -357,9 +395,9 @@ insert into sys_menu values('1065', '客户端管理导出', '123', '5', '#', '
-- ----------------------------
drop table if exists sys_user_role;
create table sys_user_role (
- user_id bigint(20) not null comment '用户ID',
- role_id bigint(20) not null comment '角色ID',
- primary key(user_id, role_id)
+ user_id bigint(20) not null comment '用户ID',
+ role_id bigint(20) not null comment '角色ID',
+ primary key(user_id, role_id)
) engine=innodb comment = '用户和角色关联表';
-- ----------------------------
@@ -374,9 +412,9 @@ insert into sys_user_role values ('2', '2');
-- ----------------------------
drop table if exists sys_role_menu;
create table sys_role_menu (
- role_id bigint(20) not null comment '角色ID',
- menu_id bigint(20) not null comment '菜单ID',
- primary key(role_id, menu_id)
+ role_id bigint(20) not null comment '角色ID',
+ menu_id bigint(20) not null comment '菜单ID',
+ primary key(role_id, menu_id)
) engine=innodb comment = '角色和菜单关联表';
-- ----------------------------
@@ -472,9 +510,9 @@ insert into sys_role_menu values ('2', '1065');
-- ----------------------------
drop table if exists sys_role_dept;
create table sys_role_dept (
- role_id bigint(20) not null comment '角色ID',
- dept_id bigint(20) not null comment '部门ID',
- primary key(role_id, dept_id)
+ role_id bigint(20) not null comment '角色ID',
+ dept_id bigint(20) not null comment '部门ID',
+ primary key(role_id, dept_id)
) engine=innodb comment = '角色和部门关联表';
-- ----------------------------
@@ -491,9 +529,9 @@ insert into sys_role_dept values ('2', '105');
drop table if exists sys_user_post;
create table sys_user_post
(
- user_id bigint(20) not null comment '用户ID',
- post_id bigint(20) not null comment '岗位ID',
- primary key (user_id, post_id)
+ user_id bigint(20) not null comment '用户ID',
+ post_id bigint(20) not null comment '岗位ID',
+ primary key (user_id, post_id)
) engine=innodb comment = '用户与岗位关联表';
-- ----------------------------
@@ -508,28 +546,28 @@ insert into sys_user_post values ('2', '2');
-- ----------------------------
drop table if exists sys_oper_log;
create table sys_oper_log (
- oper_id bigint(20) not null comment '日志主键',
- tenant_id varchar(20) default '000000' comment '租户编号',
- title varchar(50) default '' comment '模块标题',
- business_type int(2) default 0 comment '业务类型(0其它 1新增 2修改 3删除)',
- method varchar(100) default '' comment '方法名称',
- request_method varchar(10) default '' comment '请求方式',
- operator_type int(1) default 0 comment '操作类别(0其它 1后台用户 2手机端用户)',
- oper_name varchar(50) default '' comment '操作人员',
- dept_name varchar(50) default '' comment '部门名称',
- oper_url varchar(255) default '' comment '请求URL',
- oper_ip varchar(128) default '' comment '主机地址',
- oper_location varchar(255) default '' comment '操作地点',
- oper_param varchar(2000) default '' comment '请求参数',
- json_result varchar(2000) default '' comment '返回参数',
- status int(1) default 0 comment '操作状态(0正常 1异常)',
- error_msg varchar(2000) default '' comment '错误消息',
- oper_time datetime comment '操作时间',
- cost_time bigint(20) default 0 comment '消耗时间',
- primary key (oper_id),
- key idx_sys_oper_log_bt (business_type),
- key idx_sys_oper_log_s (status),
- key idx_sys_oper_log_ot (oper_time)
+ oper_id bigint(20) not null comment '日志主键',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ title varchar(50) default '' comment '模块标题',
+ business_type int(2) default 0 comment '业务类型(0其它 1新增 2修改 3删除)',
+ method varchar(100) default '' comment '方法名称',
+ request_method varchar(10) default '' comment '请求方式',
+ operator_type int(1) default 0 comment '操作类别(0其它 1后台用户 2手机端用户)',
+ oper_name varchar(50) default '' comment '操作人员',
+ dept_name varchar(50) default '' comment '部门名称',
+ oper_url varchar(255) default '' comment '请求URL',
+ oper_ip varchar(128) default '' comment '主机地址',
+ oper_location varchar(255) default '' comment '操作地点',
+ oper_param varchar(2000) default '' comment '请求参数',
+ json_result varchar(2000) default '' comment '返回参数',
+ status int(1) default 0 comment '操作状态(0正常 1异常)',
+ error_msg varchar(2000) default '' comment '错误消息',
+ oper_time datetime comment '操作时间',
+ cost_time bigint(20) default 0 comment '消耗时间',
+ primary key (oper_id),
+ key idx_sys_oper_log_bt (business_type),
+ key idx_sys_oper_log_s (status),
+ key idx_sys_oper_log_ot (oper_time)
) engine=innodb comment = '操作日志记录';
@@ -539,19 +577,19 @@ create table sys_oper_log (
drop table if exists sys_dict_type;
create table sys_dict_type
(
- dict_id bigint(20) not null comment '字典主键',
- tenant_id varchar(20) default '000000' comment '租户编号',
- dict_name varchar(100) default '' comment '字典名称',
- dict_type varchar(100) default '' comment '字典类型',
- status char(1) default '0' comment '状态(0正常 1停用)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (dict_id),
- unique (tenant_id, dict_type)
+ dict_id bigint(20) not null comment '字典主键',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ dict_name varchar(100) default '' comment '字典名称',
+ dict_type varchar(100) default '' comment '字典类型',
+ status char(1) default '0' comment '状态(0正常 1停用)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (dict_id),
+ unique (tenant_id, dict_type)
) engine=innodb comment = '字典类型表';
insert into sys_dict_type values(1, '000000', '用户性别', 'sys_user_sex', '0', 103, 1, sysdate(), null, null, '用户性别列表');
@@ -570,23 +608,23 @@ insert into sys_dict_type values(10, '000000', '系统状态', 'sys_common_statu
drop table if exists sys_dict_data;
create table sys_dict_data
(
- dict_code bigint(20) not null comment '字典编码',
- tenant_id varchar(20) default '000000' comment '租户编号',
- dict_sort int(4) default 0 comment '字典排序',
- dict_label varchar(100) default '' comment '字典标签',
- dict_value varchar(100) default '' comment '字典键值',
- dict_type varchar(100) default '' comment '字典类型',
- css_class varchar(100) default null comment '样式属性(其他样式扩展)',
- list_class varchar(100) default null comment '表格回显样式',
- is_default char(1) default 'N' comment '是否默认(Y是 N否)',
- status char(1) default '0' comment '状态(0正常 1停用)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (dict_code)
+ dict_code bigint(20) not null comment '字典编码',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ dict_sort int(4) default 0 comment '字典排序',
+ dict_label varchar(100) default '' comment '字典标签',
+ dict_value varchar(100) default '' comment '字典键值',
+ dict_type varchar(100) default '' comment '字典类型',
+ css_class varchar(100) default null comment '样式属性(其他样式扩展)',
+ list_class varchar(100) default null comment '表格回显样式',
+ is_default char(1) default 'N' comment '是否默认(Y是 N否)',
+ status char(1) default '0' comment '状态(0正常 1停用)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (dict_code)
) engine=innodb comment = '字典数据表';
insert into sys_dict_data values(1, '000000', 1, '男', '0', 'sys_user_sex', '', '', 'Y', '0', 103, 1, sysdate(), null, null, '性别男');
@@ -621,19 +659,19 @@ insert into sys_dict_data values(28, '000000', 2, '失败', '1', 'sys
-- ----------------------------
drop table if exists sys_config;
create table sys_config (
- config_id bigint(20) not null comment '参数主键',
- tenant_id varchar(20) default '000000' comment '租户编号',
- config_name varchar(100) default '' comment '参数名称',
- config_key varchar(100) default '' comment '参数键名',
- config_value varchar(500) default '' comment '参数键值',
- config_type char(1) default 'N' comment '系统内置(Y是 N否)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (config_id)
+ config_id bigint(20) not null comment '参数主键',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ config_name varchar(100) default '' comment '参数名称',
+ config_key varchar(100) default '' comment '参数键名',
+ config_value varchar(500) default '' comment '参数键值',
+ config_type char(1) default 'N' comment '系统内置(Y是 N否)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (config_id)
) engine=innodb comment = '参数配置表';
insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate(), null, null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' );
@@ -648,19 +686,19 @@ insert into sys_config values(11, '000000', 'OSS预览列表资源开关',
-- ----------------------------
drop table if exists sys_logininfor;
create table sys_logininfor (
- info_id bigint(20) not null comment '访问ID',
- tenant_id varchar(20) default '000000' comment '租户编号',
- user_name varchar(50) default '' comment '用户账号',
- ipaddr varchar(128) default '' comment '登录IP地址',
- login_location varchar(255) default '' comment '登录地点',
- browser varchar(50) default '' comment '浏览器类型',
- os varchar(50) default '' comment '操作系统',
- status char(1) default '0' comment '登录状态(0成功 1失败)',
- msg varchar(255) default '' comment '提示消息',
- login_time datetime comment '访问时间',
- primary key (info_id),
- key idx_sys_logininfor_s (status),
- key idx_sys_logininfor_lt (login_time)
+ info_id bigint(20) not null comment '访问ID',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ user_name varchar(50) default '' comment '用户账号',
+ ipaddr varchar(128) default '' comment '登录IP地址',
+ login_location varchar(255) default '' comment '登录地点',
+ browser varchar(50) default '' comment '浏览器类型',
+ os varchar(50) default '' comment '操作系统',
+ status char(1) default '0' comment '登录状态(0成功 1失败)',
+ msg varchar(255) default '' comment '提示消息',
+ login_time datetime comment '访问时间',
+ primary key (info_id),
+ key idx_sys_logininfor_s (status),
+ key idx_sys_logininfor_lt (login_time)
) engine=innodb comment = '系统访问记录';
@@ -669,19 +707,19 @@ create table sys_logininfor (
-- ----------------------------
drop table if exists sys_notice;
create table sys_notice (
- notice_id bigint(20) not null comment '公告ID',
- tenant_id varchar(20) default '000000' comment '租户编号',
- notice_title varchar(50) not null comment '公告标题',
- notice_type char(1) not null comment '公告类型(1通知 2公告)',
- notice_content longblob default null comment '公告内容',
- status char(1) default '0' comment '公告状态(0正常 1关闭)',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(255) default null comment '备注',
- primary key (notice_id)
+ notice_id bigint(20) not null comment '公告ID',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ notice_title varchar(50) not null comment '公告标题',
+ notice_type char(1) not null comment '公告类型(1通知 2公告)',
+ notice_content longblob default null comment '公告内容',
+ status char(1) default '0' comment '公告状态(0正常 1关闭)',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(255) default null comment '备注',
+ primary key (notice_id)
) engine=innodb comment = '通知公告表';
-- ----------------------------
@@ -696,29 +734,29 @@ insert into sys_notice values('2', '000000', '维护通知:2018-07-01 系统
-- ----------------------------
drop table if exists gen_table;
create table gen_table (
- table_id bigint(20) not null comment '编号',
- data_name varchar(200) default '' comment '数据源名称',
- table_name varchar(200) default '' comment '表名称',
- table_comment varchar(500) default '' comment '表描述',
- sub_table_name varchar(64) default null comment '关联子表的表名',
- sub_table_fk_name varchar(64) default null comment '子表关联的外键名',
- class_name varchar(100) default '' comment '实体类名称',
- tpl_category varchar(200) default 'crud' comment '使用的模板(crud单表操作 tree树表操作)',
- package_name varchar(100) comment '生成包路径',
- module_name varchar(30) comment '生成模块名',
- business_name varchar(30) comment '生成业务名',
- function_name varchar(50) comment '生成功能名',
- function_author varchar(50) comment '生成功能作者',
- gen_type char(1) default '0' comment '生成代码方式(0zip压缩包 1自定义路径)',
- gen_path varchar(200) default '/' comment '生成路径(不填默认项目路径)',
- options varchar(1000) comment '其它生成选项',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (table_id)
+ table_id bigint(20) not null comment '编号',
+ data_name varchar(200) default '' comment '数据源名称',
+ table_name varchar(200) default '' comment '表名称',
+ table_comment varchar(500) default '' comment '表描述',
+ sub_table_name varchar(64) default null comment '关联子表的表名',
+ sub_table_fk_name varchar(64) default null comment '子表关联的外键名',
+ class_name varchar(100) default '' comment '实体类名称',
+ tpl_category varchar(200) default 'crud' comment '使用的模板(crud单表操作 tree树表操作)',
+ package_name varchar(100) comment '生成包路径',
+ module_name varchar(30) comment '生成模块名',
+ business_name varchar(30) comment '生成业务名',
+ function_name varchar(50) comment '生成功能名',
+ function_author varchar(50) comment '生成功能作者',
+ gen_type char(1) default '0' comment '生成代码方式(0zip压缩包 1自定义路径)',
+ gen_path varchar(200) default '/' comment '生成路径(不填默认项目路径)',
+ options varchar(1000) comment '其它生成选项',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ primary key (table_id)
) engine=innodb comment = '代码生成业务表';
@@ -727,30 +765,30 @@ create table gen_table (
-- ----------------------------
drop table if exists gen_table_column;
create table gen_table_column (
- column_id bigint(20) not null comment '编号',
- table_id bigint(20) comment '归属表编号',
- column_name varchar(200) comment '列名称',
- column_comment varchar(500) comment '列描述',
- column_type varchar(100) comment '列类型',
- java_type varchar(500) comment 'JAVA类型',
- java_field varchar(200) comment 'JAVA字段名',
- is_pk char(1) comment '是否主键(1是)',
- is_increment char(1) comment '是否自增(1是)',
- is_required char(1) comment '是否必填(1是)',
- is_insert char(1) comment '是否为插入字段(1是)',
- is_edit char(1) comment '是否编辑字段(1是)',
- is_list char(1) comment '是否列表字段(1是)',
- is_query char(1) comment '是否查询字段(1是)',
- query_type varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)',
- html_type varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
- dict_type varchar(200) default '' comment '字典类型',
- sort int comment '排序',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime comment '更新时间',
- primary key (column_id)
+ column_id bigint(20) not null comment '编号',
+ table_id bigint(20) comment '归属表编号',
+ column_name varchar(200) comment '列名称',
+ column_comment varchar(500) comment '列描述',
+ column_type varchar(100) comment '列类型',
+ java_type varchar(500) comment 'JAVA类型',
+ java_field varchar(200) comment 'JAVA字段名',
+ is_pk char(1) comment '是否主键(1是)',
+ is_increment char(1) comment '是否自增(1是)',
+ is_required char(1) comment '是否必填(1是)',
+ is_insert char(1) comment '是否为插入字段(1是)',
+ is_edit char(1) comment '是否编辑字段(1是)',
+ is_list char(1) comment '是否列表字段(1是)',
+ is_query char(1) comment '是否查询字段(1是)',
+ query_type varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)',
+ html_type varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
+ dict_type varchar(200) default '' comment '字典类型',
+ sort int comment '排序',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime comment '更新时间',
+ primary key (column_id)
) engine=innodb comment = '代码生成业务表字段';
-- ----------------------------
@@ -758,19 +796,19 @@ create table gen_table_column (
-- ----------------------------
drop table if exists sys_oss;
create table sys_oss (
- oss_id bigint(20) not null comment '对象存储主键',
- tenant_id varchar(20) default '000000' comment '租户编号',
- file_name varchar(255) not null default '' comment '文件名',
- original_name varchar(255) not null default '' comment '原名',
- file_suffix varchar(10) not null default '' comment '文件后缀名',
- url varchar(500) not null comment 'URL地址',
- create_dept bigint(20) default null comment '创建部门',
- create_time datetime default null comment '创建时间',
- create_by bigint(20) default null comment '上传人',
- update_time datetime default null comment '更新时间',
- update_by bigint(20) default null comment '更新人',
- service varchar(20) not null default 'minio' comment '服务商',
- primary key (oss_id)
+ oss_id bigint(20) not null comment '对象存储主键',
+ tenant_id varchar(20) default '000000' comment '租户编号',
+ file_name varchar(255) not null default '' comment '文件名',
+ original_name varchar(255) not null default '' comment '原名',
+ file_suffix varchar(10) not null default '' comment '文件后缀名',
+ url varchar(500) not null comment 'URL地址',
+ create_dept bigint(20) default null comment '创建部门',
+ create_time datetime default null comment '创建时间',
+ create_by bigint(20) default null comment '上传人',
+ update_time datetime default null comment '更新时间',
+ update_by bigint(20) default null comment '更新人',
+ service varchar(20) not null default 'minio' comment '服务商',
+ primary key (oss_id)
) engine=innodb comment ='OSS对象存储表';
-- ----------------------------
@@ -778,34 +816,34 @@ create table sys_oss (
-- ----------------------------
drop table if exists sys_oss_config;
create table sys_oss_config (
- oss_config_id bigint(20) not null comment '主建',
- tenant_id varchar(20) default '000000'comment '租户编号',
- config_key varchar(20) not null default '' comment '配置key',
- access_key varchar(255) default '' comment 'accessKey',
- secret_key varchar(255) default '' comment '秘钥',
- bucket_name varchar(255) default '' comment '桶名称',
- prefix varchar(255) default '' comment '前缀',
- endpoint varchar(255) default '' comment '访问站点',
- domain varchar(255) default '' comment '自定义域名',
- is_https char(1) default 'N' comment '是否https(Y=是,N=否)',
- region varchar(255) default '' comment '域',
- access_policy char(1) not null default '1' comment '桶权限类型(0=private 1=public 2=custom)',
- status char(1) default '1' comment '是否默认(0=是,1=否)',
- ext1 varchar(255) default '' comment '扩展字段',
- create_dept bigint(20) default null comment '创建部门',
- create_by bigint(20) default null comment '创建者',
- create_time datetime default null comment '创建时间',
- update_by bigint(20) default null comment '更新者',
- update_time datetime default null comment '更新时间',
- remark varchar(500) default null comment '备注',
- primary key (oss_config_id)
+ oss_config_id bigint(20) not null comment '主建',
+ tenant_id varchar(20) default '000000'comment '租户编号',
+ config_key varchar(20) not null default '' comment '配置key',
+ access_key varchar(255) default '' comment 'accessKey',
+ secret_key varchar(255) default '' comment '秘钥',
+ bucket_name varchar(255) default '' comment '桶名称',
+ prefix varchar(255) default '' comment '前缀',
+ endpoint varchar(255) default '' comment '访问站点',
+ domain varchar(255) default '' comment '自定义域名',
+ is_https char(1) default 'N' comment '是否https(Y=是,N=否)',
+ region varchar(255) default '' comment '域',
+ access_policy char(1) not null default '1' comment '桶权限类型(0=private 1=public 2=custom)',
+ status char(1) default '1' comment '是否默认(0=是,1=否)',
+ ext1 varchar(255) default '' comment '扩展字段',
+ create_dept bigint(20) default null comment '创建部门',
+ create_by bigint(20) default null comment '创建者',
+ create_time datetime default null comment '创建时间',
+ update_by bigint(20) default null comment '更新者',
+ update_time datetime default null comment '更新时间',
+ remark varchar(500) default null comment '备注',
+ 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);
-- ----------------------------
-- 系统授权表
diff --git a/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql b/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql
index a9c2cc1a3..8bef87ca7 100644
--- a/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql
+++ b/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql
@@ -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,
diff --git a/script/sql/update/oracle/update_5.0-5.1.sql b/script/sql/update/oracle/update_5.0-5.1.sql
index 551e97514..9aa6d9723 100644
--- a/script/sql/update/oracle/update_5.0-5.1.sql
+++ b/script/sql/update/oracle/update_5.0-5.1.sql
@@ -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代表删除)';
diff --git a/script/sql/update/postgres/update_5.0-5.1.sql b/script/sql/update/postgres/update_5.0-5.1.sql
index 4fa7f2dcf..9d94230f8 100644
--- a/script/sql/update/postgres/update_5.0-5.1.sql
+++ b/script/sql/update/postgres/update_5.0-5.1.sql
@@ -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代表删除)';
diff --git a/script/sql/update/sqlserver/update_5.0-5.1.sql b/script/sql/update/sqlserver/update_5.0-5.1.sql
index 835ca20c5..3421a9b8f 100644
--- a/script/sql/update/sqlserver/update_5.0-5.1.sql
+++ b/script/sql/update/sqlserver/update_5.0-5.1.sql
@@ -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
diff --git a/script/sql/update/update_5.0-5.1.sql b/script/sql/update/update_5.0-5.1.sql
index 29595209d..353ca213a 100644
--- a/script/sql/update/update_5.0-5.1.sql
+++ b/script/sql/update/update_5.0-5.1.sql
@@ -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 = '社会化关系表';