Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议加入saas多租户模式 #166

Closed
wjxjasin opened this issue May 30, 2019 · 43 comments
Closed

建议加入saas多租户模式 #166

wjxjasin opened this issue May 30, 2019 · 43 comments

Comments

@wjxjasin
Copy link

使用mybatis plus多租户 SQL 解析器,
在MybatisPlusConfig中

//需要注入的字段
private static final String SYSTEM_TENANT_ID = "within_code";

//忽略不需要注入的表
private static final List<String> IGNORE_TENANT_TABLES = Lists.newArrayList("provider");

分页插件方法里面加入

// SQL解析处理拦截:增加租户处理回调。
TenantSqlParser tenantSqlParser = new TenantSqlParser()
.setTenantHandler(new TenantHandler() {

                @Override
                public Expression getTenantId() {
                    // 从当前系统上下文中取出当前请求的内码,通过解析器注入到SQL中。
                    Long currentWithinCode = apiContext.getCurrentProviderId();
                    if (null == currentWithinCode) {
                        throw new RuntimeException("从当前系统上下文中取出当前请求的内码为空。");
                    }
                    return new LongValue(currentWithinCode);
                }

                @Override
                public String getTenantIdColumn() {
                    return SYSTEM_TENANT_ID;
                }

                @Override
                public boolean doTableFilter(String tableName) {
                    // 忽略掉一些表:如租户表(provider)本身不需要执行这样的处理。
                    return IGNORE_TENANT_TABLES.stream().anyMatch((e) -> e.equalsIgnoreCase(tableName));
                }
            });
    paginationInterceptor.setSqlParserList(Lists.newArrayList(tenantSqlParser));
@zhangdaiscott
Copy link
Member

zhangdaiscott commented Jun 3, 2019

3q
这个会作为通用方案放在常见问题贴里,开源代码暂时不加上,用户按需自己添加;

@galaxist
Copy link

galaxist commented Aug 2, 2019

@zhangdaiscott @wjxjasin 请问租户用户登录时/sys/login时也会到这里,但登录中拿不到TENANT_ID,这时如何处理呢?

@wjxjasin
Copy link
Author

wjxjasin commented Aug 2, 2019 via email

@liaoyongxiong
Copy link

@wjxjasin 你好,我也计划在自己的项目中增加多租户的支持,能否把provider这个表的定义提供下?另外是不是需要手工在jeecg-boot内置的各个表中加上租户id的字段,比如sys_user,加上租户id字段来标示用户属于哪个租户的。
多谢

@shanggushenlong
Copy link

@liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加??

@wjxjasin
Copy link
Author

wjxjasin commented Nov 11, 2019 via email

@shanggushenlong
Copy link

看群

------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月11日(星期一) 下午4:47 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加?? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

嗯嗯,谢谢,我在群里看到了

@shanggushenlong
Copy link

@wjxjasin 你好,我在数据库表里面加了租户id字段和后端实体字段,现在运行报错,错误如下:

Original SQL: select * from sys_user where username = ? and del_flag = '0'
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2da4d506]
2019-11-11 18:47:50.942 [http-nio-8080-exec-1] ERROR o.jeecg.common.exception.JeecgBootExceptionHandler:54 - nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.lang.NullPointerException

The error may exist in file [D:\code\bronze-cps-crm\bronze-cps-crm-back\bronze-cps-module-system\target\classes\org\jeecg\modules\system\mapper\xml\SysUserMapper.xml]

The error may involve org.jeecg.modules.system.mapper.SysUserMapper.getUserByName

The error occurred while executing a query

Cause: java.lang.NullPointerException

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.lang.NullPointerException

The error may exist in file [D:\code\bronze-cps-crm\bronze-cps-crm-back\bronze-cps-module-system\target\classes\org\jeecg\modules\system\mapper\xml\SysUserMapper.xml]

The error may involve org.jeecg.modules.system.mapper.SysUserMapper.getUserByName

请问,要实现多租户,除了加字段之后,还需要加什么配置吗??

@shanggushenlong
Copy link

@wjxjasin 现在是首页登陆不进去,我将拦截器去掉就行了?请问什么原因

@wjxjasin
Copy link
Author

wjxjasin commented Nov 11, 2019 via email

@wjxjasin
Copy link
Author

wjxjasin commented Nov 11, 2019 via email

@shanggushenlong
Copy link

@wjxjasin 好的,谢谢大佬,我去试试

@shanggushenlong
Copy link

@wjxjasin 你好,昨天搞完多租户后,现在其中一个页面数据查询报错
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b7e6fa6] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@26e8f713] will not be managed by Spring
Original SQL: SELECT id,tenant_id,client_id,company_id,code,name,file_path,start_date,end_date,contract_status_dict,owner,del_flag,version,remark,user_def1,user_def2,create_by,create_time,update_by,update_time FROM crm_contract
WHERE del_flag=0
ORDER BY create_time DESC
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b7e6fa6]
2019-11-12 11:49:13.649 [http-nio-8080-exec-2] ERROR o.jeecg.common.exception.JeecgBootExceptionHandler:54 - nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.lang.NullPointerException

The error may exist in com/zp/bronze/cps/crm/mapper/CrmContractMapper.java (best guess)

The error may involve com.zp.bronze.cps.crm.mapper.CrmContractMapper.selectPage

The error occurred while executing a query

前台200,后台500,昨天加租户之前还是好的,现在报错,是不是加完租户之后导致这样的?
麻烦大佬现在有时间的话,请大佬指教一下,谢谢

@shanggushenlong
Copy link

@wjxjasin 我已经解决了,谢谢

@743636214
Copy link

@wjxjasin我已经解决了,谢谢

请问您怎么解决的 ,我也遇到这个问题了

@743636214
Copy link

看群

------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月11日(星期一) 下午4:47 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加?? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

请问群是多少啊? 我也在解决这个问题

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@743636214
Copy link

什么问题

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:37 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 看群 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月11日(星期一) 下午4:47 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加?? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 请问群是多少啊? 我也在解决这个问题 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

感谢您的回复, 就是登陆不了,不知道怎么使用mybatis 忽略sys_user

@743636214
Copy link

什么问题

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:37 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 看群 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月11日(星期一) 下午4:47 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加?? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 请问群是多少啊? 我也在解决这个问题 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

就是您说到过的,登陆时mybatis获取不到user,为null了,就报错,要忽略掉

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@shanggushenlong
Copy link

@wjxjasin 谢谢大佬的讲解

@shanggushenlong
Copy link

284271917这是群号

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@743636214
Copy link

非常感谢

@743636214
Copy link

不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。

------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

大佬您好,我这个过滤已经生效了,但是我的业务是每个用户只能看到自己的数据,所以要根据条件去模糊查询而不是等于,最终sql语句预计是这样的:
SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code like '%A03A01%' AND del_flag = '0' ,
但是现在是这样的:
SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code = A03A01 AND del_flag = '0'

@743636214
Copy link

不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。

------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

抱歉,太麻烦您了,但是不知道能不能这样做?

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@shanggushenlong
Copy link

模糊搜索可以去文档看,里面有

@743636214
Copy link

每个用户只能看到自己的数据,你可以用这个项目自带的设置数据规则去做。

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:13 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 大佬您好,我这个过滤已经生效了,但是我的业务是每个用户只能看到自己的数据,所以要根据条件去模糊查询而不是等于,最终sql语句预计是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code like '%A03A01%' AND del_flag = '0' , 但是现在是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code = A03A01 AND del_flag = '0' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

试过了,这个项目里面的好像是针对的单表的,所以选择了mybatis的,还是感谢您的解答

@743636214
Copy link

模糊搜索可以去文档看,里面有

好的,谢谢您的提醒

@wjxjasin
Copy link
Author

wjxjasin commented Nov 13, 2019 via email

@743636214
Copy link

我也做了类似的每个用户只能看到自己的数据,多表的话,我是通过写视图,当成单表,用数据规则就可以做,仅供参考,这样做性能会没有直接写好,但是好实现类似功能。

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:20 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 每个用户只能看到自己的数据,你可以用这个项目自带的设置数据规则去做。 … ------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:13 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 大佬您好,我这个过滤已经生效了,但是我的业务是每个用户只能看到自己的数据,所以要根据条件去模糊查询而不是等于,最终sql语句预计是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code like '%A03A01%' AND del_flag = '0' , 但是现在是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code = A03A01 AND del_flag = '0' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 试过了,这个项目里面的好像是针对的单表的,所以选择了mybatis的,还是感谢您的解答 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

是的,这样确实也挺好,比较好操作,再加上这个框架自带了可视化过滤数据

@743636214
Copy link

我也做了类似的每个用户只能看到自己的数据,多表的话,我是通过写视图,当成单表,用数据规则就可以做,仅供参考,这样做性能会没有直接写好,但是好实现类似功能。

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:20 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 每个用户只能看到自己的数据,你可以用这个项目自带的设置数据规则去做。 … ------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:13 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 大佬您好,我这个过滤已经生效了,但是我的业务是每个用户只能看到自己的数据,所以要根据条件去模糊查询而不是等于,最终sql语句预计是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code like '%A03A01%' AND del_flag = '0' , 但是现在是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code = A03A01 AND del_flag = '0' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 试过了,这个项目里面的好像是针对的单表的,所以选择了mybatis的,还是感谢您的解答 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

我也做了类似的每个用户只能看到自己的数据,多表的话,我是通过写视图,当成单表,用数据规则就可以做,仅供参考,这样做性能会没有直接写好,但是好实现类似功能。

------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:20 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 每个用户只能看到自己的数据,你可以用这个项目自带的设置数据规则去做。 … ------------------ 原始邮件 ------------------ 发件人: "743636214"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 下午3:13 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) 不敢当,我也是依托作者的开源项目,更改适合自己的需求,问题提的比较早而已。 … ------------------ 原始邮件 ------------------ 发件人: "pingyougou"<notifications@github.com>; 发送时间: 2019年11月13日(星期三) 中午1:55 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @wjxjasin 谢谢大佬的讲解 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 大佬您好,我这个过滤已经生效了,但是我的业务是每个用户只能看到自己的数据,所以要根据条件去模糊查询而不是等于,最终sql语句预计是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code like '%A03A01%' AND del_flag = '0' , 但是现在是这样的: SELECT COUNT(1) FROM ana_gra_info WHERE ana_gra_info.sys_org_code = A03A01 AND del_flag = '0' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. 试过了,这个项目里面的好像是针对的单表的,所以选择了mybatis的,还是感谢您的解答 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

` MyTenantParser myTenantParser = new MyTenantParser()
.setTenantHandler(new TenantHandler() {

                @Override
                public Expression getTenantId() {
                    LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
                    String orgCode;

                    if(sysUser != null){
                        orgCode = sysUser.getOrgCode();
                    }else {
                        orgCode = apiContext.getCurrentProviderId();
                    }
                    return new LongValue("'%"+orgCode+"%'");
                }`

重写TenantSqlParser类, 就能使用模糊查询了,
关键代码:
protected Expression builderExpression(Expression expression, Table table) { //生成字段名 LikeExpression le = new LikeExpression(); le.setLeftExpression(this.getAliasColumn(table)); le.setRightExpression(tenantHandler.getTenantId());

把EquesTo类换成LikeExpression 类就行了。

@shanggushenlong
Copy link

@wjxjasin 你好,请教一下,我今天将最新版本的代码合入到代码中,发现
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
Integer currtentTenantIdLong = sysUser.getTenantId();
此处租户id为null,无法获取

@shanggushenlong
Copy link

请教一下哈,现在想增加很多的用户账号,是分表创建一个新的user表,还是依旧使用sys_user 表,还有就是怎么确保新增加的user账号的权限(包括 role permission depart等表权限),我目前的设想是分表创建新user表,但是授权的话,难道就是向每个权限表里面插入记录,那样的话,数据还是不好管理??所以请教下大佬,希望大佬指点一下??

@wjxjasin
Copy link
Author

wjxjasin commented Nov 29, 2019 via email

@shanggushenlong
Copy link

你好,其实最主要问题是我每当创建一个账号信息的时候,都需要去插入相关表的信息,这样会有问题,第一,每个表都要去插入相关的数据权限,感觉很繁琐,第二,往这些表里面插入数据的话,会导致 系统表 sys_ 开头的那些表里面的数据独立性就被破坏了,有没有其他的方法呢,可不可以使用代理的方式实现??

@lifuchao
Copy link

lifuchao commented Dec 5, 2019

@liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加??

看了下你们问题最后都解决了对吧,你们之前说的很多消息是在QQ群里说的?现在看不到也没在群里,所以不知道最终完整的解决办法是什么,能否在这里贴一下呢?
是先需要有个provider表(表结构长啥样呢?),然后所有表加上租户id字段,然后再如楼主所说的改MybatisPlusConfig类吗

@wjxjasin
Copy link
Author

wjxjasin commented Dec 5, 2019 via email

@qilp
Copy link

qilp commented Apr 22, 2020

1.需要租户控制的表必须要加,不需要的在配置里面过滤掉 2.表里面加了对应的实体肯定也要加字段 3.租户表需要租户码(int),租户名称(varchar)等

------------------ 原始邮件 ------------------ 发件人: "lifuchao"<notifications@github.com>; 发送时间: 2019年12月5日(星期四) 中午11:49 收件人: "zhangdaiscott/jeecg-boot"<jeecg-boot@noreply.github.com>; 抄送: "jasin"<wjxjasin@foxmail.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [zhangdaiscott/jeecg-boot] 建议加入saas多租户模式 (#166) @liaoyongxiong 你好,我今天也在搞这个多租户的问题,是否需要每个表加字段,每个实体类加字段,前端页面字段是否需要加?? 看了下你们问题最后都解决了对吧,你们之前说的很多消息是在QQ群里说的?现在看不到也没在群里,所以不知道最终完整的解决办法是什么,能否在这里贴一下呢? 是先需要有个provider表(表结构长啥样呢?),然后所有表加上租户id字段,然后再如楼主所说的改MybatisPlusConfig类吗 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

大佬,请问多租户改造是不是做了这几步就可以了呢?最重要的就是在配置里面如何过滤不需要控制的表?

@CSuperC
Copy link

CSuperC commented May 28, 2020

@zhangdaiscott 建议升级多租户的方式,很多私有化,都要弄

@wkkkkk1024
Copy link

您好,我想问一下,如何设置一个用户登录后选择租户首页显示不同的页面,权限要怎么分配

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants