package com.ruoyi.web.controller.quote;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.quote.domain.CalculateRBParamDto;
import com.ruoyi.quote.domain.MaterialDto;
import com.ruoyi.quote.service.QuoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * @ClassName QuoteController
 * @Description TODO
 * @Author JIAL
 * @Date 2024/3/5 12:57
 * @Version 1.0
 */
@RestController
@RequestMapping("/quote")
@DataSource(DataSourceType.QUOT)
public class QuoteController extends BaseController {

    @Autowired
    QuoteService quoteService;

    @PostMapping("/materialList")
    public TableDataInfo queryMaterialListByParam(@RequestParam("precMaterialName") String precMaterialName,
                                                  @RequestParam("vagueMaterialName") String vagueMaterialName,
                                                  @RequestParam("vagueModel") String vagueModel) {
        startPage();
        logger.info(precMaterialName + vagueMaterialName + vagueModel);
        List<MaterialDto> materialDtos = quoteService.queryMaterialListByParam(precMaterialName,
                vagueMaterialName, vagueModel);

        System.out.println("打通接口");
        return getDataTable(materialDtos);
    }

    @PostMapping("/redBPrice")
    public void queryRedBookPriceByParam(@RequestBody List<CalculateRBParamDto> params) {

        System.out.println(params.get(0).getModel());
        System.out.println(params.get(0).getSpecification());
        System.out.println(params.get(0).getVoltLevel());

    }


}
