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
<?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.data.mapper.ArdServerManagementMapper">
    
    <resultMap type="ArdServerManagement" id="ArdServerManagementResult">
        <result property="id"    column="id"    />
        <result property="serverName"    column="server_name"    />
        <result property="ipAddress"    column="ip_address"    />
        <result property="position"    column="position"    />
        <result property="status"    column="status"    />
        <result property="cpuUsageRate"    column="cpu_usage_rate"    />
        <result property="memoryUsage"    column="memory_usage"    />
        <result property="operatingSystem"    column="operating_system"    />
        <result property="runtime"    column="runtime"    />
    </resultMap>
 
    <sql id="selectArdServerManagementVo">
        select id,
               server_name,
               ip_address,
               position,
               status,
               cpu_usage_rate,
               memory_usage,
               operating_system,
               runtime
        from ard_server_management
    </sql>
 
    <select id="selectArdServerManagementList" parameterType="ArdServerManagement" resultMap="ArdServerManagementResult">
        <include refid="selectArdServerManagementVo"/>
        <where>  
            <if test="serverName != null  and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
            <if test="ipAddress != null  and ipAddress != ''"> and ip_address = #{ipAddress}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="cpuUsageRate != null "> and cpu_usage_rate = #{cpuUsageRate}</if>
            <if test="memoryUsage != null "> and memory_usage = #{memoryUsage}</if>
            <if test="operatingSystem != null  and operatingSystem != ''"> and operating_system = #{operatingSystem}</if>
            <if test="runtime != null "> and runtime = #{runtime}</if>
        </where>
    </select>
    
    <select id="selectArdServerManagementById" parameterType="String" resultMap="ArdServerManagementResult">
        <include refid="selectArdServerManagementVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertArdServerManagement" parameterType="ArdServerManagement">
        insert into ard_server_management
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="serverName != null">server_name,</if>
            <if test="ipAddress != null">ip_address,</if>
            <if test="position != null">position,</if>
            <if test="status != null">status,</if>
            <if test="cpuUsageRate != null">cpu_usage_rate,</if>
            <if test="memoryUsage != null">memory_usage,</if>
            <if test="operatingSystem != null">operating_system,</if>
            <if test="runtime != null">runtime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="serverName != null">#{serverName},</if>
            <if test="ipAddress != null">#{ipAddress},</if>
            <if test="position != null">#{position},</if>
            <if test="status != null">#{status},</if>
            <if test="cpuUsageRate != null">#{cpuUsageRate},</if>
            <if test="memoryUsage != null">#{memoryUsage},</if>
            <if test="operatingSystem != null">#{operatingSystem},</if>
            <if test="runtime != null">#{runtime},</if>
         </trim>
    </insert>
 
    <update id="updateArdServerManagement" parameterType="ArdServerManagement">
        update ard_server_management
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverName != null">server_name = #{serverName},</if>
            <if test="ipAddress != null">ip_address = #{ipAddress},</if>
            <if test="position != null">position = #{position},</if>
            <if test="status != null">status = #{status},</if>
            <if test="cpuUsageRate != null">cpu_usage_rate = #{cpuUsageRate},</if>
            <if test="memoryUsage != null">memory_usage = #{memoryUsage},</if>
            <if test="operatingSystem != null">operating_system = #{operatingSystem},</if>
            <if test="runtime != null">runtime = #{runtime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteArdServerManagementById" parameterType="String">
        delete from ard_server_management where id = #{id}
    </delete>
 
    <delete id="deleteArdServerManagementByIds" parameterType="String">
        delete from ard_server_management where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>