mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
sso service
This commit is contained in:
parent
dc2b493748
commit
8699c104a5
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.web.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||||
|
import org.dromara.common.tenant.properties.TenantProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusAutoConfigTenant {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
||||||
|
return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.dromara.common.tenant.handle;
|
package org.dromara.web.config;
|
||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
@ -8,8 +8,9 @@ import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
|||||||
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
|
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
|
||||||
import org.dromara.common.satoken.core.service.SaPermissionImpl;
|
import org.dromara.common.satoken.core.service.SaPermissionImpl;
|
||||||
import org.dromara.common.satoken.handler.SaTokenExceptionHandler;
|
import org.dromara.common.satoken.handler.SaTokenExceptionHandler;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +18,7 @@ import org.springframework.context.annotation.PropertySource;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@Configuration
|
||||||
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
||||||
public class SaTokenConfig {
|
public class SaTokenConfig {
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ public class SaTokenConfig {
|
|||||||
* 自定义dao层存储
|
* 自定义dao层存储
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@Primary
|
||||||
public SaTokenDao saTokenDao() {
|
public SaTokenDao saTokenDao() {
|
||||||
return new PlusSaTokenDao();
|
return new PlusSaTokenDao();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler;
|
import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler;
|
||||||
@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableTransactionManagement(proxyTargetClass = true)
|
@EnableTransactionManagement(proxyTargetClass = true)
|
||||||
@MapperScan("${mybatis-plus.mapperPackage}")
|
@MapperScan("${mybatis-plus.mapperPackage}")
|
||||||
@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class)
|
@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class)
|
||||||
|
@Slf4j
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -37,6 +39,7 @@ public class MybatisPlusConfig {
|
|||||||
TenantLineInnerInterceptor tenant = SpringUtils.getBean(TenantLineInnerInterceptor.class);
|
TenantLineInnerInterceptor tenant = SpringUtils.getBean(TenantLineInnerInterceptor.class);
|
||||||
interceptor.addInnerInterceptor(tenant);
|
interceptor.addInnerInterceptor(tenant);
|
||||||
} catch (BeansException ignore) {
|
} catch (BeansException ignore) {
|
||||||
|
log.warn("MybatisPlus 多租户未打开!");
|
||||||
}
|
}
|
||||||
// 数据权限处理
|
// 数据权限处理
|
||||||
interceptor.addInnerInterceptor(dataPermissionInterceptor());
|
interceptor.addInnerInterceptor(dataPermissionInterceptor());
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
package org.dromara.common.tenant.config;
|
package org.dromara.common.tenant.config;
|
||||||
|
|
||||||
import cn.dev33.satoken.dao.SaTokenDao;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
|
||||||
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||||
import org.dromara.common.mybatis.config.MybatisPlusConfig;
|
|
||||||
import org.dromara.common.redis.config.RedisConfig;
|
import org.dromara.common.redis.config.RedisConfig;
|
||||||
import org.dromara.common.redis.config.properties.RedissonProperties;
|
import org.dromara.common.redis.config.properties.RedissonProperties;
|
||||||
import org.dromara.common.tenant.core.TenantSaTokenDao;
|
|
||||||
import org.dromara.common.tenant.handle.PlusTenantLineHandler;
|
|
||||||
import org.dromara.common.tenant.handle.TenantKeyPrefixHandler;
|
import org.dromara.common.tenant.handle.TenantKeyPrefixHandler;
|
||||||
import org.dromara.common.tenant.manager.TenantSpringCacheManager;
|
import org.dromara.common.tenant.manager.TenantSpringCacheManager;
|
||||||
import org.dromara.common.tenant.properties.TenantProperties;
|
import org.dromara.common.tenant.properties.TenantProperties;
|
||||||
@ -16,7 +11,6 @@ import org.redisson.config.ClusterServersConfig;
|
|||||||
import org.redisson.config.SingleServerConfig;
|
import org.redisson.config.SingleServerConfig;
|
||||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
@ -33,19 +27,19 @@ import org.springframework.context.annotation.Primary;
|
|||||||
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
|
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
|
||||||
public class TenantConfig {
|
public class TenantConfig {
|
||||||
|
|
||||||
@ConditionalOnBean(MybatisPlusConfig.class)
|
// @ConditionalOnBean(MybatisPlusConfig.class)
|
||||||
@AutoConfiguration(after = {MybatisPlusConfig.class})
|
// @AutoConfiguration(after = {MybatisPlusConfig.class})
|
||||||
static class MybatisPlusConfiguration {
|
// static class MybatisPlusConfiguration {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 多租户插件
|
// * 多租户插件
|
||||||
*/
|
// */
|
||||||
@Bean
|
// @Bean
|
||||||
public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
// public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
||||||
return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
// return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedissonAutoConfigurationCustomizer tenantRedissonCustomizer(RedissonProperties redissonProperties) {
|
public RedissonAutoConfigurationCustomizer tenantRedissonCustomizer(RedissonProperties redissonProperties) {
|
||||||
@ -77,13 +71,13 @@ public class TenantConfig {
|
|||||||
return new TenantSpringCacheManager();
|
return new TenantSpringCacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 多租户鉴权dao实现
|
// * 多租户鉴权dao实现
|
||||||
*/
|
// */
|
||||||
@Primary
|
// @Primary
|
||||||
@Bean
|
// @Bean
|
||||||
public SaTokenDao tenantSaTokenDao() {
|
// public SaTokenDao tenantSaTokenDao() {
|
||||||
return new TenantSaTokenDao();
|
// return new TenantSaTokenDao();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
package org.dromara.common.tenant.core;
|
package org.dromara.common.tenant.core;
|
||||||
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户基类
|
* 租户基类
|
||||||
@ -10,8 +18,54 @@ import lombok.EqualsAndHashCode;
|
|||||||
* @author Michelle.Chung
|
* @author Michelle.Chung
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class TenantEntity implements Serializable {
|
||||||
public class TenantEntity extends BaseEntity {
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索值
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String searchValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建部门
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户编号
|
* 租户编号
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
<module>ruoyi-generator</module>
|
<module>ruoyi-generator</module>
|
||||||
<module>ruoyi-job</module>
|
<module>ruoyi-job</module>
|
||||||
<module>ruoyi-system</module>
|
<module>ruoyi-system</module>
|
||||||
<module>ruoyi-system-saas</module>
|
<!-- <module>ruoyi-system-saas</module>-->
|
||||||
<module>ruoyi-workflow</module>
|
<module>ruoyi-workflow</module>
|
||||||
<module>ruoyi-sso-server</module>
|
<module>ruoyi-sso-server</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.pj;
|
package com.pj;
|
||||||
|
|
||||||
import cn.dev33.satoken.sso.SaSsoManager;
|
import cn.dev33.satoken.sso.SaSsoManager;
|
||||||
|
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|||||||
@ -3,20 +3,17 @@ package com.pj.config;
|
|||||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||||
import cn.dev33.satoken.stp.StpInterface;
|
import cn.dev33.satoken.stp.StpInterface;
|
||||||
import cn.dev33.satoken.stp.StpLogic;
|
import cn.dev33.satoken.stp.StpLogic;
|
||||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
|
||||||
import org.dromara.common.satoken.core.service.SaPermissionImpl;
|
import org.dromara.common.satoken.core.service.SaPermissionImpl;
|
||||||
import org.dromara.common.satoken.handler.SaTokenExceptionHandler;
|
import org.dromara.common.satoken.handler.SaTokenExceptionHandler;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sa-token 配置
|
* sa-token 配置
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@Configuration
|
||||||
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
|
||||||
public class SaTokenConfig {
|
public class SaTokenConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@ -94,23 +94,10 @@ dubbo:
|
|||||||
registry:
|
registry:
|
||||||
address: nacos://127.0.0.1:8848
|
address: nacos://127.0.0.1:8848
|
||||||
group: DUBBO_GROUP
|
group: DUBBO_GROUP
|
||||||
username: ${spring.cloud.nacos.username}
|
username: nacos
|
||||||
password: ${spring.cloud.nacos.password}
|
password: nacos
|
||||||
parameters:
|
parameters:
|
||||||
namespace: c5c00044-93e6-4e66-8060-3f39aa7ab82b
|
namespace: c5c00044-93e6-4e66-8060-3f39aa7ab82b
|
||||||
metadata-report:
|
|
||||||
address: redis://${spring.data.redis.host}:${spring.data.redis.port}
|
|
||||||
group: DUBBO_GROUP
|
|
||||||
username: dubbo
|
|
||||||
password: ${spring.data.redis.password}
|
|
||||||
# 集群开关
|
|
||||||
cluster: false
|
|
||||||
parameters:
|
|
||||||
namespace: ${spring.profiles.active}
|
|
||||||
database: ${spring.data.redis.database}
|
|
||||||
timeout: ${spring.data.redis.timeout}
|
|
||||||
# 集群地址 cluster 为 true 生效
|
|
||||||
backup: 127.0.0.1:6379,127.0.0.1:6381
|
|
||||||
# 消费者相关配置
|
# 消费者相关配置
|
||||||
consumer:
|
consumer:
|
||||||
# 结果缓存(LRU算法)
|
# 结果缓存(LRU算法)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user