476
社区成员
发帖
与我相关
我的任务
分享
也就是根据组织关系的选择 进行tmp.org_id 的过滤
创建组织: 就是 org_id
组织关系选择 : 1 本组织 ,2 下级组织 , 3 本组及其下级组织
选择1的时候 : 就是 组织关系表sys_org 的 org_id
选择2 的时候: 就是 组织关系表sys_org 里面 parent_id 的所有 org_id :
select so.org_id from sys_org so where so.parent_id
选择3 的时候: 获取它自己的组织org_id 及其所有下级的所有组织的org_id( 这里要注意的是,假如下级组织还存在下级组织,那么这个下级组织的下级组织org_id 也要被查出来,也就是说一个递归(若下下级组织还有 下级组织也要被查出来 ) ) --我擦,咋觉得这么绕口..
我 sql 里面可以获取到 页面传递过来的 创建组织关系id(org_id),组织关系选择 org_choice (1,2,3 三个选项)
where tmp.org_id in(
case when 1= org_choice then {org_id}
when 2=org_choice then (select so.org_id from sys_org so where so.parent_org_id=org_id)
when 3=org_choice then (select org_id(界面传递过来的本组织), so.org_id from sys_org so where so.parent_org_id=org_id)
) 我现在想的这个方案是错误的(in 里面嵌套case when 是错误的解决办法 )。。所以请各位给个思路
我想把它封装 成一个函数,该怎么弄呢?
谢谢各位赐教