<?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.lotusnhtj.mapper.TLotusNhtjMapper">
    
    <resultMap type="TLotusNhtj" id="TLotusNhtjResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="data"    column="data"    />
        <result property="dataTime"    column="data_time"    />
    </resultMap>

    <sql id="selectTLotusNhtjVo">
        select id, name, data, data_time from t_lotus_nhtj
    </sql>

    <select id="selectTLotusNhtjList" parameterType="TLotusNhtj" resultMap="TLotusNhtjResult">
        <include refid="selectTLotusNhtjVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="data != null "> and data = #{data}</if>
            <if test="dataTime != null  and dataTime != ''"> and data_time = #{dataTime}</if>
        </where>
    </select>
    
    <select id="selectTLotusNhtjById" parameterType="Long" resultMap="TLotusNhtjResult">
        <include refid="selectTLotusNhtjVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTLotusNhtj" parameterType="TLotusNhtj" useGeneratedKeys="true" keyProperty="id">
        insert into t_lotus_nhtj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="data != null">data,</if>
            <if test="dataTime != null">data_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="data != null">#{data},</if>
            <if test="dataTime != null">#{dataTime},</if>
         </trim>
    </insert>

    <update id="updateTLotusNhtj" parameterType="TLotusNhtj">
        update t_lotus_nhtj
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="data != null">data = #{data},</if>
            <if test="dataTime != null">data_time = #{dataTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTLotusNhtjById" parameterType="Long">
        delete from t_lotus_nhtj where id = #{id}
    </delete>

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

</mapper>