fix(sql): 修复数据库查询中的FIND_IN_SET函数兼容性问题

- 将BaseBomInfoMapper.xml中的FIND_IN_SET替换为INSTR函数以提高数据库兼容性
- 更新DataScopeAspect.java中部门数据权限查询的FIND_IN_SET为INSTR函数
- 修改OrderBomInfoMapper.xml中子级BOM查询的FIND_IN_SET函数
- 替换SysDeptMapper.xml中部门层级查询的FIND_IN_SET为INSTR函数
- 更新SysUserMapper.xml中用户查询的部门层级条件为INSTR函数
- 移除所有XML映射文件末尾多余的空行以保持代码整洁
master
zangch@mesnac.com 1 day ago
parent 26fcb8cc09
commit b22ed8f6af

@ -169,7 +169,7 @@
</delete>
<select id="selectChildrenBomById" parameterType="String" resultMap="OrderBomInfoResult">
select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
select * from order_bominfo where INSTR(',' || ancestors || ',', ',' || #{materialCode} || ',') <![CDATA[ > ]]> 0
</select>
@ -199,4 +199,4 @@
#{item.materialCode}
</foreach>
</update>
</mapper>
</mapper>

@ -124,7 +124,7 @@ public class DataScopeAspect
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
{
sqlString.append(StringUtils.format(
" OR {}.dept_id IN ( SELECT dept_id from Z_sys_dept WHERE dept_id = {} or 0 < find_in_set( {} , ancestors ) )",
" OR {}.dept_id IN ( SELECT dept_id from Z_sys_dept WHERE dept_id = {} or INSTR(',' || ancestors || ',', ',' || {} || ',') > 0 )",
deptAlias, user.getDeptId(), user.getDeptId()));
}
else if (DATA_SCOPE_SELF.equals(dataScope))

@ -101,7 +101,7 @@
<select id="selectChildrenBomById" parameterType="String" resultMap="BaseBomInfoResult">
select *
from BASE_BOMINFO
where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
where INSTR(',' || ancestors || ',', ',' || #{materialCode} || ',') <![CDATA[ > ]]> 0
</select>
<insert id="insertBaseBomInfo" parameterType="BaseBomInfo">
@ -190,4 +190,4 @@
#{objId}
</foreach>
</delete>
</mapper>
</mapper>

@ -73,11 +73,11 @@
</select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from Z_sys_dept where FIND_IN_SET(#{deptId}, ancestors) <![CDATA[ <> ]]> 0
select * from Z_sys_dept where INSTR(',' || ancestors || ',', ',' || #{deptId} || ',') <![CDATA[ > ]]> 0
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from Z_sys_dept where status = 0 and del_flag = '0' and FIND_IN_SET(#{deptId}, ancestors) <![CDATA[ <> ]]> 0
select count(*) from Z_sys_dept where status = 0 and del_flag = '0' and INSTR(',' || ancestors || ',', ',' || #{deptId} || ',') <![CDATA[ > ]]> 0
</select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
@ -157,4 +157,4 @@
</foreach>
</update>
</mapper>
</mapper>

@ -138,7 +138,7 @@
AND to_char(u.create_time, 'yyyy-mm-dd') &lt;= #{params.endTime}
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id from Z_sys_dept t WHERE FIND_IN_SET(#{deptId}, ancestors) <![CDATA[ <> ]]> 0 ))
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id from Z_sys_dept t WHERE INSTR(',' || t.ancestors || ',', ',' || #{deptId} || ',') <![CDATA[ > ]]> 0 ))
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
@ -290,4 +290,4 @@
</foreach>
</delete>
</mapper>
</mapper>

Loading…
Cancel
Save