<?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.dgtis.dorm.manager.db.dao.ZhllCollectMapper">
    
    <resultMap type="com.dgtis.dorm.manager.db.domain.ZhllCollect" id="ZhllCollectResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="serviceUnid"    column="service_unid"    />
        <result property="serviceName"    column="service_name"    />
        <result property="userId"    column="user_id"    />
        <result property="addTime"    column="add_time"    />
        <result property="addUser"    column="add_user"    />
        <result property="modifyTime"    column="modify_time"    />
        <result property="modifyUser"    column="modify_user"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>
	
	<sql id="selectZhllCollectVo">
        select id,
        type,
        service_unid,
        service_name,
        user_id,
        DATE_FORMAT(add_time,'%Y-%m-%d %H:%i') add_time,
        add_user,
        DATE_FORMAT(modify_time,'%Y-%m-%d %H:%i') modify_time,
        modify_user,
        del_flag from zhll_collect
    </sql>
	
    <select id="selectZhllCollectList" parameterType="com.dgtis.dorm.manager.db.domain.ZhllCollect" resultMap="ZhllCollectResult">
        <include refid="selectZhllCollectVo"/>
        <where>
            <if test="id != null  and id != '' "> and id = #{id}</if>
             <if test="type != null  and type != '' "> and type = #{type}</if>
             <if test="serviceUnid != null  and serviceUnid != '' "> and service_unid = #{serviceUnid}</if>
             <if test="serviceName != null  and serviceName != '' "> and service_name = #{serviceName}</if>
             <if test="userId != null  and userId != '' "> and user_id = #{userId}</if>
             <if test="addUser != null  and addUser != '' "> and add_user = #{addUser}</if>
             <if test="modifyUser != null  and modifyUser != '' "> and modify_user = #{modifyUser}</if>
         </where>
        ORDER BY add_time desc
    </select>
    
    <select id="selectZhllCollectById" parameterType="String" resultMap="ZhllCollectResult">
        <include refid="selectZhllCollectVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertZhllCollect" parameterType="com.dgtis.dorm.manager.db.domain.ZhllCollect">
        insert into zhll_collect
		<trim prefix="(" suffix=")" suffixOverrides=",">
            add_time,
            modify_time,
            del_flag,
			<if test="id != null  and id != ''  ">id,</if>
			<if test="type != null  and type != ''  ">type,</if>
			<if test="serviceUnid != null  and serviceUnid != ''  ">service_unid,</if>
			<if test="serviceName != null  and serviceName != ''  ">service_name,</if>
			<if test="userId != null  and userId != ''  ">user_id,</if>
			<if test="addUser != null  and addUser != ''  ">add_user,</if>
			<if test="modifyUser != null  and modifyUser != ''  ">modify_user,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            now(),
            0,
			<if test="id != null  and id != ''  ">#{id},</if>
			<if test="type != null  and type != ''  ">#{type},</if>
			<if test="serviceUnid != null  and serviceUnid != ''  ">#{serviceUnid},</if>
			<if test="serviceName != null  and serviceName != ''  ">#{serviceName},</if>
			<if test="userId != null  and userId != ''  ">#{userId},</if>
			<if test="addUser != null  and addUser != ''  ">#{addUser},</if>
			<if test="modifyUser != null  and modifyUser != ''  ">#{modifyUser},</if>
         </trim>
    </insert>
	 
    <update id="updateZhllCollect" parameterType="com.dgtis.dorm.manager.db.domain.ZhllCollect">
        update zhll_collect
        <trim prefix="SET" suffixOverrides=",">
            modify_time = now(),
            <if test="type != null  and type != ''  ">type = #{type},</if>
            <if test="serviceUnid != null  and serviceUnid != ''  ">service_unid = #{serviceUnid},</if>
            <if test="serviceName != null  and serviceName != ''  ">service_name = #{serviceName},</if>
            <if test="userId != null  and userId != ''  ">user_id = #{userId},</if>
            <if test="modifyUser != null  and modifyUser != ''  ">modify_user = #{modifyUser},</if>
            <if test="delFlag != null  and delFlag != ''  ">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteById" parameterType="String">
        delete from zhll_collect where id = #{id}
    </delete>
    
</mapper>