package com.caliverse.admin.domain.dao.admin;

import com.caliverse.admin.domain.entity.*;
import com.caliverse.admin.domain.request.DataRequest;
import com.caliverse.admin.domain.request.LandRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


public interface DataMapper {
    @Select("SELECT * FROM data_initialize_schedule WHERE status = 'WAIT'")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "dataType", column = "data_type"),
            @Result(property = "status", column = "status"),
            @Result(property = "deleted", column = "deleted"),
            @Result(property = "createBy", column = "create_by"),
            @Result(property = "createDt", column = "create_dt"),
    })
    List<DataInit> getDataInit();

    @Select("SELECT * FROM data_initialize_schedule WHERE status = 'WAIT' AND id = #{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "dataType", column = "data_type"),
            @Result(property = "status", column = "status"),
            @Result(property = "deleted", column = "deleted"),
            @Result(property = "createBy", column = "create_by"),
            @Result(property = "createDt", column = "create_dt"),
    })
    DataInit getDataInitDetail(@Param("id") long id);

    @Update("UPDATE data_initialize_schedule SET status = #{status} WHERE id = #{id}")
    int updateStatus(@Param("id") long id, @Param("status") String status);

    @Insert("INSERT INTO data_initialize_schedule (data_type, create_by) VALUES (#{request.initDataType}, #{request.createBy})")
    @Options(useGeneratedKeys = true, keyProperty = "request.id", keyColumn = "id")
    int postDataInit(@Param("request") DataRequest request);
}
