ImportMapper.java 2.97 KB
package com.uccc.number.mapper;

import com.uccc.number.domain.ImportPoolProgress;
import com.uccc.number.domain.Number;
import com.uccc.number.domain.NumberImportTask;
import com.uccc.number.domain.PrefixNew;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ImportMapper {
    static final String NUMBER_IMPORT_TASK = "number_import_task";


    @Insert({
            "<script>",
            "insert into " + NUMBER_IMPORT_TASK + " (",
            "import_key,cts,pushed_count,total_count,fail_count,filename,status,type",
            ")",
            "values" + " (",
            "#{import.importKey},now(),#{import.pushedCount},#{import.totalCount},#{import.failCount},#{import.filename},#{import.status}, #{import.type}",
            ")",
            "</script>"
    })
    int insertImportTask(@Param("import") ImportPoolProgress importPoolProgress);


    @Update({
            "<script>",
            "UPDATE " + NUMBER_IMPORT_TASK + " SET uts = now()",
            "<when test='import.pushedCount!=null'>",
            ",pushed_count = #{import.pushedCount}" ,
            "</when>",
            "<when test='import.failCount!=null'>",
            ",fail_count = #{import.failCount}" ,
            "</when>",
            "<when test='import.status!=null'>",
            ",status = #{import.status}" ,
            "</when>",
            "<when test='import.failFile!=null'>",
            ",fail_file = #{import.failFile}" ,
            "</when>",
            "where import_key = #{import.importKey}",
            "</script>"
    })
    void updateImportTask(@Param("import") ImportPoolProgress importPoolProgress);


    @Select({
            "<script>",
            "select * from " + NUMBER_IMPORT_TASK,
            "where import_key = #{importKey}",
            "</script>",
    })
    ImportPoolProgress getNumTaskByKey(@Param("importKey") String importKey);


    @Select({
            "<script>",
            "select count(*) from " + NUMBER_IMPORT_TASK,
            "where status = #{status}",
            "</script>",
    })
    int getTaskByStatus(@Param("status") Integer status);

    @Select({
            "<script>",
            "select * from " + NUMBER_IMPORT_TASK,
            "<when test='status!=null'>",
            "where status = #{status}",
            "</when>",
            "order by cts desc",
            "limit #{limit}",
            "offset #{page}-1",
            "</script>"
    })
    List<ImportPoolProgress> selectNumberImportTasks(@Param("limit") Integer limit, @Param("page") Integer page, @Param("status") Integer status);

    @Select({
            "<script>",
            "select count(*) from " + NUMBER_IMPORT_TASK,
            "<when test='status!=null'>",
            "where status = #{status}",
            "</when>",
            "</script>"
    })
    int selectNumberImportTaskCount(@Param("status") Integer status);


}