package com.salpa.subject.mapper;

import com.salpa.subject.domain.MonitorDatabaseDocument;
import com.salpa.subject.domain.MonitorProjectSyncTask;
import com.salpa.subject.domain.MonitorTableDocument;
import com.salpa.subject.domain.data.DatabaseDocumentResponse;
import com.salpa.subject.domain.data.TableDocumentResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface DocumentMapper {

    int createSyncTask(MonitorProjectSyncTask projectSyncTask);

    List<Map<String ,Object>> getVersionsByProjectId(Integer projectId);

    Long getMaxVersion(Integer projectId);

    MonitorDatabaseDocument getSimpleByProjectId(@Param("projectId") Integer projectId, @Param("version") Long version);

    List<MonitorTableDocument> getTableDocument(@Param("id") Integer id, @Param("search") String search);

    List<Map<String, Object>> getTableDocumentById(@Param("projectId") Integer id,  @Param("search")String search);

    Map<String, Object> getTable(Integer id);

    List<MonitorProjectSyncTask> getSyncTaskList(@Param("list") Integer[] taskIds);

    int updateStatusAndResultById(Integer taskId);

    List<MonitorTableDocument> getTableByIds(@Param("list") Integer[] tableIds);

    DatabaseDocumentResponse getByProjectId(@Param("projectId")Integer projectId, @Param("version") Long version);

    List<TableDocumentResponse> getTableDetails(Integer databaseDocumentId);

    Optional<MonitorDatabaseDocument> selectNotArchivedByProjectId(Integer projectId);

    void updateIsArchiveById(@Param("id") Integer id, @Param("archive") boolean archive);

    Integer addDatabaseDocument(MonitorDatabaseDocument dbDocPojo);

    Integer insertTableDocumentAndReturnId(MonitorTableDocument tableMeta);

    MonitorTableDocument getTableById(Integer id);

    void updateSyncTask(int syncTask);

    String selectStatusById(Integer taskId);

    Long getDocumentVersionById(Integer docId);

    void deleteDocumentById(Integer docId);

    void updateIsArchive(@Param("projectId") Integer projectId, @Param("version") Long version);

    String getSyncTaskStatus(Integer taskId);

    Integer uniqueDocumentByProjectId(Integer projectId);
}
