这个if的执行顺序是否应该是: 先判断用户是否是管理员,不是的话再判断是否是教师,不是教师再判断是否是培训组,都不是这三个角色就执行最后一句and dept_hrbp ='"+fine_username+"' 但是我给一个用户设置了教师角色后,是先执行管理员的判断,再执行培训组的判断,教师的判断放在了最后,导致我设置的教师角色没效果。这是什么情况 有大佬知道什么原因吗 SELECT user_id,user_name,user_num,ud_user_id,ud_dept_id,dept_name,ud_pos_id,pos_name,user_mobile,user_type,user_entry_date,user_cardNo from hr_user LEFT JOIN hr_user_dept on user_id=ud_user_id left join hr_department on dept_id=ud_dept_id left join hr_position on pos_id=ud_pos_id where dept_id in ( SELECT dept_id FROM [dbo].[v_dept] where 1=1 ${if(INARRAY("HRBP管理员",fine_role)>0,"" ,if(INARRAY("教师",fine_role)>0,"and '4ab45e9a-057d-4394-81f7-82ba40dfbe8a' in (dept_id,dept_id1,dept_id2,dept_id3,dept_id4,dept_id5,dept_id6,dept_id7)" ,if(INARRAY("培训组",fine_role)>0,"and dept_name like '%分公司%'" ," and dept_hrbp ='"+fine_username+"'")))} ${if(len(dept_id) == 0,"" ," and '" + dept_id + "' in (dept_id,dept_id1,dept_id2,dept_id3,dept_id4,dept_id5,dept_id6,dept_id7)")} ) and user_status='在职' and dept_name not like '%旧%' and ( user_name like '%${search}%' or user_mobile like '%${search}%' or dept_name like '%${search}%' or pos_name like '%${search}%' ) ORDER BY user_num 这是数据集语句 |