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

import cn.estsh.i3plus.ext.mes.api.base.IMesOrderJobService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesOrderJob;
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
 * @CreateDate: 2021/01/22 16:14
 * @Description:
 **/
@RestController
@Api(tags = "单据作业")
@RequestMapping(CommonConstWords.BASE_URL_MES + "/order-job")
public class OrderJobController extends MesBaseController {
    @Autowired
    private IMesOrderJobService orderJobService;

    /**
     * 按条件分页查找单据作业
     * @param orderJob
     * @param pager
     * @return
     */
    @GetMapping(value = "/mes-order-job/query")
    @ApiOperation(value = "按条件分页查找单据作业")
    public ResultBean queryMesOrderJobByPager(MesOrderJob orderJob, Pager pager) {
        try {
            return ResultBean.success("查询成功").setListPager(orderJobService.queryMesOrderJobByPager(orderJob,pager))
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
