package com.zzsmart.qomo.kn.cost.manage.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsmart.qomo.kn.cost.manage.entity.CostMaterialBom;
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion;
import com.zzsmart.qomo.kn.cost.manage.service.CostMaterialBomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 物料bom 前端控制器
 * </p>
 *
 * @author
 * @since 2024-06-21
 */
@RequestMapping("//cost-material-bom")
@Api(tags="cost-标准成本-bom信息")
@RestController
public class CostMaterialBomController {
    @Autowired
    CostMaterialBomService costMaterialBomService;
    /**
     * 分页列表查询
     *
     * @param costMaterialBom
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "app_scene_cost_standard_version-分页列表查询")
    @ApiOperation(value="物料bom分页列表查询", notes="物料bom分页列表查询")
    @GetMapping(value = "/pageList")
    public Result<IPage<CostMaterialBom>> queryPageList(CostMaterialBom costMaterialBom,
                                                            @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                            @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                                            HttpServletRequest req) {
        QueryWrapper<CostMaterialBom> queryWrapper = QueryGenerator.initQueryWrapper(costMaterialBom, req.getParameterMap());
        Page<CostMaterialBom> page = new Page<CostMaterialBom>(pageNo, pageSize);
        IPage<CostMaterialBom> pageList = costMaterialBomService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     * 列表查询
     *
     * @return
     */
    @ApiOperation(value="物料bom列表查询", notes="物料bom列表查询")
    @GetMapping(value = "/list")
    public Result<  List<CostMaterialBom>> queryList(@RequestParam(name = "materialNumber",required = false) String materialNumber) {
        List<CostMaterialBom> list = costMaterialBomService.queryListResult(materialNumber);
        return Result.OK(list);
    }
}
