package com.hdkj.lt.mq.service.base.impl;

import com.google.common.collect.Lists;
import com.hdkj.lt.feign.ILineSvgFileApiClient;
import com.hdkj.lt.modle.dto.svg.SvgGenerationDTO;
import com.hdkj.lt.modle.dto.svg.SvgObjectDTO;
import com.hdkj.lt.modle.vo.svg.LineFileInfoVO;
import com.hdkj.lt.mq.service.base.ISvgFileInfoService;
import com.hdkj.hussar.ApiResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.hdkj.lt.base.constants.CommonConstant.ONE;

/**
 * @Description
 * @Author wcx
 * @Date 2025/7/2 13:51
 * @Version 1.0
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SvgFileInfoServiceImpl implements ISvgFileInfoService {

    private final ILineSvgFileApiClient lineSvgFileApiClient;

    @Override
    public LineFileInfoVO getSvgGenerationFile(String lineId, Long objId, String type) {
        try {
            // 获取方案对应的文件信息
            SvgGenerationDTO svgGeneration = new SvgGenerationDTO(Lists.newArrayList(lineId), ONE, SvgObjectDTO.builder().objId(objId).objType(type).build());
            ApiResponse<List<LineFileInfoVO>> listApiResponse = lineSvgFileApiClient.lineDynamicSvgSave(svgGeneration);
            return listApiResponse.getData().get(0);
        } catch (Exception ex) {
            log.error("获取方案对应的文件信息失败：{}", ex.getMessage());
            ex.printStackTrace();
            return null;
        }
    }
}
