OpsStateMapper.xml 3.5 KB
<?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.zhonglai.luhui.serverops.mapper.OpsStateMapper">
    
    <resultMap type="OpsState" id="OpsStateResult">
        <result property="id"    column="id"    />
        <result property="host_id"    column="host_id"    />
        <result property="create_time"    column="create_time"    />
        <result property="cpu"    column="cpu"    />
        <result property="mem"    column="mem"    />
        <result property="sessionNumber"    column="sessionNumber"    />
        <result property="disk"    column="disk"    />
    </resultMap>

    <sql id="selectOpsStateVo">
        select `id`, `host_id`, `create_time`, `cpu`, `mem`, `sessionNumber`, `disk` from ops_state
    </sql>

    <select id="selectOpsStateList" parameterType="OpsState" resultMap="OpsStateResult">
        <include refid="selectOpsStateVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="host_id != null "> and host_id = #{host_id}</if>
            <if test="params.beginCreate_time != null and params.beginCreate_time != '' and params.endCreate_time != null and params.endCreate_time != ''"> and create_time between #{params.beginCreate_time} and #{params.endCreate_time}</if>
            <if test="sessionNumber != null "> and sessionNumber = #{sessionNumber}</if>
        </where>
    </select>
    
    <select id="selectOpsStateById" parameterType="Integer" resultMap="OpsStateResult">
        <include refid="selectOpsStateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOpsState" parameterType="OpsState" useGeneratedKeys="true" keyProperty="id">
        insert into ops_state
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="host_id != null">host_id,</if>
            <if test="create_time != null">create_time,</if>
            <if test="cpu != null">cpu,</if>
            <if test="mem != null">mem,</if>
            <if test="sessionNumber != null">sessionNumber,</if>
            <if test="disk != null">disk,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="host_id != null">#{host_id},</if>
            <if test="create_time != null">#{create_time},</if>
            <if test="cpu != null">#{cpu},</if>
            <if test="mem != null">#{mem},</if>
            <if test="sessionNumber != null">#{sessionNumber},</if>
            <if test="disk != null">#{disk},</if>
         </trim>
    </insert>

    <update id="updateOpsState" parameterType="OpsState">
        update ops_state
        <trim prefix="SET" suffixOverrides=",">
            <if test="host_id != null">host_id = #{host_id},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="cpu != null">cpu = #{cpu},</if>
            <if test="mem != null">mem = #{mem},</if>
            <if test="sessionNumber != null">sessionNumber = #{sessionNumber},</if>
            <if test="disk != null">disk = #{disk},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOpsStateById" parameterType="Integer">
        delete from ops_state where id = #{id}
    </delete>

    <delete id="deleteOpsStateByIds" parameterType="String">
        delete from ops_state where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>