<?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.javaweb.cms.mapper.TemplateMapper">
|
|
<resultMap type="Template" id="TemplateResult">
|
<result property="templateId" column="template_id" />
|
<result property="templateCode" column="template_code" />
|
<result property="templateType" column="template_type" />
|
<result property="templateName" column="template_name" />
|
<result property="templateContent" column="template_content" />
|
</resultMap>
|
|
<sql id="selectTemplateVo">
|
select template_id, template_code, template_type, template_name, template_content from cms_template
|
</sql>
|
|
<select id="selectTemplateList" parameterType="Template" resultMap="TemplateResult">
|
<include refid="selectTemplateVo"/>
|
<where>
|
<if test="templateCode != null and templateCode != ''"> and template_code = #{templateCode}</if>
|
<if test="templateType != null and templateType != ''"> and template_type = #{templateType}</if>
|
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
|
<if test="templateContent != null and templateContent != ''"> and template_content = #{templateContent}</if>
|
</where>
|
</select>
|
|
<select id="selectTemplateById" parameterType="Long" resultMap="TemplateResult">
|
<include refid="selectTemplateVo"/>
|
where template_id = #{templateId}
|
</select>
|
|
<insert id="insertTemplate" parameterType="Template" useGeneratedKeys="true" keyProperty="templateId">
|
insert into cms_template
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="templateCode != null and templateCode != ''">template_code,</if>
|
<if test="templateType != null and templateType != ''">template_type,</if>
|
<if test="templateName != null and templateName != ''">template_name,</if>
|
<if test="templateContent != null and templateContent != ''">template_content,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="templateCode != null and templateCode != ''">#{templateCode},</if>
|
<if test="templateType != null and templateType != ''">#{templateType},</if>
|
<if test="templateName != null and templateName != ''">#{templateName},</if>
|
<if test="templateContent != null and templateContent != ''">#{templateContent},</if>
|
</trim>
|
</insert>
|
|
<update id="updateTemplate" parameterType="Template">
|
update cms_template
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="templateCode != null and templateCode != ''">template_code = #{templateCode},</if>
|
<if test="templateType != null and templateType != ''">template_type = #{templateType},</if>
|
<if test="templateName != null and templateName != ''">template_name = #{templateName},</if>
|
<if test="templateContent != null and templateContent != ''">template_content = #{templateContent},</if>
|
</trim>
|
where template_id = #{templateId}
|
</update>
|
|
<delete id="deleteTemplateById" parameterType="Long">
|
delete from cms_template where template_id = #{templateId}
|
</delete>
|
|
<delete id="deleteTemplateByIds" parameterType="String">
|
delete from cms_template where template_id in
|
<foreach item="templateId" collection="array" open="(" separator="," close=")">
|
#{templateId}
|
</foreach>
|
</delete>
|
|
</mapper>
|