package com.dk.mdm.controller.ivt;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.ivt.Transfer;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.ivt.TransferQuery;
import com.dk.mdm.model.response.ivt.TransferResponse;
import com.dk.mdm.model.vo.ivt.CheckVO;
import com.dk.mdm.model.vo.ivt.TransferVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.ivt.TransferService;

@Api(tags = "调整单API接口")
@RestController
@RequestMapping("/ivt/transfer")
public class TransferController{

    public BaseService<Transfer> getService() {
        return transferService;
    }

    @Autowired
    private TransferService transferService;

    /**
     * @desc   : 条件查询
     * @author : 宋扬
     * @date   : 2024/4/2 9:19
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<TransferResponse>> selectByCond(@RequestBody TransferQuery transferQuery) {
        return transferService.selectByCond(transferQuery);
    }

    /**
     * @desc   : 新建调整单
     * @author : 宋扬
     * @date   : 2024/4/3 14:50
     */
    @ApiOperation(value = "新建调整单", notes = "新建调整单")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody TransferVO transferVO) {
        return transferService.insert(transferVO);
    }

    /**
     * @desc   : 作废
     * @author : 宋扬
     * @date   : 2024/4/15 16:27
     */
    @ApiOperation(value = "作废", notes = "作废")
    @PostMapping({"invalid/{id}"})
    public ResponseResultVO<?> invalid(@PathVariable String id) {
        return transferService.invalid(id);
    }

    /**
     * @desc : 通过ID获取库存明细详情
     * @author : 王英杰
     * @date : 2024/3/28 15:34
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return transferService.getTransferForUpdate(id);
    }
}
