All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.msend.dao.ITemplateDao.xml Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
<?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="net.mingsoft.msend.dao.ITemplateDao">
	
	<resultMap id="resultMap" type="net.mingsoft.msend.entity.TemplateEntity">
		<id column="template_id" property="templateId" /><!--编号 -->
		<result column="model_id" property="modelId" /><!--模块编号 -->
		<result column="app_id" property="appId" /><!--应用编号 -->
		<result column="template_title" property="templateTitle" /><!--标题 -->
		<result column="template_mail" property="templateMail" /><!-- -->
		<result column="template_sms" property="templateSms" /><!-- -->
		<result column="template_code" property="templateCode" /><!--邮件模块代码 -->
	</resultMap>
	
	<!--保存-->	
	<insert id="saveEntity" useGeneratedKeys="true" keyProperty="templateId"
		parameterType="net.mingsoft.msend.entity.TemplateEntity" >
		insert into msend_template
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="modelId != null">model_id,</if>
			<if test="appId != null">app_id,</if>
			<if test="templateTitle != null and templateTitle != ''">template_title,</if>
			<if test="templateMail != null and templateMail != ''">template_mail,</if>
			<if test="templateSms != null and templateSms != ''">template_sms,</if>
			<if test="templateCode != null and templateCode != ''">template_code,</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="modelId != null">#{modelId},</if>
			<if test="appId != null">#{appId},</if>
			<if test="templateTitle != null and templateTitle != ''">#{templateTitle},</if>
			<if test="templateMail != null and templateMail != ''">#{templateMail},</if>
			<if test="templateSms != null and templateSms != ''">#{templateSms},</if>
			<if test="templateCode != null and templateCode != ''">#{templateCode},</if>
		</trim>
	</insert>
	
	<!--更新-->	
	<update id="updateEntity" parameterType="net.mingsoft.msend.entity.TemplateEntity">
		update msend_template
		<set>
			<if test="modelId != null">model_id=#{modelId},</if>			
			<if test="appId != null">app_id=#{appId},</if>			
			<if test="templateTitle != null and templateTitle != ''">template_title=#{templateTitle},</if>			
			<if test="templateMail != null and templateMail != ''">template_mail=#{templateMail},</if>			
			<if test="templateSms != null and templateSms != ''">template_sms=#{templateSms},</if>			
			<if test="templateCode != null and templateCode != ''">template_code=#{templateCode},</if>			
		</set>
		where template_id = #{templateId}
	</update>
	
	<!--根据id获取-->	
	<select id="getEntity" resultMap="resultMap" parameterType="int">
		select * from msend_template where template_id=#{templateId}
	</select>
	
	<!--根据实体获取-->
	<select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.msend.entity.TemplateEntity">
		select * from msend_template 
		<where>
			<if test="modelId != null"> and model_id=#{modelId} </if>				
			<if test="appId != null"> and app_id=#{appId} </if>				
			<if test="templateTitle != null and templateTitle != ''"> and template_title=#{templateTitle} </if>				
			<if test="templateMail != null and templateMail != ''"> and template_mail=#{templateMail} </if>				
			<if test="templateSms != null and templateSms != ''"> and template_sms=#{templateSms} </if>				
			<if test="templateCode != null and templateCode != ''"> and template_code=#{templateCode} </if>				
		</where>
		limit 0,1
	</select>	
	
	
	<!--删除-->	
	<delete id="deleteEntity" parameterType="int">
		delete from msend_template  where template_id=#{templateId}
	</delete>	
	
	<!--批量删除-->	
	<delete id="delete" >
		delete from msend_template
		<where>
			 template_id  in <foreach collection="ids" item="item" index="index" 
			open="(" separator="," close=")">#{item}</foreach>
		</where>
	</delete>
	<!--查询全部-->	
	<select id="queryAll" resultMap="resultMap">
		select * from msend_template order by template_id desc
	</select>
	<!--条件查询-->	
	<select id="query" resultMap="resultMap">
		select * from msend_template  
		<where>
				<if test="modelId != null"> and model_id=#{modelId} </if>				
				<if test="appId != null"> and app_id=#{appId} </if>				
				<if test="templateTitle != null and templateTitle != ''"> and template_title like CONCAT('%',#{templateTitle},'%') </if>				
				<if test="templateMail != null and templateMail != ''"> and template_mail=#{templateMail} </if>				
				<if test="templateSms != null and templateSms != ''"> and template_sms=#{templateSms} </if>				
				<if test="templateCode != null and templateCode != ''"> and template_code=#{templateCode} </if>				
		</where>		
		order by template_id desc
	</select>
	
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy