package com.ruoyi.web.report.service.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.report.domain.meta.ReportColumnMetaVo;
import com.ruoyi.web.report.domain.meta.ReportAssetMetricVo;
import com.ruoyi.web.report.domain.meta.ReportAssetTemplateVo;
import com.ruoyi.web.report.domain.meta.ReportTableMetaVo;
import com.ruoyi.web.report.mapper.ReportMetaMapper;
import com.ruoyi.web.report.service.IReportMetaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 低代码设计器元数据服务实现。
 *
 * <p>当前策略：开放当前库全部表字段，不做白名单收敛。</p>
 */
@Service
public class ReportMetaServiceImpl implements IReportMetaService {

    @Autowired
    private ReportMetaMapper reportMetaMapper;

    @Override
    public List<ReportTableMetaVo> listTables() {
        return reportMetaMapper.selectWhitelistedTables();
    }

    @Override
    public List<ReportColumnMetaVo> listColumns(String tableName) {
        if (StringUtils.isEmpty(tableName)) {
            return Collections.emptyList();
        }
        return reportMetaMapper.selectWhitelistedColumnsByTable(tableName);
    }

    @Override
    public List<ReportAssetTemplateVo> listAssetTemplates() {
        return reportMetaMapper.selectAssetTemplates();
    }

    @Override
    public List<ReportAssetMetricVo> listAssetMetrics() {
        return reportMetaMapper.selectAssetMetrics();
    }
}
