<?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.hzya.frame.u9c.bom.replace.dao.impl.VHzyaBomReplaceDaoImpl">

    <resultMap id="get-VHzyaBomReplaceEntity-result" type="com.hzya.frame.u9c.bom.replace.entity.VHzyaBomReplaceEntity" >
        <result property="detailId" column="detail_id" jdbcType="VARCHAR"/>
        <result property="bomId" column="bom_id" jdbcType="VARCHAR"/>
        <result property="itemNumber" column="item_number" jdbcType="VARCHAR"/>
        <result property="skuCode" column="sku_code" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id = "VHzyaBomReplaceEntity_Base_Column_List">
        detail_id
       ,bom_id 
        ,item_number 
        ,sku_code 
        ,code 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-VHzyaBomReplaceEntity-result" parameterType = "com.hzya.frame.u9c.bom.replace.entity.VHzyaBomReplaceEntity">
    select
    <include refid="VHzyaBomReplaceEntity_Base_Column_List" />
    from v_hzya_bom_replace
    <trim prefix="where" prefixOverrides="and"> 
        <if test="detailId != null and detailId != ''"> and detail_id = #{detailId} </if>
        <if test="bomId != null and bomId != ''"> and bom_id = #{bomId} </if>
        <if test="itemNumber != null and itemNumber != ''"> and item_number = #{itemNumber} </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code = #{skuCode} </if>
        <if test="code != null and code != ''"> and code = #{code} </if>

    </trim>

</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.u9c.bom.replace.entity.VHzyaBomReplaceEntity">
        select  count(1)   from v_hzya_bom_replace
    <trim prefix="where" prefixOverrides="and"> 
        <if test="detailId != null and detailId != ''"> and detail_id = #{detailId} </if>
        <if test="bomId != null and bomId != ''"> and bom_id = #{bomId} </if>
        <if test="itemNumber != null and itemNumber != ''"> and item_number = #{itemNumber} </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code = #{skuCode} </if>
        <if test="code != null and code != ''"> and code = #{code} </if>

    </trim>

    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-VHzyaBomReplaceEntity-result" parameterType = "com.hzya.frame.u9c.bom.replace.entity.VHzyaBomReplaceEntity">
    select
    <include refid="VHzyaBomReplaceEntity_Base_Column_List" />
    from v_hzya_bom_replace
    <trim prefix="where" prefixOverrides="and"> 
        <if test="detailId != null and detailId != ''"> and detail_id like concat('%',#{detailId},'%') </if>
        <if test="bomId != null and bomId != ''"> and bom_id like concat('%',#{bomId},'%') </if>
        <if test="itemNumber != null and itemNumber != ''"> and item_number like concat('%',#{itemNumber},'%') </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code like concat('%',#{skuCode},'%') </if>
        <if test="code != null and code != ''"> and code like concat('%',#{code},'%') </if>
        and sts='Y'
    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="VHzyaBomReplaceentity_list_or" resultMap="get-VHzyaBomReplaceEntity-result" parameterType = "com.hzya.frame.u9c.bom.replace.entity.VHzyaBomReplaceEntity">
    select
    <include refid="VHzyaBomReplaceEntity_Base_Column_List" />
    from v_hzya_bom_replace
    <trim prefix="where" prefixOverrides="and"> 
        <if test="detailId != null and detailId != ''"> or detail_id = #{detailId} </if>
        <if test="bomId != null and bomId != ''"> or bom_id = #{bomId} </if>
        <if test="itemNumber != null and itemNumber != ''"> or item_number = #{itemNumber} </if>
        <if test="skuCode != null and skuCode != ''"> or sku_code = #{skuCode} </if>
        <if test="code != null and code != ''"> or code = #{code} </if>

    </trim>

</select>

</mapper>

