SafetyEscortMapperAuto.xml 5.01 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.SafetyEscortMapper">

    <resultMap id="safetyEscortPO" type="com.xiniunet.service.railway.po.SafetyEscortPO">
        
        <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="IS_LAID" jdbcType="TINYINT" property="isLaid"/>
        <result column="AUTO_LAID" jdbcType="TINYINT" property="autoLaid"/>
        <result column="LAID_ON_ID" jdbcType="NUMERIC" property="laidOnId"/>
        <result column="LAID_OFF_ID" jdbcType="NUMERIC" property="laidOffId"/>
        <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`, `IS_LAID`, `AUTO_LAID`, `LAID_ON_ID`, `LAID_OFF_ID`, `ROW_VERSION`,`IS_DELETED`,`CREATED_BY`,`CREATION_TIME`,`LAST_UPDATED_BY`,`LAST_UPDATE_TIME`
    </sql>

    <insert id="insert">
        INSERT INTO
            `RW_SAFETY_ESCORT`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        (
        #{ safetyEscort.id },
        #{ passport.tenantId },
        #{ safetyEscort.userId },
        #{ safetyEscort.isLaid },
        #{ safetyEscort.autoLaid },
        #{ safetyEscort.laidOnId },
        #{ safetyEscort.laidOffId },
        
        0,0,#{ passport.userId },sysdate(),null,null
        )
    </insert>

    <insert id="insertBatch">
        INSERT INTO
            `RW_SAFETY_ESCORT`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        <foreach collection="list" item= "safetyEscort" index ="index" separator=",">
            (
            #{ safetyEscort.id },
            #{ passport.tenantId },
            #{ safetyEscort.userId },
            #{ safetyEscort.isLaid },
            #{ safetyEscort.autoLaid },
            #{ safetyEscort.laidOnId },
            #{ safetyEscort.laidOffId },
            
            0,0,#{ passport.userId },sysdate(),null,null
            )
        </foreach >
    </insert>


    <update id="delete">
        UPDATE
            `RW_SAFETY_ESCORT`
        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_SAFETY_ESCORT`
        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="safetyEscortPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_SAFETY_ESCORT`
        WHERE
            `IS_DELETED` = 0
            AND `ID` = #{id}
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>
    <select id="getByUserId" resultMap="safetyEscortPO">
        SELECT
        <include refid="entityColumnList" />
        FROM
        `RW_SAFETY_ESCORT`
        WHERE
        `IS_DELETED` = 0
        AND `USER_ID` = #{id}
        AND `TENANT_ID`=#{ passport.tenantId }
    </select>
    <select id="getListByIds" resultMap="safetyEscortPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_SAFETY_ESCORT`
        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="safetyEscortPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `RW_SAFETY_ESCORT`
        WHERE
            `IS_DELETED`=0
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

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