package com.cf.imes.module.executor.api.ordercomponent;

import cn.hutool.core.bean.BeanUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.executor.api.ordercomponent.dto.OrderComponentListReqDTO;
import com.cf.imes.module.executor.api.ordercomponent.dto.OrderComponentListRespDTO;
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
import com.cf.imes.module.executor.service.ordercomponent.OrderComponentService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 *
 * @author Gqr
 * @since 2026/2/25 16:26
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
public class OrderComponentApiImpl implements OrderComponentApi {

    @Resource
    private OrderComponentService orderComponentService;

    @Override
    public CommonResult<List<OrderComponentListRespDTO>> getOrderComponentList(OrderComponentListReqDTO dto) {
        List<OrderComponentRespVO> orderComponentListOnOrders = orderComponentService.getOrderComponentListOnOrders(dto.getOrderIds());
        return CommonResult.success(BeanUtil.copyToList(orderComponentListOnOrders, OrderComponentListRespDTO.class));
    }
}
