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

import com.utic.center.common.annotation.SqlOperation;
import com.utic.center.utic.traf.server.dao.mapper.dwdb.DwdbTableManagerMapper;
import com.utic.center.utic.traf.server.dto.TableExistDto;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class DwdbTableManagerRepository {

    private final DwdbTableManagerMapper mapper;

    @SqlOperation(type = SqlOperation.SqlType.SELECT, table = "USER_TABLES", param = "tableName")
    public TableExistDto findTableExist(@Param("tableName") String tableName) {
        return this.mapper.findTableExist(tableName);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "TABLE COMMENT", param = "tableName", param2 = "tableComment")
    public int addTableComment(String tableName, String tableComment) {
        return this.mapper.addTableComment(tableName, tableComment);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "COLUMN COMMENT", param = "tableName", param2 = "columnName")
    public int addColumnComment(String tableName, String columnName, String columnComment) {
        return this.mapper.addColumnComment(tableName, columnName, columnComment);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "TRAFFIC_CENTER_", param = "crtMonth", param2 = "create table")
    public int createTrafficCenterHistTable(String crtMonth) {
        return this.mapper.createTrafficCenterHistTable(crtMonth);
    }

    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "TRAFFIC_CENTER_", param = "crtMonth", param2 = "add constraints")
    public int addTrafficCenterHistPrimaryKey(String crtMonth) {
        return this.mapper.addTrafficCenterHistPrimaryKey(crtMonth);
    }

}
