package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.base.ep;

import cn.estsh.i3plus.ext.mes.pcn.api.base.ep.IEpBomExtService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-dev
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2021-12-16 14:30
 */
@RestController
@Api(tags = "物料BOM 拓展查询")
@RequestMapping(CommonConstWords.BASE_URL_MES_PCN + "/bom-ext")
public class BomExtController {
    @Autowired
    private IEpBomExtService bomExtService;

    @GetMapping("/query")
    @ApiOperation(value = "条件分页查询物料BOM")
    public ResultBean queryPager(String organizeCode, String partNo, String itemPartNo, String itemPartName, Pager pager) {
        try {
            return ResultBean.success("查询成功").setListPager(bomExtService.getBomListByPartNoAndPager(organizeCode, partNo, itemPartNo, itemPartName, pager))
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
