<?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.ruoyi.zongzhi.mapper.TcAttackMapper">
    
    <resultMap type="TcAttack" id="TcAttackResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="attackCount"    column="attack_count"    />
    </resultMap>

    <sql id="selectTcAttackVo">
        select id, name, attack_count from tc_attack
    </sql>

    <select id="selectTcAttackList" parameterType="TcAttack" resultMap="TcAttackResult">
        <include refid="selectTcAttackVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="attackCount != null "> and attack_count = #{attackCount}</if>
        </where>
    </select>
    
    <select id="selectTcAttackById" parameterType="Long" resultMap="TcAttackResult">
        <include refid="selectTcAttackVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcAttack" parameterType="TcAttack">
        insert into tc_attack
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="attackCount != null">attack_count,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="attackCount != null">#{attackCount},</if>
         </trim>
    </insert>

    <update id="updateTcAttack" parameterType="TcAttack">
        update tc_attack
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="attackCount != null">attack_count = #{attackCount},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcAttackById" parameterType="Long">
        delete from tc_attack where id = #{id}
    </delete>

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