SubtaskMapperAuto.xml 4.8 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.task.dal.SubtaskMapper">

    <resultMap  id="subtaskPO" type="com.xiniunet.task.po.SubtaskPO">
        <id column="ID" jdbcType="NUMERIC" property="id" />
        <result column="TENANT_ID"  jdbcType="NUMERIC" property="tenantId"></result>
        <result column="TASK_ID"  jdbcType="NUMERIC" property="taskId"></result>
        <result column="NAME"  jdbcType="VARCHAR" property="name"></result>
        <result column="IS_DONE"  jdbcType="TINYINT" property="isDone"></result>
        <result column="DO_TIME"  jdbcType="TIMESTAMP" property="doTime"></result>
        <result column="DO_USER_ID"  jdbcType="NUMERIC" property="doUserId"></result>
        <result column="DO_USER_NAME"  jdbcType="VARCHAR" property="doUserName"></result>
        <result column="ROW_VERSION"  jdbcType="NUMERIC" property="rowVersion"></result>
        <result column="IS_DELETED"  jdbcType="TINYINT" property="isDeleted"></result>
        <result column="CREATED_BY"  jdbcType="NUMERIC" property="createdBy"></result>
        <result column="CREATION_TIME"  jdbcType="TIMESTAMP" property="creationTime"></result>
        <result column="LAST_UPDATED_BY"  jdbcType="NUMERIC" property="lastUpdatedBy"></result>
        <result column="LAST_UPDATE_TIME"  jdbcType="TIMESTAMP" property="lastUpdateTime"></result>
    </resultMap>

    <sql id="entityColumnList">
    `ID`,`TENANT_ID`,`TASK_ID`,`NAME`,`IS_DONE`,`DO_TIME`,`DO_USER_ID`,`DO_USER_NAME`,`ROW_VERSION`,`IS_DELETED`,`CREATED_BY`,`CREATION_TIME`,`LAST_UPDATED_BY`,`LAST_UPDATE_TIME`
    </sql>

    <insert id="insert">
        INSERT INTO
            `TSK_SUBTASK`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        (
        #{ subtask.id },
         #{ passport.tenantId },
        
        #{ subtask.taskId },
        #{ subtask.name },
        #{ subtask.isDone },
        #{ subtask.doTime },
        #{ subtask.doUserId },
        #{ subtask.doUserName },
        0,0,#{ passport.userId },sysdate(),null,null
        )
    </insert>

    <insert id="insertBatch">
        INSERT INTO
            `TSK_SUBTASK`
            (
            <include refid="entityColumnList" />
            )
        VALUES
        <foreach collection="list" item= "subtask" index ="index" separator=",">
            (
            #{ subtask.id },
            #{ passport.tenantId },
            
            #{ subtask.taskId },
            #{ subtask.name },
            #{ subtask.isDone },
            #{ subtask.doTime },
            #{ subtask.doUserId },
            #{ subtask.doUserName },
            0,0,#{ passport.userId },sysdate(),null,null
            )
        </foreach >
    </insert>


    <update id="delete">
        UPDATE
            `TSK_SUBTASK`
        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
            `TSK_SUBTASK`
        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="subtaskPO">
        SELECT
        <include refid="entityColumnList" />
        FROM
            `TSK_SUBTASK`
        WHERE
            `IS_DELETED` = 0
            AND `ID` = #{id}
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

    <select id="getListByIds" resultMap="subtaskPO">
        SELECT
            <include refid="entityColumnList" />
        FROM
            `TSK_SUBTASK`
        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="subtaskPO">
        SELECT
        <include refid="entityColumnList" />
        FROM
            `TSK_SUBTASK`
        WHERE
            `IS_DELETED`=0
            AND `TENANT_ID`=#{ passport.tenantId }
    </select>

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