net.mingsoft.msend.dao.ITemplateDao.xml Maven / Gradle / Ivy
<?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="id" property="id" /><!--编号 --> <result column="model_id" property="modelId" /><!--模块编号 --> <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="id" parameterType="net.mingsoft.msend.entity.TemplateEntity" > insert into msend_template <trim prefix="(" suffix=")" suffixOverrides=","> <if test="modelId != null">model_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="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="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 id = #{id} </update> <!--根据id获取--> <select id="getEntity" resultMap="resultMap" parameterType="int"> select * from msend_template where id=#{id} </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="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 id=#{id} </delete> <!--批量删除--> <delete id="delete" > delete from msend_template <where> 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 id desc </select> <!--条件查询--> <select id="query" resultMap="resultMap"> select * from msend_template <where> <if test="modelId != null"> and model_id=#{modelId} </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 id desc </select> </mapper>