AdminMsgTemplateMapper.xml 4.75 KB
Newer Older
ilal committed
1 2 3 4 5 6 7 8
<?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="cn.timer.api.dao.admin.AdminMsgTemplateMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.admin.AdminMsgTemplate" >
                <id column="id" property="id" />
                <result column="template_name" property="templateName" />
mobh committed
9
                <result column="platform_num" property="platformNum" />
ilal committed
10 11 12 13 14
                <result column="platform_type" property="platformType" />
                <result column="content" property="content" />
                <result column="msg_type" property="msgType" />
                <result column="state" property="state" />
                <result column="addtime" property="addtime" />
mobh committed
15
                <result column="sys_default" property="sysDefault" />
ilal committed
16 17 18 19 20 21
                <result column="org_code" property="orgCode" />
    </resultMap>

    <sql id="Base_Column_List">
                id,
                template_name,
mobh committed
22
                platform_num,
ilal committed
23 24 25 26 27
                platform_type,
                content,
                msg_type,
                state,
                addtime,
mobh committed
28
                sys_default,
ilal committed
29 30
                org_code
    </sql>
mobh committed
31

mobh committed
32
    <select id="getByParams" resultMap="BaseResultMap">
mobh committed
33 34 35
        SELECT <include refid="Base_Column_List" />
        FROM admin_msg_template temp
        <where>
mobh committed
36 37
            <if test="param.templateName != null and param.templateName !=''">
                and temp.template_name like CONCAT('%',#{param.templateName},'%')
mobh committed
38
            </if>
mobh committed
39 40 41
            <if test="param.platformNum != null">
                and temp.platform_num = #{param.platformNum}
            </if>
mobh committed
42
            <if test="param.platformType != null">
mobh committed
43
                and temp.platform_type = #{param.platformType}
mobh committed
44
            </if>
mobh committed
45 46
            <if test="param.msgType != null">
                and temp.msg_type = #{param.msgType}
mobh committed
47
            </if>
mobh committed
48 49
            <if test="param.state != null">
                and temp.state = #{param.state}
mobh committed
50
            </if>
mobh committed
51 52 53
            <if test="param.sysDefault != null">
                and temp.sys_default = #{param.sysDefault}
            </if>
mobh committed
54 55
            <if test="param.orgCode != null">
                and temp.org_code = #{param.orgCode}
mobh committed
56 57 58
            </if>
        </where>
    </select>
mobh committed
59

mobh committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    <!-- 列出企业可选择的消息模板 -->
    <sql id="listMsgTemplateCondition">
            <if test="param.templateName != null and param.templateName !=''">
                and temp.template_name like CONCAT('%',#{param.templateName},'%')
            </if>
            <if test="param.platformType != null">
                and temp.platform_type = #{param.platformType}
            </if>
            <if test="param.msgType != null">
                and temp.msg_type = #{param.msgType}
            </if>
            <if test="param.state != null">
                and temp.state = #{param.state}
            </if>
    </sql>
    <select id="listMsgTemplate" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM admin_msg_template temp
        WHERE temp.sys_default = 0
        <include refid="listMsgTemplateCondition" />
        UNION ALL
        SELECT <include refid="Base_Column_List" />
        FROM admin_msg_template temp
        WHERE temp.sys_default = 1 AND temp.org_code = #{param.orgCode}
        <include refid="listMsgTemplateCondition" />
    </select>

mobh committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    <!-- 分页查询 -->
    <sql id="pageMsgTemplateCondition">
        <where>
            <if test="param.templateName != null and param.templateName !=''">
                and temp.template_name like CONCAT('%',#{param.templateName},'%')
            </if>
            <if test="param.platformType != null">
                and temp.platform_type = #{param.platformType}
            </if>
            <if test="param.msgType != null">
                and temp.msg_type = #{param.msgType}
            </if>
            <if test="param.state != null">
                and temp.state = #{param.state}
            </if>
mobh committed
102 103 104
            <if test="param.sysDefault != null">
                and temp.sys_default = #{param.sysDefault}
            </if>
mobh committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
            <if test="param.orgCode != null">
                and temp.org_code = #{param.orgCode}
            </if>
        </where>
    </sql>
    <select id="pageMsgTemplateCount" resultType="java.lang.Long">
        SELECT count(*) FROM admin_msg_template temp
        <include refid="pageMsgTemplateCondition" />
    </select>
    <select id="pageMsgTemplate" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM admin_msg_template temp
        <include refid="pageMsgTemplateCondition" />
        LIMIT #{param.offset}, #{param.totalPage}
    </select>
ilal committed
120
</mapper>