package org.springblade.modules.app.web.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.controller.BaseController;
import com.wn.common.datamodel.ResultDTO;
import org.springblade.modules.app.common.dto.WaybillDTO;
import org.springblade.modules.app.common.query.AdminWaybillQuery;
import org.springblade.modules.app.common.vo.ApprovalVO;
import org.springblade.modules.app.manager.WaybillManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AdminUserController
 * @Description:
 * @author: fxs
 * @createTime: 2021-11-22-16:11
 */
@RestController
@RequestMapping("app/admin/waybill")
@Api(value = "调运单管理-管理端", tags = "调运单管理-管理端")
public class AdminWaybillController extends BaseController {

    @Autowired
    private WaybillManager waybillManager;

    //@ApiOperation(value = "分页查询调运单")
    @GetMapping("/page")
    public ResponseEntity<ResultDTO<Page<WaybillDTO>>> pageWaybill(AdminWaybillQuery waybillQuery) {
        return success(waybillManager.pageWaybill(waybillQuery));
    }

    //@ApiOperation(value = "查询调运单详情", notes = "查询调运单详情")
    @GetMapping("/{id}")
    public ResponseEntity<ResultDTO<WaybillDTO>> getWaybillDetail(@PathVariable Long id) {
        return success(waybillManager.getAdminWaybillDetail(id));
    }

    //@ApiOperation(value = "审批调运单", notes = "审批调运单")
    @PutMapping("approval")
    public ResponseEntity<ResultDTO<Boolean>> approvalWayBill(@RequestBody ApprovalVO approvalVO) {
        return success(waybillManager.approvalWaybillByBureau(approvalVO));
    }
}
