ZsearchTemplateMapper.xml 3.32 KB
<?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.lhcredit.project.business.zsearchTemplate.mapper.ZsearchTemplateMapper">
    
    <resultMap type="ZsearchTemplate" id="ZsearchTemplateResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="templateName"    column="template_name"    />
        <result property="templateJson"    column="template_json"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
	
	<sql id="selectZsearchTemplateVo">
        select id, user_id,template_name, template_json, create_time from zsearch_template
    </sql>
	
    <select id="selectZsearchTemplateList" parameterType="ZsearchTemplate" resultMap="ZsearchTemplateResult">
        <include refid="selectZsearchTemplateVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="templateName != null "> and template_name = #{templateName}</if>
            <if test="templateJson != null  and templateJson != '' "> and template_json = #{templateJson}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectZsearchTemplateById" parameterType="Integer" resultMap="ZsearchTemplateResult">
        <include refid="selectZsearchTemplateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertZsearchTemplate" parameterType="ZsearchTemplate">
        insert into zsearch_template
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null  ">id,</if>
			<if test="userId != null  ">user_id,</if>
			<if test="templateName != null  ">template_name,</if>
			<if test="templateJson != null  and templateJson != ''  ">template_json,</if>
			<if test="createTime != null  ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="id != null  ">#{id},</if>
			<if test="userId != null  ">#{userId},</if>
			<if test="templateName != null  ">#{templateName},</if>
			<if test="templateJson != null  and templateJson != ''  ">#{templateJson},</if>
			<if test="createTime != null  ">#{createTime},</if>
         </trim>
    </insert>
	 
    <update id="updateZsearchTemplate" parameterType="ZsearchTemplate">
        update zsearch_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null  ">user_id = #{userId},</if>
            <if test="templateName != null  ">template_name = #{templateName},</if>
            <if test="templateJson != null  and templateJson != ''  ">template_json = #{templateJson},</if>
            <if test="createTime != null  ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

	<delete id="deleteZsearchTemplateByUserId" parameterType="Integer">
        delete from zsearch_template where user_id = #{userId}
    </delete>
	
    <delete id="deleteZsearchTemplateByIds" parameterType="String">
        delete from zsearch_template where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>