package com.hotwj.platform.reportStatistics.provider.driver;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
import com.hotwj.platform.driverManagement.driver.service.IHotDriverService;
import com.hotwj.platform.reportStatistics.service.IDriverFilePrintService;
import com.hotwj.platform.reportStatistics.service.IReportDataProvider;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 驾驶员从业资格证复印件数据提供者
 *
 * @author shihongwei
 */
@Component
@RequiredArgsConstructor
public class QualificationCertificateCopyProvider implements IReportDataProvider {

    private final IHotDriverService driverService;

    @Override
    public String getTemplateCode() {
        return "templates/driver/qualificationCertificateCopy.html.vm";
    }

    @Override
    public String getReportType() {
        return IDriverFilePrintService.TYPE_QUALIFICATION_CERTIFICATE_COPY;
    }

    @Override
    public String getReportTitle() {
        return "驾驶员从业资格证复印件";
    }

    @Override
    public Map<String, Object> prepareData(Map<String, Object> params) {
        String driverId = MapUtil.getStr(params, "driverId");
        if (StrUtil.isBlank(driverId)) {
            return MapUtil.empty();
        }

        HotDriverVo driver = driverService.queryById(driverId);
        if (driver == null) {
            return MapUtil.empty();
        }

        Map<String, Object> data = new HashMap<>();
        data.put("driver", driver);
        // Images will be handled by template using $tool.getOssUrls()

        return data;
    }
}
