<?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.xhpc.mapper.XhpcDeviceMessageMapper">

    <resultMap type="com.xhpc.pp.domain.XhpcDeviceMessage" id="XhpcDeviceMessageResult">
        <id property="deviceMessageId" column="device_message_id"/>
        <result property="type" column="type"/>
        <result property="serialNumber" column="serial_number"/>
        <result property="content" column="content"/>
        <result property="chargeOrderNo" column="charge_order_no"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <insert id="insertByDomain" parameterType="com.xhpc.pp.domain.XhpcDeviceMessage">
        insert into xhpc_device_message(

        <if test="type != null">type,</if>
        <if test="serialNumber != null and serialNumber != 0">serial_number,</if>
        <if test="content != null and content != ''">content,</if>
        <if test="chargeOrderNo != null and chargeOrderNo != ''">charge_order_no,</if>
        <if test="status != null and status != ''">status,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="updateBy != null and updateBy != ''">update_by,</if>
        create_time,
        update_time
        )values(
        <if test="type != null">#{type},</if>
        <if test="serialNumber != null and serialNumber != 0">#{serialNumber},</if>
        <if test="content != null and content != ''">#{content},</if>
        <if test="chargeOrderNo != null and chargeOrderNo != ''">#{chargeOrderNo},</if>
        <if test="status != null and status != ''">#{status},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
        sysdate(),
        sysdate()
        )
    </insert>

    <delete id="deleteByLastThreeMonth">
        delete from xhpc_message
        where create_time <![CDATA[ <= ]]> #{expireDate};
    </delete>
</mapper>
