package com.njcn.csharmonic.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.service.ICsSysExcelRelationService;
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
import com.njcn.harmonic.common.service.ISysExcelRelationService;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xy
 * @since 2026-01-27
 */
@Service
@RequiredArgsConstructor
@DS("sjzx")
public class CsSysExcelRelationServiceImpl extends ServiceImpl<SysExcelRelationMapper, SysExcelRelation> implements ICsSysExcelRelationService {

    private final ISysExcelRelationService sysExcelRelationService;
    private final ExcelRptTempMapper excelRptTempMapper;

    @Override
    public List<ReportTemplateVO> queryList(String id) {
        List<ReportTemplateVO> result = new ArrayList<>();
        SysExcelRelationVO sysExcelRelationVO = sysExcelRelationService.getRelation(id);
        if (CollectionUtil.isNotEmpty(sysExcelRelationVO.getRelationIds())) {
            result = excelRptTempMapper.getReportTemplateByIds(sysExcelRelationVO.getRelationIds());
        }
        return result;
    }

    @Override
    public Boolean bandRelation(ExcelParam.ListExcelParam param) {
        return sysExcelRelationService.bandRelation(param);
    }
}
