<?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.foreverwin.mesnac.meapi.mapper.BomOperationMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.BomOperation">
        <result column="HANDLE" property="handle" />
        <result column="BOM_COMPONENT_BO" property="bomComponentBo" />
        <result column="OPERATION_BO" property="operationBo" />
        <result column="QTY" property="qty" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, BOM_COMPONENT_BO, OPERATION_BO, QTY
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="selectById" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM BOM_OPERATION WHERE HANDLE=#{handle}
    </select>

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM BOM_OPERATION
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </select>


    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM BOM_OPERATION
        <where>
            <if test="ew.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.bomComponentBo}</if>
            <if test="ew.operationBo!=null"> AND OPERATION_BO=#{ew.operationBo}</if>
            <if test="ew.qty!=null"> AND QTY=#{ew.qty}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                <if test="ew.entity.handle!=null">
                    HANDLE=#{ew.entity.handle}
                </if>
                <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMaps" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectObjs" resultType="Object">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <insert id="insert" parameterType="com.foreverwin.mesnac.meapi.model.BomOperation">
        INSERT INTO BOM_OPERATION
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="bomComponentBo!=null">BOM_COMPONENT_BO,</if>
            <if test="operationBo!=null">OPERATION_BO,</if>
            <if test="qty!=null">QTY,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="bomComponentBo!=null">#{bomComponentBo},</if>
            <if test="operationBo!=null">#{operationBo},</if>
            <if test="qty!=null">#{qty},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.BomOperation">
        INSERT INTO BOM_OPERATION
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{bomComponentBo},
            #{operationBo},
            #{qty},
        </trim>
    </insert>






    <update id="update">
        UPDATE BOM_OPERATION <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.bomComponentBo!=null">BOM_COMPONENT_BO=#{et.bomComponentBo},</if>
        <if test="et.operationBo!=null">OPERATION_BO=#{et.operationBo},</if>
        <if test="et.qty!=null">QTY=#{et.qty},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </update>


    <delete id="deleteByMap">
        DELETE FROM BOM_OPERATION
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </delete>

    <delete id="delete">
        DELETE FROM BOM_OPERATION
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.bomComponentBo!=null"> AND BOM_COMPONENT_BO=#{ew.entity.bomComponentBo}</if>
                    <if test="ew.entity.operationBo!=null"> AND OPERATION_BO=#{ew.entity.operationBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </delete>

    <!-- BaseMapper标准查询/修改/删除 -->

</mapper>
