fengjin
2022-09-28 a3fde7c78f3d8c98fbd6ce42a97e1d510317b0b4
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
<?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"      />
 
 
    </resultMap>
 
    <sql id="selectOrganizationChartVo">
        SELECT
            id,
            resume,
            organization_name,
            contact_number,
            departmental_application,
            create_time,
            update_time,
            parent_id,
            (select organization_name from automessage_organization_chart as oc where oc.id=automessage_organization_chart.parent_id) as parentName,
            city,
            district,
            village,
            detailed_address,
            grade,
            resume,contact_number
        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="parentId != null and parentId != ''">
                AND parent_id=#{parentId}
            </if>
 
            <if test="grade != null and grade != ''">
                AND grade=#{grade}
            </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>
        </where>
    </select>
 
    <select id="selectByKeyWord" resultMap="OrganizationChartResult">
        <include refid="selectOrganizationChartVo"/>
        where organization_name like concat('%', #{keyWord}, '%') or #{keyWord} like concat('%', organization_name, '%')
        or detailed_address like concat('%', #{keyWord}, '%') or #{keyWord} like concat('%', detailed_address, '%')
        or resume like concat('%', #{keyWord}, '%') or #{keyWord} like concat('%', resume, '%')
    </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>
        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>
        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>
            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>