package cn.iocoder.yudao.module.stockOperate.controller.admin;


import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 采购单领料单(DlRepairSo)表控制层
 *
 * @author 小李
 * @date 9:13 2024/9/13
 **/
@RestController
@RequestMapping("/repair/so")
public class DlRepairSoController {
    /**
     * 服务对象
     */
    @Resource
    private DlRepairSoService dlRepairSoService;

    /**
     * 采购单/领料单 新增
     *
     * @param repairSoRespVO 采购单对象
     * @author 小李
     * @date 10:49 2024/9/14
     **/
    @PostMapping("/create")
    @Operation(summary = "采购单/领料单 新增")
    public CommonResult<?> createRepairSo(@RequestBody DlRepairSoRespVO repairSoRespVO) {
        dlRepairSoService.createRepairSo(repairSoRespVO);
        return CommonResult.ok();
    }

    /**
     * 采购单/领料单新增分页
     *
     * @param repairSoReqVO 查询对象
     * @param pageNo 页码
     * @param pageSize 条数
     * @author 小李
     * @date 18:14 2024/9/14
     **/
    @GetMapping("/page")
    @Operation(summary = "采购单/领料单 分页")
    public CommonResult<?> getRepairSoPage(DlRepairSoReqVO repairSoReqVO,
                                           @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
        return success(dlRepairSoService.getRepairSoPage(repairSoReqVO, page));
    }

    /**
     * 采购单/领料单 作废
     *
     * @author 小李
     * @date 11:12 2024/9/18
     * @param repairSoReqVO 作废对象
    **/
    @PostMapping("/void")
    @Operation(summary = "采购单/领料单 作废")
    public CommonResult<?> voidRepairSo(@RequestBody DlRepairSoReqVO repairSoReqVO) {
        dlRepairSoService.voidRepairSo(repairSoReqVO);
        return CommonResult.ok();
    }
}

