mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?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.OrganizationChartMapper">
 
    <resultMap type="com.dg.core.db.gen.entity.OrganizationChartEntity" id="OrganizationChartResult">
        <id     property="id"      column="id"      />
        <id     property="organizationName"      column="organization_name"      />
        <id     property="city"      column="city"      />
        <id     property="district"      column="district"      />
        <id     property="village"      column="village"      />
        <id     property="detailedAddress"      column="detailed_address"      />
        <id     property="createTime"      column="create_time"      />
        <id     property="updateTime"      column="update_time"      />
        <id     property="parentId"      column="parent_id"      />
        <id     property="grade"      column="grade"      />
        <id     property="resume"      column="resume"      />
        <id     property="contactNumber"      column="contact_number"      />
        <id     property="departmentalApplication"      column="departmental_application"      />
        <id     property="updateUserId"      column="update_user_id"      />
        <id     property="areaList"      column="area_list"      />
 
    </resultMap>
 
    <sql id="selectOrganizationChartVo">
        SELECT
            id,
            resume,
            organization_name,
            contact_number,
            departmental_application,
            create_time,
            update_time,
            parent_id,
            update_user_id,
            (select  user_name from automessage_sys_user where user_id=automessage_organization_chart.update_user_id) as updateUserName,
            (select organization_name from automessage_organization_chart as oc where oc.id=automessage_organization_chart.parent_id) as parentName,
            city,
            district,
            village,
            (select name from automessage_area_code_2022 where city=automessage_area_code_2022.code) as cityName,
            (select name from automessage_area_code_2022 where district=automessage_area_code_2022.code) as districtName,
            (select name from automessage_area_code_2022 where village=automessage_area_code_2022.code) as villageName,
            detailed_address,
            grade,
            area_list
        FROM
            automessage_organization_chart
    </sql>
 
    <select id="selectConfigById" resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        where id= #{id}
    </select>
 
    <select id="queryList"  resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        <where>
            <if test="organizationName != null and organizationName != ''">
                AND organization_name like concat('%', #{organizationName}, '%')
            </if>
            <if test="ids != null">
                and id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="countList" resultType="integer">
        select count(id) from automessage_organization_chart
        <where>
            <if test="organizationName != null and organizationName != ''">
                AND organization_name like concat('%', #{organizationName}, '%')
            </if>
            <if test="ids != null">
                and id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="selectConfigList"  resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        <where>
            <if test="parentId != null and parentId != ''">
                AND parent_id=#{parentId}
            </if>
            <if test="grade != null and grade != ''">
                AND grade=#{grade}
            </if>
            <if test="ids != null">
                and id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="selectByKeyWord" resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        where grade=1 and ( organization_name like concat('%', #{keyWord}, '%')
        or((detailed_address like concat('%', #{keyWord}, '%')  )     and TRIM(detailed_address)  !='')
        or((resume like concat('%', #{keyWord}, '%')  ) and  TRIM(resume)  !=  '' ))
    </select>
 
    <select id="selectByCode" resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        <where>
           ( id=#{id} or parent_id=#{id})   and  (city=#{areaCode} or district= #{areaCode} or village=#{areaCode}) and grade=#{grade}
        </where>
      order by grade
    </select>
 
    <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.OrganizationChartEntity">
        insert into automessage_organization_chart (
        <if test="id != null">id,</if>
        <if test="organizationName != null and organizationName != '' ">organization_name,</if>
        <if test="parentId != null">parent_id,</if>
        <if test="city != null and city != '' ">city,</if>
        <if test="district != null and district != '' ">district,</if>
        <if test="village != null and village != '' ">village,</if>
        <if test="detailedAddress != null and detailedAddress != '' ">detailed_address,</if>
        <if test="grade != null and grade != '' ">grade,</if>
        <if test="areaList != null and areaList != '' ">area_list,</if>
        <if test="contactNumber != null and contactNumber != '' ">contact_number,</if>
        <if test="departmentalApplication != null and departmentalApplication != '' ">departmental_application,</if>
        <if test="updateUserId != null and updateUserId != '' ">update_user_id,</if>
        <if test="resume != null and resume != '' ">resume,</if>
        update_time,
        create_time
        )values(
        <if test="id != null">#{id},</if>
        <if test="organizationName != null and organizationName != '' ">#{organizationName},</if>
        <if test="parentId != null">#{parentId},</if>
        <if test="city != null and city != '' ">#{city},</if>
        <if test="district != null and district != '' ">#{district},</if>
        <if test="village != null and village != '' ">#{village},</if>
        <if test="detailedAddress != null and detailedAddress != '' ">#{detailedAddress},</if>
        <if test="grade != null and grade != '' ">#{grade},</if>
        <if test="areaList != null and areaList != '' ">#{areaList},</if>
        <if test="contactNumber != null and contactNumber != '' ">#{contactNumber},</if>
        <if test="departmentalApplication != null and departmentalApplication != '' ">#{departmentalApplication},</if>
        <if test="updateUserId != null and updateUserId != '' ">#{updateUserId},</if>
        <if test="resume != null and resume != '' ">#{resume},</if>
        sysdate(),
        sysdate()
        )
    </insert>
 
    <update id="updateConfig" parameterType="com.dg.core.db.gen.entity.OrganizationChartEntity">
        update automessage_organization_chart
        <set>
            <if test="id != null">id=#{id},</if>
            <if test="organizationName != null and organizationName != '' ">organization_name=#{organizationName},</if>
            <if test="parentId != null">parent_id=#{parentId},</if>
            <if test="city != null and city != '' ">city=#{city},</if>
            <if test="district != null and district != '' ">district=#{district},</if>
            <if test="village != null and village != '' ">village=#{village},</if>
            <if test="detailedAddress != null and detailedAddress != '' ">detailed_address=#{detailedAddress},</if>
            <if test="grade != null and grade != '' ">grade=#{grade},</if>
            <if test="departmentalApplication != null and departmentalApplication != '' ">departmental_application=#{departmentalApplication},</if>
            <if test="updateUserId != null">update_user_id=#{updateUserId},</if>
            <if test="areaList != null and areaList != '' ">area_list=#{areaList},</if>
            <if test="contactNumber != null and contactNumber != '' ">contact_number=#{contactNumber},</if>
            <if test="departmentalApplication != null  ">departmental_application=#{departmentalApplication},</if>
            <if test="updateUserId != null and updateUserId != '' ">update_user_id=#{updateUserId},</if>
            <if test="resume != null and resume != '' ">resume=#{resume},</if>
            update_time=sysdate()
        </set>
        where  id= #{id}
    </update>
 
    <delete id="deleteConfigById" parameterType="string">
        delete from automessage_organization_chart where id= #{Id}
    </delete>
 
    <select id="countNum" resultType="integer">
        select count(id) from automessage_organization_chart
    </select>
 
</mapper>