<?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="com.chushang.inspection.terminal.mapper.ConsumableDetailsMapper">
  <resultMap id="BaseResultMap" type="com.chushang.inspection.terminal.po.ConsumableDetails">
    <!--@mbg.generated-->
    <!--@Table consumable_details-->
    <result column="detail_id" jdbcType="BIGINT" property="detailId" />
    <result column="dept_id" jdbcType="BIGINT" property="deptId" />
    <result column="total_id" jdbcType="BIGINT" property="totalId" />
    <result column="inbound_and_outbound_type" jdbcType="TINYINT" property="inboundAndOutboundType" />
    <result column="quantity" jdbcType="INTEGER" property="quantity" />
    <result column="version" jdbcType="BIGINT" property="version" />
    <result column="del_state" jdbcType="BOOLEAN" property="delState" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="type" property="type" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    detail_id, dept_id, total_id, inbound_and_outbound_type, quantity, version, del_state,
    create_by, create_time, update_by, update_time, type
  </sql>

  <select id="findPage" resultMap="BaseResultMap">
    SELECT cd.*, ct.type FROM consumable_details cd
    LEFT JOIN consumables_total ct ON ct.total_id = cd.total_id
    WHERE cd.del_state = 0
      <if test="query.taskId != null">
        AND ct.task_id = #{query.taskId}
      </if>
      <if test="query.type != null">
        AND ct.type = #{query.type}
      </if>
      <if test="query.totalId != null">
        AND cd.total_id = #{query.totalId}
      </if>
      <if test="1 == 1">
        <!-- 数据范围过滤 -->
        ${query.sqlParam.get('dataScope')}
      </if>
  </select>
</mapper>
