Description
版本号: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 commentedon Aug 8, 2019
非常感谢 ,已收录
fly1206 commentedon Aug 13, 2019
已修正 下个版本发布