package com.JN.demo.jnzmquatation.controller;

import com.JN.common.R;
import com.JN.demo.jnzmquatation.dto.JnInventoryDto;
import com.JN.demo.jnzmquatation.dto.JnMaterialDto;
import com.JN.demo.jnzmquatation.dto.JnRegionDto;
import com.JN.demo.jnzmquatation.service.JnInventoryService;
import com.JN.demo.jnzmquatation.service.JnMaterialService;
import com.JN.demo.jnzmquatation.service.JnRegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName JNController
 * @Description TODO
 * @Author JIAL
 * @Date 2024/2/19 8:47
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/jnquotation")
public class JNController {
    @Autowired
    JnRegionService regionService;

    @Autowired
    JnMaterialService materialService;

    @Autowired
    JnInventoryService inventoryService;

    /**
     * @title queryRegionList
     * @description 查询地区列表信息
     * @author JIAL
     * @param: regionName
     * @updateTime 2024/2/20 16:54
     * @return: com.JN.common.R<java.util.List<com.JN.demo.zmquotation.dto.RegionDto>>
     */
    @PostMapping("/regionList")
    public R queryRegionList(@RequestParam("regionName") String regionName){

        List<JnRegionDto> regionList = regionService.queryRegionListByName(regionName);

        log.info("查询到的地区列表结果是：{}", regionList);

        return R.success(regionList);
    }

    /**
     * @title queryMaterialList
     * @description 查询物料信息
     * @author JIAL
     * @param: precMaterialName
     * @param: vagueMaterialName
     * @param: vagueModel
     * @updateTime 2024/2/20 16:54
     * @return: com.JN.common.R<java.util.List<com.JN.demo.zmquotation.dto.MaterialDto>>
     */
    @PostMapping("/materialList")
    public R queryMaterialList(@RequestParam("precMaterialName") String precMaterialName,
                               @RequestParam("vagueMaterialName") String vagueMaterialName,
                               @RequestParam("vagueModel") String vagueModel) {
        List<JnMaterialDto> materialList = materialService.queryMaterialListByParam(precMaterialName, vagueMaterialName, vagueModel);

  /*      Map<String, Object> result = new HashMap<>();
        result.put("rows", materialList);
        result.put("total", materialNum);*/

        return R.success(materialList);
    }

    /**
     * @title queryInventoryList
     * @description 获取盘具列表
     * @author JIAL
     * @updateTime 2024/2/22 10:09
     * @return: com.JN.common.R<java.util.List<com.JN.demo.zmquotation.dto.InventoryDto>>
     */
    @PostMapping("/inventoryList")
    public R queryInventoryList() {
        List<JnInventoryDto> inventoryList = inventoryService.queryInventoryList();

        return R.success(inventoryList);
    }


}
