package com.jay.monitor.data.server.store.mysql;

import com.jay.monitor.data.core.enums.MsgTypeEnums;
import com.jay.monitor.data.core.model.serializable.SQLMonitorDTO;
import com.jay.monitor.data.server.daos.JayMonitorSqlMapperExt;
import com.jay.monitor.data.server.daos.PartitionOperation;
import com.jay.monitor.data.server.enums.StoreType;
import com.jay.monitor.data.server.models.entity.JayMonitorSql;
import com.jay.monitor.data.server.store.BigTextStoreProcess;
import com.jay.monitor.data.server.utils.JayDataUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * @Module 数据存储器
 * @Description Mysql的SQL存储实现
 * @Author liukaixiong
 * @Date 2020/10/29 13:36
 */
public class MysqlSQLStoreProcess extends BigTextStoreProcess<SQLMonitorDTO, JayMonitorSql> {

    private Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 队列的大小
     */
    public int defaultSize = 5000;

    @Autowired
    @Qualifier("jayMonitorSqlMapperExt")
    private JayMonitorSqlMapperExt sqlMapper;

    @Override
    public StoreType storeType() {
        return StoreType.MYSQL;
    }

    @Override
    public MsgTypeEnums msgTypeEnums() {
        return MsgTypeEnums.SQL;
    }

    @Override
    public String tableName() {
        return "jay_monitor_sql";
    }

    @Override
    protected PartitionOperation<JayMonitorSql> getMapper() {
        return sqlMapper;
    }

    @Override
    protected JayMonitorSql builderJayMonitor(SQLMonitorDTO request) {
        return JayDataUtils.builderJayMonitorSql(request);
    }

}
