<?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.zcloud.mapper.datasource.message.MessageTemplatesMapper">

	<!--表名 -->
	<sql id="tableName">
		MESSAGE_TEMPLATES
	</sql>
	<!-- 字段 -->
	<sql id="Field">
		TEMPLATES_ID,
		NAME,
		CONTENT,
		URL,
		PID,
		PARAMETER1,
		PARAMETER2,
		PARAMETER3,
		SYNOPSIS,
		ENCODE,
		WEIGHT,
		CREATE_TIME
	</sql>
	<!-- 字段值 -->
	<sql id="FieldValue">
		#{TEMPLATES_ID},
		#{NAME},
		#{CONTENT},
		#{URL},
		#{PID},
		#{PARAMETER1},
		#{PARAMETER2},
		#{PARAMETER3},
		#{SYNOPSIS},
		#{ENCODE},
		#{WEIGHT},
		#{CREATE_TIME}
	</sql>

	<!-- 新增-->
	<insert id="save" parameterType="pd">
		insert into
	<include refid="tableName"></include>
		(
	<include refid="Field"></include>
		) values (
	<include refid="FieldValue"></include>
		)
	</insert>

	<!-- 删除-->
	<delete id="delete" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			ISDELETE = '1'
		where
			AIWARNING_ID = #{AIWARNING_ID}
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			TEMPLATES_ID = #{TEMPLATES_ID}
		<if test="TEMPLATES_ID != null and TEMPLATES_ID != ''">
			,TEMPLATES_ID = #{TEMPLATES_ID}
		</if>
		<if test="NAME != null and NAME != ''">
			,NAME = #{NAME}
		</if>
		<if test="CONTENT != null and CONTENT != ''">
			,CONTENT = #{CONTENT}
		</if>
		<if test="URL != null and URL != ''">
			,URL = #{URL}
		</if>
		<if test="PID != null and PID != ''">
			,PID = #{PID}
		</if>
		<if test="PARAMETER1 != null and PARAMETER1 != ''">
			,PARAMETER1 = #{PARAMETER1}
		</if>
		<if test="PARAMETER2 != null and PARAMETER2 != ''">
			,PARAMETER2 = #{PARAMETER2}
		</if>
		<if test="PARAMETER3 != null and PARAMETER3 != ''">
			,PARAMETER3 = #{PARAMETER3}
		</if>
		<if test="SYNOPSIS != null and SYNOPSIS != ''">
			,SYNOPSIS = #{SYNOPSIS}
		</if>
		<if test="ENCODE != null and ENCODE != ''">
			,ENCODE = #{ENCODE}
		</if>
		<if test="WEIGHT != null and WEIGHT != ''">
			,WEIGHT = #{WEIGHT}
		</if>
		<if test="CREATE_TIME != null and CREATE_TIME != ''">
			,CREATE_TIME = #{CREATE_TIME}
		</if>
		where
			TEMPLATES_ID = #{TEMPLATES_ID}
	</update>
	<!-- 通过ID获取数据 -->
	<select id="findById" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include>
		where
			TEMPLATES_ID = #{TEMPLATES_ID}
	</select>
	<!-- 通过编码获取数据 -->
	<select id="findByEncode" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include>
		where
		ENCODE = #{ENCODE}
	</select>
	<!-- 获取列表数据 -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include>
	</select>
</mapper>
