package cn.com.poc.thirdparty.resource.demand.ai.aggregate.impl;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

import cn.com.poc.thirdparty.resource.demand.ai.aggregate.MD2WordService;
import cn.com.poc.thirdparty.resource.demand.ai.entity.md2word.Md2WordResponse;
import cn.com.poc.thirdparty.resource.demand.ai.entity.md2word.Md2WordResult;
import cn.com.poc.thirdparty.resource.demand.ai.route.DgtoolsApiRoute;
import cn.com.poc.thirdparty.resource.demand.dgTools.DgtoolsAbstractHttpClient;
import cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService;
import org.apache.http.Header;
import org.apache.http.message.BasicHeader;
import org.springframework.stereotype.Service;

/**
 * @author alex.yao
 * @date 2025/7/28
 */
@Service
public class Md2WordServiceImpl implements MD2WordService {

    @Resource
    private DgtoolsAbstractHttpClient dgToolsAbstractHttpClient;

    @Resource
    private DemandAuthService demandAuthService;

    @Override
    public Md2WordResult md2Word(Md2WordResponse response) {
        String url = DgtoolsApiRoute.DgtoolsAI.MD_2_WORD_FILE;
        List<Header> headers = new ArrayList<Header>() {{
            add(DgtoolsApiRoute.JSON_HEADER);
            add(DgtoolsApiRoute.AI_HEADER);
            add(new BasicHeader(DgtoolsApiRoute.HEADER_X_PLATFORM_AUTHORIZATION, demandAuthService.getToken()));
        }};
        return dgToolsAbstractHttpClient.doRequest(url, response, headers);
    }
}
