YouChain_WMS/nc_wms_java/solution.xml

46 lines
1.6 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="example.dao.OrdersDao">
<!-- 查询结果列 -->
<sql id="base_columns">
orders.id,
orders.order_number,
orders.status,
orders.create_time,
orders.updateInfo.operatorName,
orders.updateInfo.operateTime
<!-- 其他列... -->
</sql>
<!-- 分页查询 -->
<select id="queryPage" resultType="example.domain.vo.OrderVO">
SELECT
<include refid="base_columns"/>
FROM orders
<where>
<!-- 其他查询条件... -->
<!-- 用户过滤条件如果是admin则不过滤否则只显示当前操作员的数据 -->
AND (orders.updateInfo.operatorName=#{SESSION_USERS} or orders.updateInfo.operatorName='admin')
</where>
ORDER BY orders.create_time DESC
</select>
<!-- 另一种实现方式使用动态SQL更灵活控制 -->
<select id="queryPageAlt" resultType="example.domain.vo.OrderVO">
SELECT
<include refid="base_columns"/>
FROM orders
<where>
<!-- 其他查询条件... -->
<!-- 当前操作员为admin时不添加过滤条件否则只显示当前操作员的数据 -->
<if test="SESSION_USERS != 'admin'">
AND orders.updateInfo.operatorName=#{SESSION_USERS}
</if>
</where>
ORDER BY orders.create_time DESC
</select>
</mapper>