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
<?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.ard.work.mapper.ArdServerInfoMapper">
    
    <resultMap type="ArdServerInfo" id="ArdServerInfoResult">
        <result property="id"    column="id"    />
        <result property="serverName"    column="server_name"    />
        <result property="host"    column="host"    />
        <result property="tcpPort"    column="tcp_port"    />
        <result property="httpPort"    column="http_port"    />
        <result property="accessKeyId"    column="access_key_id"    />
        <result property="accessKeySecret"    column="access_key_secret"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="altitude"    column="altitude"    />
        <result property="userId"    column="user_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="serverStatus"    column="server_status"    />
    </resultMap>
 
    <sql id="selectArdServerInfoVoNo">
        select id,
               server_name,
               host,
               tcp_port,
               http_port,
               access_key_id,
               access_key_secret,
               longitude,
               latitude,
               altitude,
               user_id,
               dept_id,
               server_status
        from ard_server_info
    </sql>
 
    <sql id="selectArdServerInfoVo">
        select c.id,
               c.server_name,
               c.host,
               c.tcp_port,
               c.http_port,
               c.access_key_id,
               c.access_key_secret,
               c.longitude,
               c.latitude,
               c.altitude,
               c.user_id,
               c.dept_id,
               c.server_status
        from ard_server_info c
                 left join sys_dept d on d.dept_id = c.dept_id
                 left join sys_user u on u.user_id = c.user_id
    </sql>
 
    <select id="selectArdServerInfoList" parameterType="ArdServerInfo" resultMap="ArdServerInfoResult">
        <include refid="selectArdServerInfoVo"/>
        <where>
            <if test="id != null and id != ''"> and c.id = #{id}</if>
            <if test="serverName != null and serverName != ''"> and c.server_name like concat('%', #{serverName}, '%')</if>
            <if test="accessKeyId != null and accessKeyId != ''"> and c.access_key_id = #{accessKeyId}</if>
            <if test="accessKeySecret != null and accessKeySecret != ''"> and c.access_key_secret = #{accessKeySecret}</if>
            <if test="serverStatus != null and serverStatus != ''"> and c.server_status = #{serverStatus}</if>
            <if test="deptId != null and deptId != 0">
                AND (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
            </if>
            <!-- 数据范围过滤 -->
            ${params.dataScope}
        </where>
    </select>
 
    <select id="getServerLsNoPermission" parameterType="ArdServerInfo" resultMap="ArdServerInfoResult">
        <include refid="selectArdServerInfoVoNo"/>
        <where>
            <if test="id != null and id != ''"> and id = #{id}</if>
            <if test="serverName != null and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
            <if test="accessKeyId != null and accessKeyId != ''"> and access_key_id = #{accessKeyId}</if>
            <if test="accessKeySecret != null and accessKeySecret != ''"> and access_key_secret = #{accessKeySecret}</if>
            <if test="serverStatus != null and serverStatus != ''"> and server_status = #{serverStatus}</if>
            <if test="deptId != null and deptId != 0">and dept_id = #{deptId}</if>
        </where>
    </select>
    
    <select id="selectArdServerInfoById" parameterType="String" resultMap="ArdServerInfoResult">
        <include refid="selectArdServerInfoVo"/>
        where c.id = #{id}
    </select>
 
    <insert id="insertArdServerInfo" parameterType="ArdServerInfo">
        insert into ard_server_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="serverName != null">server_name,</if>
            <if test="host != null">host,</if>
            <if test="tcpPort != null">tcp_port,</if>
            <if test="httpPort != null">http_port,</if>
            <if test="accessKeyId != null">access_key_id,</if>
            <if test="accessKeySecret != null">access_key_secret,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="altitude != null">altitude,</if>
            <if test="userId != null">user_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="serverStatus != null">server_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="serverName != null">#{serverName},</if>
            <if test="host != null">#{host},</if>
            <if test="tcpPort != null">#{tcpPort},</if>
            <if test="httpPort != null">#{httpPort},</if>
            <if test="accessKeyId != null">#{accessKeyId},</if>
            <if test="accessKeySecret != null">#{accessKeySecret},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="altitude != null">#{altitude},</if>
            <if test="userId != null">#{userId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="serverStatus != null">#{serverStatus},</if>
         </trim>
    </insert>
 
    <update id="updateArdServerInfo" parameterType="ArdServerInfo">
        update ard_server_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverName != null">server_name = #{serverName},</if>
            <if test="host != null">host = #{host},</if>
            <if test="tcpPort != null">tcp_port = #{tcpPort},</if>
            <if test="httpPort != null">http_port = #{httpPort},</if>
            <if test="accessKeyId != null">access_key_id = #{accessKeyId},</if>
            <if test="accessKeySecret != null">access_key_secret = #{accessKeySecret},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="altitude != null">altitude = #{altitude},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="serverStatus != null">server_status = #{serverStatus},</if>
        </trim>
        where id = #{id}
    </update>
 
    <update id="updateServerStatus">
        update ard_server_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">server_status = #{status},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteArdServerInfoById" parameterType="String">
        delete from ard_server_info where id = #{id}
    </delete>
 
    <delete id="deleteArdServerInfoByIds" parameterType="String">
        delete from ard_server_info where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>