HisToryRecordMapper.xml 9.75 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.genersoft.iot.vmp.vmanager.jt1078.platform.mapper.HisToryRecordMapper">

    <resultMap id="HISTORY_RECORD_LIST_MAP" type="com.genersoft.iot.vmp.vmanager.jt1078.platform.domain.HistoryRecord">
        <result property="id" column="id" />
        <result property="name" column="name" />
        <result property="sim" column="sim" />
        <result property="channel" column="channel" />
        <result property="startTime" column="start_time" />
        <result property="endTime" column="end_time" />
        <result property="status" column="status" />
        <result property="ip" column="ip" />
        <result property="port" column="port" />
        <result property="username" column="username" />
        <result property="password" column="password" />
        <result property="path" column="path" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="createBy" column="create_by" />
        <result property="updateBy" column="update_by" />
        <result property="remark" column="remark" />
    </resultMap>

    <sql id="HISTORY_RECORD_LIST_SQL">
        SELECT
            id,
            name,
            sim,
            channel,
            start_time,
            end_time,
            status,
            ip,
            port,
            username,
            password,
            path,
            create_time,
            update_time,
            create_by,
            update_by,
            remark
        FROM `wvp_history_record`
    </sql>

    <insert id="addOrUpdRecode">
        INSERT INTO `wvp_history_record`
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test=" id != null         and  id != ''         ">`id`               ,</if>
                <if test=" name != null       and  name != ''       ">`name`             ,</if>
                <if test=" sim != null        and  sim != ''        ">`sim`              ,</if>
                <if test=" channel != null    and  channel != ''    ">`channel`          ,</if>
                <if test=" startTime != null  and  startTime != ''  ">`start_time`       ,</if>
                <if test=" endTime != null    and  endTime != ''    ">`end_time`         ,</if>
                <if test=" status != null     and  status != ''     ">`status`           ,</if>
                <if test=" ip != null         and  ip != ''         ">`ip`               ,</if>
                <if test=" port != null                             ">`port`             ,</if>
                <if test=" username != null   and  username != ''   ">`username`         ,</if>
                <if test=" password != null   and  password != ''   ">`password`         ,</if>
                <if test=" path != null       and  path != ''       ">`path`             ,</if>
                <if test=" createTime != null                       ">`create_time`      ,</if>
                <if test=" updateTime != null                       ">`update_time`      ,</if>
                <if test=" createBy != null   and  createBy != ''   ">`create_by`        ,</if>
                <if test=" updateBy != null   and  updateBy != ''   ">`update_by`        ,</if>
                <if test=" remark != null     and  remark != ''     ">`remark`           ,</if>
            </trim>
            VALUES
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test=" id != null         and id != ''         ">   #{id},            </if>
                <if test=" name != null       and name != ''       ">   #{name},          </if>
                <if test=" sim != null        and sim != ''        ">   #{sim},           </if>
                <if test=" channel != null    and channel != ''    ">   #{channel},       </if>
                <if test=" startTime != null  and startTime != ''  ">   #{startTime},     </if>
                <if test=" endTime != null    and endTime != ''    ">   #{endTime},       </if>
                <if test=" status != null     and status != ''     ">   #{status},        </if>
                <if test=" ip != null         and ip != ''         ">   #{ip},            </if>
                <if test=" port != null                            ">   #{port},          </if>
                <if test=" username != null   and username != ''   ">   #{username},      </if>
                <if test=" password != null   and password != ''   ">   #{password},      </if>
                <if test=" path != null       and path != ''       ">   #{path},          </if>
                <if test=" createTime != null                      ">   #{createTime} ,   </if>
                <if test=" updateTime != null                      ">   #{updateTime},    </if>
                <if test=" createBy != null   and createBy != ''   ">   #{createBy},      </if>
                <if test=" updateBy != null   and updateBy != ''   ">   #{updateBy},      </if>
                <if test=" remark != null     and remark != ''     ">   #{remark},        </if>
            </trim>
            ON DUPLICATE KEY UPDATE
            <trim suffixOverrides=",">
                <if test=" id != null         and  id != ''         "> `id`            = #{id},            </if>
                <if test=" name != null       and  name != ''       "> `name`          = #{name},          </if>
                <if test=" sim != null        and  sim != ''        "> `sim`           = #{sim},           </if>
                <if test=" channel != null    and  channel != ''    "> `channel`       = #{channel},       </if>
                <if test=" startTime != null  and  startTime != ''  "> `start_time`    = #{startTime},     </if>
                <if test=" endTime != null    and  endTime != ''    "> `end_time`      = #{endTime},       </if>
                <if test=" status != null     and  status != ''     "> `status`        = #{status},        </if>
                <if test=" ip != null         and  ip != ''         "> `ip`            = #{ip},            </if>
                <if test=" port != null                             "> `port`          = #{port},          </if>
                <if test=" username != null   and  username != ''   "> `username`      = #{username},      </if>
                <if test=" password != null   and  password != ''   "> `password`      = #{password},      </if>
                <if test=" path != null       and  path != ''       "> `path`          = #{path},          </if>
                <if test=" createTime != null                       "> `create_time`   = #{createTime} ,   </if>
                <if test=" updateTime != null                       "> `update_time`   = #{updateTime},    </if>
                <if test=" createBy != null   and  createBy != ''   "> `create_by`     = #{createBy},      </if>
                <if test=" updateBy != null   and  updateBy != ''   "> `update_by`     = #{updateBy},      </if>
                <if test=" remark != null     and  remark != ''     "> `remark`        = #{remark},        </if>
            </trim>
    </insert>

    <update id="beachUpdRecode">
        <foreach collection="list" item="item" separator=";">
            UPDATE `wvp_history_record`
            <set>
            <if test="item.sim != null        and item.sim != ''        ">`sim`           = #{item.sim},           </if>
            <if test="item.channel != null    and item.channel != ''    ">`channel`       = #{item.channel},       </if>
            <if test="item.startTime != null  and item.startTime != ''  ">`start_time`    = #{item.startTime},     </if>
            <if test="item.endTime != null    and item.endTime != ''    ">`end_time`      = #{item.endTime},       </if>
            <if test="item.status != null     and item.status != ''     ">`status`        = #{item.status},        </if>
            <if test="item.ip != null         and item.ip != ''         ">`ip`            = #{item.ip},            </if>
            <if test="item.port != null                                 ">`port`          = #{item.port},          </if>
            <if test="item.username != null   and item.username != ''   ">`username`      = #{item.username},      </if>
            <if test="item.password != null   and item.password != ''   ">`password`      = #{item.password},      </if>
            <if test="item.path != null       and item.path != ''       ">`path`          = #{item.path},          </if>
            <if test="item.path == null                                 ">`path`          = NULL,                  </if>
            <if test="item.createTime != null                           ">`create_time`   = #{item.createTime} ,   </if>
            <if test="item.updateTime != null                           ">`update_time`   = #{item.updateTime},    </if>
            <if test="item.createBy != null   and item.createBy != ''   ">`create_by`     = #{item.createBy},      </if>
            <if test="item.updateBy != null   and item.updateBy != ''   ">`update_by`     = #{item.updateBy},      </if>
            <if test="item.remark != null     and item.remark != ''     ">`remark`        = #{item.remark},        </if>
            </set>
            WHERE
            `name` = #{item.name}
        </foreach>
    </update>
    <update id="updateStatusByName">
        update `wvp_history_record` set `status` = #{status} where name = #{name}
    </update>

    <select id="getHistoryRecordList"
            resultMap="HISTORY_RECORD_LIST_MAP">
        <include refid="HISTORY_RECORD_LIST_SQL" />
    </select>

    <select id="getHistoryRecord"
            resultMap="HISTORY_RECORD_LIST_MAP">
        <include refid="HISTORY_RECORD_LIST_SQL" />
        WHERE `name` = #{stream}
    </select>
</mapper>