package com.utic.center.utic.traf.server.dao.repository.utic;

import com.utic.center.common.annotation.SqlOperation;
import com.utic.center.utic.traf.server.dao.mapper.utic.UticTrafficMapper;
import com.utic.center.utic.traf.server.dto.LinkTrafCenterDto;
import com.utic.center.utic.traf.server.dto.TrafPrcsTimeDto;
import com.utic.center.utic.traf.server.dto.ViewTextDto;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class UticTrafficRepository {

    private final UticTrafficMapper mapper;

//    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "NEXT_MONTH(DUAL)")
    public ViewTextDto findNextMonth() {
        return this.mapper.findNextMonth();
    }
    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "USER_VIEWS")
    public ViewTextDto findTrafficCenterViewDdl() {
        return this.mapper.findTrafficCenterViewDdl();
    }

    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "TRAF_PRCS_TIME")
    public TrafPrcsTimeDto findOneTrafPrcsTime() {
        return this.mapper.findOneTrafPrcsTime();
    }

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

    @SqlOperation(type = SqlOperation.SqlType.INSERT, table = "CENTER_RECEIVE")
    public int insertCenterRecv(String centerId, String infoType, Integer seq, Integer dataCnt) {
        return this.mapper.insertCenterRecv(centerId, infoType, seq, dataCnt);
    }

    @SqlOperation(type = SqlOperation.SqlType.TRUNCATE, table = "TRAFFIC_CENTER", param = "tableName")
    public int truncateTrafficCenter(String tableName) {
        return this.mapper.truncateTrafficCenter(tableName);
    }
    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "disableIndexes", param = "tableName", param2 = "index")
    public int disableIndexes(@Param("tableName") String tableName, String index) {
        return this.mapper.disableIndexes(tableName, index);
    }
    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "disablePrimaryKey", param = "tableName")
    public int disablePrimaryKey(@Param("tableName") String tableName) {
        return this.mapper.disablePrimaryKey(tableName);
    }
    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "rebuildIndexes", param = "tableName", param2 = "index")
    public int rebuildIndexes(@Param("tableName") String tableName, String index) {
        return this.mapper.rebuildIndexes(tableName, index);
    }
    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "enablePrimaryKey", param = "tableName")
    public int enablePrimaryKey(@Param("tableName") String tableName) {
        return this.mapper.enablePrimaryKey(tableName);
    }

    @SqlOperation(type = SqlOperation.SqlType.INSERT, table = "TRAFFIC_CENTER", param = "tableName")
    public int insertTrafficCenter(String tableName, @Param("obj") LinkTrafCenterDto obj) {
        return this.mapper.insertTrafficCenter(tableName, obj);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "swapTrafficCenterView", param = "currTable", param2 = "nextTable")
    public int swapTrafficCenterView(String currTable, String nextTable) {
        return this.mapper.swapTrafficCenterView(nextTable);
    }

}
