package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi.jx;

import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxWorkOrderService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.WorkOrderQueryDto;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.base.controller.MesPcnBaseController;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wangjie
 * @CreateDate: 2021/01/19 15:37
 * @Description:
 **/
@Slf4j
@RestController
@RequestMapping(MesPcnExtConstWords.BASE_URL_MES_PCN_JX + "/work-order")
@Api(tags = "JX生成工单控制层")
public class JxWorkOrderController extends MesPcnBaseController {

    @Autowired
    private IJxWorkOrderService workOrderService;

    @GetMapping("/query-by-pager")
    @ApiOperation(value = "分页查询工单接口")
    public ResultBean queryWorkOrderByPager(WorkOrderQueryDto workOrderQueryDto, Pager pager) {
        try {
            return ResultBean.success("查询成功")
                    .setListPager(workOrderService.queryWorkOrderByPager(workOrderQueryDto, pager))
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
