CourseOneMapper.xml 4.4 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="org.yrhl.syncdata.mapper.local.CourseOneMapper">

    <select id="getList" resultType="org.yrhl.syncdata.domain.BusinessDataResultsEntity">
        select * from business_data_results where create_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
    </select>


    <select id="getBlockSourceDataEntityList" resultType="org.yrhl.syncdata.domain.BlockSourceDataEntity">
        select * from block_source_data where create_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
    </select>

    <select id="getBlockNewSourceDataEntityList" resultType="org.yrhl.syncdata.domain.BlockNewSourceDataEntity">
        select * from block_new_source_data ;
    </select>

    <select id="getAllinonepushresultsEntityList" resultType="org.yrhl.syncdata.domain.AllinonepushresultsEntity">
        select * from allinonepushresults where CreateTime BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
    </select>

    <select id="getSyncTableList" resultType="org.yrhl.syncdata.domain.SyncTable">
        select TableName from sync_table where isDelete=0 ;
    </select>

    <select id="getSyncResultListForWaitForAllinonepushresults" resultType="org.yrhl.syncdata.domain.SyncResult" parameterType="string">
        SELECT
            #{tableName} as TableName  ,a.Id as InfoId ,a.CreateTime AS DateCreateTime,0 AS STATUS,now() AS CreateDateTime,now() AS UpdateTime
        FROM   ${tableName} a
        WHERE
            a.CreateTime >( SELECT IF ( max( datecreatetime ) IS NULL, '2024-09-01 00:00:00', max( datecreatetime )) FROM sync_result sr WHERE sr.TableName = #{tableName} )
        ORDER BY
            a.CreateTime
            LIMIT #{page},
            #{size}
    </select>



    <select id="isExist" resultType="int" parameterType="long">
        SELECT count(1) from sync_result  where  InfoId=#{infoId}
    </select>

    <select id="getSyncResultListForWait" resultType="org.yrhl.syncdata.domain.SyncResult" parameterType="string">
        SELECT
            #{tableName} as TableName  ,a.Id as InfoId ,a.create_date AS DateCreateTime,0 AS STATUS,now() AS CreateDateTime,now() AS UpdateTime
        FROM   ${tableName} a
        WHERE
            a.create_date >( SELECT IF ( max( datecreatetime ) IS NULL, '2024-01-01 00:00:00', max( datecreatetime )) FROM sync_result sr WHERE sr.TableName = #{tableName} )
        ORDER BY
            a.create_date
            LIMIT   #{page},
            #{size}
    </select>

    <insert id="insertSyncResult">
        INSERT INTO sync_result (
        Id,
        TableName,
        InfoId,
        DateCreateTime,
        Status,
        CreateDateTime,
        UpdateTime
        )
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id},
            #{item.TableName},
            #{item.InfoId},
            #{item.DateCreateTime},
            0,
            #{item.CreateDateTime},
            #{item.UpdateTime}
            )
        </foreach>
    </insert>


    <update id="updateSyncResult" parameterType="long" >
        UPDATE sync_result
        SET Status =1
        WHERE InfoId = #{infoId}
    </update>


    <update id="updateSyncResultFail" parameterType="long" >
        UPDATE sync_result
        SET Status =-1
        WHERE InfoId = #{infoId}
    </update>



    <select id="getSyncTableList" resultType="org.yrhl.syncdata.domain.SyncTable">
        select * from sync_table where isDelete=0 ;
    </select>

    <select id="getSyncResultListForWaitForConsumer" resultType="org.yrhl.syncdata.domain.AllinonepushresultsEntity" parameterType="string">
        select * from ${tableName} a where a.Id in(select InfoId  from sync_result where TableName =#{tableName} and Status !=1) order by a.CreateTime asc limit #{page},#{size}
    </select>

    <select id="getSyncResultListForWaitForOtherConsumer" resultType="map" parameterType="string">
        select * from ${tableName} a where a.Id in(select InfoId  from sync_result where TableName =#{tableName} and Status !=1) order by a.create_date asc limit #{page},#{size}
    </select>


    <select id="isExesit" resultType="int" parameterType="long">
        select count(1) from sync_result where InfoId=#{infoId}
    </select>

</mapper>