mitao
2025-03-13 86df207c37502cce1b2043e1c7c0486459eef1d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
87
88
89
<?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.dg.core.db.gen.mapper.AutomessagePolicyDocumentsMapper">
    <resultMap type="com.dg.core.db.gen.entity.AutomessagePolicyDocuments" id="AutomessagePolicyDocumentsResult">
        <id     property="id"      column="id"      />
        <id     property="departmentId"      column="department_id"      />
        <id     property="name"      column="name"      />
        <id     property="linkType"      column="link_type"      />
        <id     property="articleLink"      column="article_link"      />
        <id     property="richText"      column="rich_text"      />
        <id     property="type"      column="type"      />
        <id     property="createTime"      column="create_time"      />
        <id     property="createUserId"      column="create_user_id"      />
        <id     property="updateTime"      column="update_time"      />
        <id     property="updateUserId"      column="update_user_id"      />
    </resultMap>
 
    <sql id="selectAutomessagePolicyDocumentsResult">
        SELECT
            id,
            (select organization_name from  automessage_organization_chart where id=a.department_id )departmentName,
            department_id,
            name,
            link_type,
            type,
            article_link,
            rich_text,
            create_time,
            update_time,
            (select user_name from automessage_sys_user where user_id=a.update_user_id)updateUserName,
            update_user_id,
            (select user_name from automessage_sys_user where user_id=a.create_user_id)createUserName,
            create_user_id
        FROM
            automessage_policy_documents a
    </sql>
 
    <select id="selectConfigList" resultMap="AutomessagePolicyDocumentsResult">
        <include refid="selectAutomessagePolicyDocumentsResult" />
        <where>
            <if test="name!=null and name!=''">
                and name  like concat('%', #{name}, '%')
            </if>
            <if test="type!=null">
                and type = #{type}
            </if>
            <if test="departmentId != null">
                 and department_id  in  (SELECT id from automessage_organization_chart where id=#{departmentId} or parent_id = #{departmentId})
            </if>
            <if test="ids != null">
                and department_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>
 
    <select id="selectCountList" resultType="integer">
      select count(*) from automessage_policy_documents
      <where>
            <if test="name!=null and name!=''">
                and name  like concat('%', #{name}, '%')
            </if>
            <if test="type!=null">
                and type = #{type}
            </if>
          <if test="departmentId != null">
              and department_id  in  (SELECT id from automessage_organization_chart where id=#{departmentId} or parent_id = #{departmentId})
          </if>
          <if test="ids != null">
              and department_id IN
              <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                  #{param}
              </foreach>
          </if>
        </where>
    </select>
 
    <select id="selectAutomessagePolicyDocumentById" resultMap="AutomessagePolicyDocumentsResult">
        <include refid="selectAutomessagePolicyDocumentsResult" />
        <where>
            id = #{id}
        </where>
 
    </select>
 
</mapper>