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.IntoReturn;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.ivt.InboundQuery;
import com.dk.mdm.model.query.ivt.IntoReturnQuery;
import com.dk.mdm.model.query.pur.PurchaseQuery;
import com.dk.mdm.model.response.ivt.InboundResponse;
import com.dk.mdm.model.response.ivt.IntoReturnResponse;
import com.dk.mdm.model.response.pur.PurchaseResponse;
import com.dk.mdm.model.vo.ivt.IntoReturnVO;
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.IntoReturnService;

import java.util.List;

@Api(tags = "入库退货API接口")
@RestController
@RequestMapping("/ivt/intoReturn")
public class IntoReturnController {

    public BaseService<IntoReturn> getService() {
        return intoReturnService;
    }

    @Autowired
    private IntoReturnService intoReturnService;

    /**
     * @desc : 查询
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation(
            value = "分页、关联、条件查询",
            notes = "分页、关联、条件查询"
    )
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<IntoReturnResponse>> selectByCond(@RequestBody IntoReturnQuery intoReturnQuery) {
        return intoReturnService.selectByCond(intoReturnQuery);
    }

    /**
     * @desc : 新建采购退货
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation(value = "新建", notes = "新建")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody IntoReturnVO intoReturnVO) {
        return intoReturnService.insert(intoReturnVO);
    }


    /**
     * @desc : 作废
     * @date : 2022/6/28 16:58
     * @author : 于继渤
     */
    @ApiOperation(
            value = "作废",
            notes = "作废"
    )
    @PostMapping("cancel")
    public ResponseResultVO<String> cancel(@RequestBody IntoReturnVO intoReturnVO) {
        return intoReturnService.cancel(intoReturnVO);
    }


    /**
     * @desc : 获取单据信息
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation(value = "获取单据信息（编辑用）", notes = "获取单据信息（编辑用）")
    @PostMapping({"select_by_update/{id}"})
    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
        return intoReturnService.selectByUpdate(id);
    }

    /**
     * @desc : 采购退货编辑
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation(value = "编辑", notes = "编辑")
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody IntoReturnVO intoReturnVO) {
        return intoReturnService.update(intoReturnVO);
    }

}
