Skip to content

mapper文件优化以便能更好支持多租户扩展 #404

Closed
@liaoyongxiong

Description

@liaoyongxiong
版本号:2.0.2
问题描述:

参照mybatis-plus扩展多租户后(https://mp.baomidou.com/guide/tenant.html),发现如下mapper文件的sql写法会导致sql执行异常,建议调整优化下,以支持对多租户友好扩展:
1、org/jeecg/modules/system/mapper/xml/SysAnnouncementMapper.xml
现有的写法如下:
select sa.* from sys_announcement sa,sys_announcement_send sas where sa.id = sas.annt_id and sa.send_status = '1' and sa.del_flag = '0' and sas.user_id = #{userId} and sa.msg_category = #{msgCategory} and sas.read_flag = '0'
建议修改为如下等同效果的,更好支持多租户扩展:
select * from sys_announcement where send_status = '1' and del_flag = '0' and msg_category = #{msgCategory} and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = '0' )
2、org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml
现行写法如下:
select a.* from sys_depart a join sys_user_depart b on a.id = b.dep_id where b.user_id = #{userId}
建议修改为如下等同效果,支持多租户扩展:
select * from sys_depart where id IN ( select dep_id from sys_user_depart where user_id = #{userId} )

截图&代码:

Activity

fly1206

fly1206 commented on Aug 8, 2019

@fly1206

非常感谢 ,已收录

fly1206

fly1206 commented on Aug 13, 2019

@fly1206

已修正 下个版本发布

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zhangdaiscott@liaoyongxiong@fly1206

        Issue actions

          mapper文件优化以便能更好支持多租户扩展 · Issue #404 · jeecgboot/JeecgBoot