<?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.ztmap.project.zhny.strategytarget.mapper.TStrategyTargetMapper">
    
    <resultMap type="TStrategyTarget" id="TStrategyTargetResult">
        <result property="id"    column="id"    />
        <result property="conditionId"    column="condition_id"    />
        <result property="targetType"    column="target_type"    />
        <result property="lightingNum"    column="lighting_num"    />
        <result property="ktwd"    column="ktwd"    />
        <result property="ktfs"    column="ktfs"    />
        <result property="dxzs"    column="dxzs"    />
    </resultMap>

    <sql id="selectTStrategyTargetVo">
        select id, condition_id, target_type, lighting_num, ktwd, ktfs, dxzs from t_strategy_target
    </sql>

    <select id="selectTStrategyTargetList" parameterType="TStrategyTarget" resultMap="TStrategyTargetResult">
        <include refid="selectTStrategyTargetVo"/>
        <where>  
            <if test="conditionId != null "> and condition_id = #{conditionId}</if>
            <if test="targetType != null "> and target_type = #{targetType}</if>
            <if test="lightingNum != null "> and lighting_num = #{lightingNum}</if>
            <if test="ktwd != null "> and ktwd = #{ktwd}</if>
            <if test="ktfs != null "> and ktfs = #{ktfs}</if>
            <if test="dxzs != null "> and dxzs = #{dxzs}</if>
        </where>
    </select>
    
    <select id="selectTStrategyTargetById" parameterType="Long" resultMap="TStrategyTargetResult">
        <include refid="selectTStrategyTargetVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTStrategyTarget" parameterType="TStrategyTarget" useGeneratedKeys="true" keyProperty="id">
        insert into t_strategy_target
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="conditionId != null">condition_id,</if>
            <if test="targetType != null">target_type,</if>
            <if test="lightingNum != null">lighting_num,</if>
            <if test="ktwd != null">ktwd,</if>
            <if test="ktfs != null">ktfs,</if>
            <if test="dxzs != null">dxzs,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="conditionId != null">#{conditionId},</if>
            <if test="targetType != null">#{targetType},</if>
            <if test="lightingNum != null">#{lightingNum},</if>
            <if test="ktwd != null">#{ktwd},</if>
            <if test="ktfs != null">#{ktfs},</if>
            <if test="dxzs != null">#{dxzs},</if>
         </trim>
    </insert>

    <update id="updateTStrategyTarget" parameterType="TStrategyTarget">
        update t_strategy_target
        <trim prefix="SET" suffixOverrides=",">
            <if test="conditionId != null">condition_id = #{conditionId},</if>
            <if test="targetType != null">target_type = #{targetType},</if>
            <if test="lightingNum != null">lighting_num = #{lightingNum},</if>
            <if test="ktwd != null">ktwd = #{ktwd},</if>
            <if test="ktfs != null">ktfs = #{ktfs},</if>
            <if test="dxzs != null">dxzs = #{dxzs},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTStrategyTargetById" parameterType="Long">
        delete from t_strategy_target where id = #{id}
    </delete>

    <delete id="deleteTStrategyTargetByIds" parameterType="String">
        delete from t_strategy_target where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>