EventMapperAuto.xml 5.35 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.xiniunet.service.railway.dal.EventMapper">

    <resultMap id="eventPO" type="com.xiniunet.service.railway.po.EventPO">
        
        <id column="ID" jdbcType="NUMERIC" property="id"/>
        <result column="TENANT_ID" jdbcType="NUMERIC" property="tenantId"/>
        <result column="USER_ID" jdbcType="NUMERIC" property="userId"/>
        <result column="TYPE" jdbcType="VARCHAR" property="type"/>
        <result column="DESCRIPTION" jdbcType="VARCHAR" property="description"/>
        <result column="DATE_ID" jdbcType="VARCHAR" property="dateId"/>
        <result column="EVENT_TIME" jdbcType="TIMESTAMP" property="eventTime"/>
        <result column="EVENT_LOCATION" jdbcType="VARCHAR" property="eventLocation"/>
        <result column="STATION" jdbcType="VARCHAR" property="station"/>
        <result column="NEXT_STATION" jdbcType="VARCHAR" property="nextStation"/>
        <result column="IS_HANDLED" jdbcType="TINYINT" property="isHandled"/>
        <result column="HANDLE_SUGGESTION" jdbcType="VARCHAR" property="handleSuggestion"/>
        <result column="ROW_VERSION" jdbcType="NUMERIC" property="rowVersion"/>
        <result column="IS_DELETED" jdbcType="TINYINT" property="isDeleted"/>
        <result column="CREATED_BY" jdbcType="NUMERIC" property="createdBy"/>
        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime"/>
        <result column="LAST_UPDATED_BY" jdbcType="NUMERIC" property="lastUpdatedBy"/>
        <result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
    </resultMap>

    <sql id="entityColumnList">
         `ID`, `TENANT_ID`, `USER_ID`, `TYPE`, `DESCRIPTION`, `DATE_ID`, `EVENT_TIME`, `EVENT_LOCATION`, `STATION`, `NEXT_STATION`, `IS_HANDLED`, `HANDLE_SUGGESTION`, `ROW_VERSION`,`IS_DELETED`,`CREATED_BY`,`CREATION_TIME`,`LAST_UPDATED_BY`,`LAST_UPDATE_TIME`
    </sql>

    <insert id="insert">
        INSERT INTO
            `RW_EVENT`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        (
        #{ event.id },
        #{ passport.tenantId },
        #{ event.userId },
        #{ event.type },
        #{ event.description },
        #{ event.dateId },
        #{ event.eventTime },
        #{ event.eventLocation },
        #{ event.station },
        #{ event.nextStation },
        #{ event.isHandled },
        #{ event.handleSuggestion },
        
        0,0,#{ passport.userId },sysdate(),null,null
        )
    </insert>

    <insert id="insertBatch">
        INSERT INTO
            `RW_EVENT`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        <foreach collection="list" item= "event" index ="index" separator=",">
            (
            #{ event.id },
            #{ passport.tenantId },
            #{ event.userId },
            #{ event.type },
            #{ event.description },
            #{ event.dateId },
            #{ event.eventTime },
            #{ event.eventLocation },
            #{ event.station },
            #{ event.nextStation },
            #{ event.isHandled },
            #{ event.handleSuggestion },
            
            0,0,#{ passport.userId },sysdate(),null,null
            )
        </foreach >
    </insert>


    <update id="delete">
        UPDATE
            `RW_EVENT`
        SET
            `IS_DELETED` = 1
            ,`LAST_UPDATED_BY`=#{ passport.userId }
            ,`LAST_UPDATE_TIME`=SYSDATE()
        WHERE
            `IS_DELETED`=0
            AND `TENANT_ID`=#{ passport.tenantId }
            AND `ID` = #{id}
    </update>

    <update id= "deleteBatch">
        UPDATE
            `RW_EVENT`
        SET
            `IS_DELETED` = 1
            ,`LAST_UPDATED_BY`=#{ passport.userId }
            ,`LAST_UPDATE_TIME`=SYSDATE()
        WHERE
            `IS_DELETED`=0
            AND `TENANT_ID`=#{ passport.tenantId }
            AND `ID` in
        <foreach collection="list" item= "id" index ="index" open= "(" close =")" separator=",">
            #{id}
        </foreach >
    </update >


    <select id="getById" resultMap="eventPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_EVENT`
        WHERE
            `IS_DELETED` = 0
            AND `ID` = #{id}
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

    <select id="getListByIds" resultMap="eventPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_EVENT`
        WHERE
        `IS_DELETED` = 0
        AND `ID` in
        <foreach collection="list" item= "id" index ="index" open= "(" close =")" separator=",">
            #{id}
        </foreach >
        
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

    <select id="getAllList" resultMap="eventPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_EVENT`
        WHERE
            `IS_DELETED`=0
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

    <select id="existById"  resultType="java.lang.Long">
        SELECT
            COUNT(*)
        FROM
            `RW_EVENT`
        WHERE
            `IS_DELETED`=0
            AND `ID`=#{id}
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>
</mapper>