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

import cn.estsh.i3plus.ext.mes.api.base.IBomTakeEffectRecordService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesBomTakeEffectRecord;
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.base.controller.MesBaseController;
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;

/**
 * 文件描述
 *
 * @author xiangming.liao
 * @date 2021年05月06日 10:05
 */
@RestController
@Api(tags = "BOM生效记录")
@RequestMapping(CommonConstWords.BASE_URL_MES + "/bom_take_effect_record")
public class BomTakeEffectRecordController extends MesBaseController {

    @Autowired
    private IBomTakeEffectRecordService bomTakeEffectRecordService;

    /**
     * @return cn.estsh.impp.framework.boot.util.ResultBean
     * @Description: 按条件分页查询BOM生效记录
     * @Param [bomTakeEffectRecord, pager]
     * @Date 2021/5/6 10:12
     **/
    @GetMapping(value = "/query")
    @ApiOperation(value = "按条件分页查询BOM生效记录")
    public ResultBean queryBomTakeEffectRecord(MesBomTakeEffectRecord bomTakeEffectRecord, Pager pager) {
        try {
            return ResultBean.success("查询成功").setListPager(bomTakeEffectRecordService.queryByPager(bomTakeEffectRecord, pager))
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);

        }
    }
}