<?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.tcZz.mapper.TcAqyhMapper">

    <resultMap type="TcAqyh" id="TcAqyhResult">
        <result property="id" column="id"/>
        <result property="yhName" column="yh_name"/>
        <result property="yhCount" column="yh_count"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectTcAqyhVo">
        select id, yh_name, yh_count, create_by, create_time, update_by, update_time, remark from tc_aqyh
    </sql>

    <select id="selectTcAqyhList" parameterType="TcAqyh" resultMap="TcAqyhResult">
        <include refid="selectTcAqyhVo"/>
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="yhName != null  and yhName != ''">and yh_name like concat('%', #{yhName}, '%')</if>
            <if test="yhCount != null  and yhCount != ''">and yh_count = #{yhCount}</if>
            <if test="createBy != null  and createBy != ''">and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
                and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
            </if>
            <if test="updateBy != null  and updateBy != ''">and update_by = #{updateBy}</if>
            <if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''">
                and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}
            </if>
            <if test="remark != null  and remark != ''">and remark = #{remark}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectTcAqyhById" parameterType="Long" resultMap="TcAqyhResult">
        <include refid="selectTcAqyhVo"/>
        where id = #{id}
    </select>

    <insert id="insertTcAqyh" parameterType="TcAqyh" useGeneratedKeys="true" keyProperty="id">
        insert into tc_aqyh
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="yhName != null">yh_name,</if>
            <if test="yhCount != null">yh_count,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="yhName != null">#{yhName},</if>
            <if test="yhCount != null">#{yhCount},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateTcAqyh" parameterType="TcAqyh">
        update tc_aqyh
        <trim prefix="SET" suffixOverrides=",">
            <if test="yhName != null">yh_name = #{yhName},</if>
            <if test="yhCount != null">yh_count = #{yhCount},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
    <update id="updateByisStatus">
        UPDATE tc_aqyh
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcAqyhById" parameterType="Long">
        delete from tc_aqyh where id = #{id}
    </delete>

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