package com.utic.center.utic.stat.server.dao.repository.dwdb;

import com.utic.center.common.annotation.SqlOperation;
import com.utic.center.utic.stat.server.dao.mapper.dwdb.UticStatPatternMapper;
import com.utic.center.utic.stat.server.dto.HolidayDto;
import com.utic.center.utic.stat.server.dto.PatternDto;
import com.utic.center.utic.stat.server.dto.PatternJobDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class UticStatPatternRepository {

    private final UticStatPatternMapper mapper;

    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "HOLIDAY", param = "past25Min")
    public HolidayDto findHoliday(String patternTime) {
        return this.mapper.findHoliday(patternTime);
    }

    @SqlOperation(type = SqlOperation.SqlType.INSERT, table = "targetTable", param = "fromTable", param2 = "logTable")
    public int insertPatternHist(String targetTable, String fromTable, String patternTime, String logTable) {
        return this.mapper.insertPatternHist(targetTable, fromTable, patternTime);
    }

    @SqlOperation(type = SqlOperation.SqlType.MERGE, table = "targetTable", param = "statTable", param2 = "logTable")
    public int updatePattern(String targetTable, String statTable, String patternTime, String minValue, String maxValue, String logTable) {
        return this.mapper.updatePattern(targetTable, statTable, patternTime, minValue, maxValue);
    }

    @SqlOperation(type = SqlOperation.SqlType.MERGE, table = "targetTable", param = "statTable", param2 = "columnName")
    public int mergePatternWeekJob(String targetTable, String statTable, String columnName, String patternTime, String weekType) {
        return this.mapper.mergePatternWeekJob(targetTable, statTable, columnName, patternTime, weekType);
    }

    @SqlOperation(type = SqlOperation.SqlType.MERGE, table = "targetTable", param = "jobTable", param2 = "patternTime")
    public int mergePatternWeek(String targetTable, String jobTable, String patternTime, String minValue, String maxValue) {
        return this.mapper.mergePatternWeek(targetTable, jobTable, patternTime, minValue, maxValue);
    }

    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "DUAL", param = "PATTERN DAY, WEEK")
    public PatternDto findPatternDay() {
        return this.mapper.findPatternDay();
    }

    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "PATN_JOB_LOG", param = "patternType", param2 = "exeDay")
    public PatternJobDto findPatternJobLog(String patternType, String exeDay) {
        return this.mapper.findPatternJobLog(patternType, exeDay);
    }

    @SqlOperation(type = SqlOperation.SqlType.INSERT, table = "PATN_JOB_LOG", param = "patternType", param2 = "exeDay")
    public int insertPatternJobLog(String patternType, String exeDay) {
        return this.mapper.insertPatternJobLog(patternType, exeDay);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "PATN_JOB_LOG", param = "patternType", param2 = "exeDay")
    public int updatePatternJobLog(String patternType, String exeDay) {
        return this.mapper.updatePatternJobLog(patternType, exeDay);
    }

    @SqlOperation(type = SqlOperation.SqlType.TRUNCATE, table = "tableName")
    public int deletePatternWeekJob(String tableName) {
        return this.mapper.deletePatternWeekJob(tableName);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "tableName", param2 = "patternTime")
    public int updatePatternWeekJob(String tableName, String patternTime) {
        return this.mapper.updatePatternWeekJob(tableName, patternTime);
    }

}
