<?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.ZhllUserMaterialMapper">
    
    <resultMap type="com.dgtis.dorm.manager.db.domain.ZhllUserMaterial" id="ZhllUserMaterialResult">
        <result property="id"    column="id"    />
        <result property="materialName"    column="material_name"    />
        <result property="materialUrl"    column="material_url"    />
        <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="selectZhllUserMaterialVo">
        select id, material_name, material_url, user_id, add_time, add_user, modify_time, modify_user, del_flag from zhll_user_material
    </sql>
	
    <select id="selectZhllUserMaterialList" parameterType="com.dgtis.dorm.manager.db.domain.ZhllUserMaterial" resultMap="ZhllUserMaterialResult">
        <include refid="selectZhllUserMaterialVo"/>
        <where>
            <if test="id != null  and id != '' "> and id = #{id}</if>
             <if test="materialName != null  and materialName != '' "> and material_name = #{materialName}</if>
             <if test="materialUrl != null  and materialUrl != '' "> and material_url = #{materialUrl}</if>
             <if test="userId != null  and userId != '' "> and user_id = #{userId}</if>
             <if test="addTime != null "> and add_time = #{addTime}</if>
             <if test="addUser != null  and addUser != '' "> and add_user = #{addUser}</if>
             <if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
             <if test="modifyUser != null  and modifyUser != '' "> and modify_user = #{modifyUser}</if>
         </where>
    </select>
    
    <select id="selectZhllUserMaterialById" parameterType="String" resultMap="ZhllUserMaterialResult">
        <include refid="selectZhllUserMaterialVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertZhllUserMaterial" parameterType="com.dgtis.dorm.manager.db.domain.ZhllUserMaterial">
        insert into zhll_user_material
		<trim prefix="(" suffix=")" suffixOverrides=",">
            add_time,
            modify_time,
            del_flag,
			<if test="id != null  and id != ''  ">id,</if>
			<if test="materialName != null  and materialName != ''  ">material_name,</if>
			<if test="materialUrl != null  and materialUrl != ''  ">material_url,</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="materialName != null  and materialName != ''  ">#{materialName},</if>
			<if test="materialUrl != null  and materialUrl != ''  ">#{materialUrl},</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="updateZhllUserMaterial" parameterType="com.dgtis.dorm.manager.db.domain.ZhllUserMaterial">
        update zhll_user_material
        <trim prefix="SET" suffixOverrides=",">
            modify_time = now(),
            <if test="materialName != null  and materialName != ''  ">material_name = #{materialName},</if>
            <if test="materialUrl != null  and materialUrl != ''  ">material_url = #{materialUrl},</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_user_material where id = #{id}
    </delete>

    
</mapper>