package com.xdap.self_development.common;

import com.definesys.mpaas.query.MpaasQuery;
import com.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.common.constant.DatasourceConstant;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class BusinessDatabase {
    @Resource
    private MpaasQueryFactory queryFactory;

    @Value("${apaas.single.tenantId}")
    private String tenantId;

    @Bean
    public MpaasQuery getBusinessDatabase() {
        return queryFactory.buildFromDatasource("qygs");
    }

    @Bean
    public MpaasQuery getSystemDatabase() {
        return queryFactory.buildFromDatasource(DatasourceConstant.XDAP_MYSQL_PREFIX + tenantId);
    }

    @Bean
    public MpaasQuery getTCDatabase() {
        return queryFactory.buildFromDatasource("yc_lrs_test_relsult");
    }
}
