mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +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 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.service.SaPermissionImpl;
|
||||
import org.dromara.common.satoken.handler.SaTokenExceptionHandler;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
@ -17,7 +18,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@Configuration
|
||||
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
||||
public class SaTokenConfig {
|
||||
|
||||
@ -39,6 +40,7 @@ public class SaTokenConfig {
|
||||
* 自定义dao层存储
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public SaTokenDao saTokenDao() {
|
||||
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.PaginationInnerInterceptor;
|
||||
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.utils.SpringUtils;
|
||||
import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler;
|
||||
@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@MapperScan("${mybatis-plus.mapperPackage}")
|
||||
@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class)
|
||||
@Slf4j
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
@ -37,6 +39,7 @@ public class MybatisPlusConfig {
|
||||
TenantLineInnerInterceptor tenant = SpringUtils.getBean(TenantLineInnerInterceptor.class);
|
||||
interceptor.addInnerInterceptor(tenant);
|
||||
} catch (BeansException ignore) {
|
||||
log.warn("MybatisPlus 多租户未打开!");
|
||||
}
|
||||
// 数据权限处理
|
||||
interceptor.addInnerInterceptor(dataPermissionInterceptor());
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
package org.dromara.common.tenant.config;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
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.mybatis.config.MybatisPlusConfig;
|
||||
import org.dromara.common.redis.config.RedisConfig;
|
||||
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.manager.TenantSpringCacheManager;
|
||||
import org.dromara.common.tenant.properties.TenantProperties;
|
||||
@ -16,7 +11,6 @@ import org.redisson.config.ClusterServersConfig;
|
||||
import org.redisson.config.SingleServerConfig;
|
||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@ -33,19 +27,19 @@ import org.springframework.context.annotation.Primary;
|
||||
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
|
||||
public class TenantConfig {
|
||||
|
||||
@ConditionalOnBean(MybatisPlusConfig.class)
|
||||
@AutoConfiguration(after = {MybatisPlusConfig.class})
|
||||
static class MybatisPlusConfiguration {
|
||||
|
||||
/**
|
||||
* 多租户插件
|
||||
*/
|
||||
@Bean
|
||||
public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
||||
return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
||||
}
|
||||
|
||||
}
|
||||
// @ConditionalOnBean(MybatisPlusConfig.class)
|
||||
// @AutoConfiguration(after = {MybatisPlusConfig.class})
|
||||
// static class MybatisPlusConfiguration {
|
||||
//
|
||||
// /**
|
||||
// * 多租户插件
|
||||
// */
|
||||
// @Bean
|
||||
// public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
||||
// return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public RedissonAutoConfigurationCustomizer tenantRedissonCustomizer(RedissonProperties redissonProperties) {
|
||||
@ -77,13 +71,13 @@ public class TenantConfig {
|
||||
return new TenantSpringCacheManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* 多租户鉴权dao实现
|
||||
*/
|
||||
@Primary
|
||||
@Bean
|
||||
public SaTokenDao tenantSaTokenDao() {
|
||||
return new TenantSaTokenDao();
|
||||
}
|
||||
// /**
|
||||
// * 多租户鉴权dao实现
|
||||
// */
|
||||
// @Primary
|
||||
// @Bean
|
||||
// public SaTokenDao tenantSaTokenDao() {
|
||||
// return new TenantSaTokenDao();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
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.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
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TenantEntity extends BaseEntity {
|
||||
public class TenantEntity implements Serializable {
|
||||
|
||||
@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-job</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-system-saas</module>
|
||||
<!-- <module>ruoyi-system-saas</module>-->
|
||||
<module>ruoyi-workflow</module>
|
||||
<module>ruoyi-sso-server</module>
|
||||
</modules>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.pj;
|
||||
|
||||
import cn.dev33.satoken.sso.SaSsoManager;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@ -3,20 +3,17 @@ package com.pj.config;
|
||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
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.handler.SaTokenExceptionHandler;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* sa-token 配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
||||
@Configuration
|
||||
public class SaTokenConfig {
|
||||
|
||||
@Bean
|
||||
|
||||
@ -94,23 +94,10 @@ dubbo:
|
||||
registry:
|
||||
address: nacos://127.0.0.1:8848
|
||||
group: DUBBO_GROUP
|
||||
username: ${spring.cloud.nacos.username}
|
||||
password: ${spring.cloud.nacos.password}
|
||||
username: nacos
|
||||
password: nacos
|
||||
parameters:
|
||||
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:
|
||||
# 结果缓存(LRU算法)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user