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

import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxManualReportTravelService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesManualReportTravel;
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.auth.AuthUtil;
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 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-jx
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2023-10-27 10:14
 */
@RestController
@Api(tags = "手动报工 控制层")
@RequestMapping(CommonConstWords.BASE_URL_MES + "/manual-report-travel")
public class JxManualReportTravelController {

    @Autowired
    private IJxManualReportTravelService manualReportTravelService;

    @GetMapping(value = "/query-pager")
    public ResultBean queryManualReportTravelByPager(MesManualReportTravel manualReportTravel, Pager pager) {

        try {
            manualReportTravel.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
            return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setListPager(manualReportTravelService.queryManualReportTravelByPager(manualReportTravel, pager));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

}
