package com.dk.mdm.controller.ivt.inbound;


import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.pojo.ivt.Inbound;
import com.dk.mdm.model.query.ivt.InboundQuery;
import com.dk.mdm.model.response.ivt.InboundResponse;
import com.dk.mdm.model.vo.ivt.InboundVO;
import com.dk.mdm.service.ivt.inbound.InboundPurchaseService;
import com.dk.mdm.service.ivt.inbound.InboundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;


@Api(tags = "采购入库单API接口")
@RestController
@RequestMapping("/ivt/inbound_purchase")
public class InboundPurchaseController {

    public BaseService<Inbound> getService() {
        return inheritedPurchaseService;
    }

    @Autowired
    private InboundPurchaseService inheritedPurchaseService;


    @Autowired
    private InboundService inboundService;




    /**
     * @desc   : 条件查询
     * @date   : 2024/3/7 14:09
     * @author : 寇珊珊
     */
    @ApiOperation(value = "条件查询", notes = "条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody InboundQuery inboundQuery) {
        return inheritedPurchaseService.selectByCond(inboundQuery);
    }

    /**
     * @desc : 查看来源单据,总单加明细  采购入库用
     * @author : 王英杰
     * @date : 2024/3/6 10:36
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return inboundService.selectById(id);
    }


    /**
     * @desc   : 明细信息条件查询
     * @date   : 2024/3/15 9:15
     * @author : 寇珊珊
     */
    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
    @PostMapping({"select_item_info_by_id/{id}"})
    public ResponseResultVO<Map<String, Object>> selectPurchaseInboundItemInfoById(@PathVariable String id) {
        return inheritedPurchaseService.selectPurchaseInboundItemInfoById(id);
    }



    /**
     * @desc   : 采购入库新建
     * @date   : 2024/3/7 14:00
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "采购入库新建",
            notes = "采购入库新建"
    )
    @PostMapping({"inbound_insert"})
    public ResponseResultVO<?> purchaseInboundInsert(@Valid @RequestBody InboundVO inboundVO) {
        return inheritedPurchaseService.purchaseInboundInsert(inboundVO);
    }



    /**
     * @desc   : 采购入库办理
     * @date   : 2024/3/7 15:34
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "采购入库办理",
            notes = "采购入库办理"
    )
    @PostMapping({"inbound_handle"})
    public ResponseResultVO<?> purchaseHandleInbound(@Valid @RequestBody InboundVO inboundVO) {
        return inheritedPurchaseService.purchaseHandleInbound(inboundVO);
    }



    /**
     * @desc   : 采购入库撤销
     * @date   : 2024/3/7 17:06
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "采购入库撤销",
            notes = "采购入库撤销"
    )
    @PostMapping({"inbound_cancel"})
    public ResponseResultVO<?> purchaseInboundCancel(@Valid @RequestBody InboundVO inboundVO) {
        return inheritedPurchaseService.purchaseInboundCancel(inboundVO);
    }

    /**
     * @desc   : 采购入库编辑
     * @date   : 2024/3/26 9:51
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "采购入库编辑",
            notes = "采购入库编辑"
    )
    @PostMapping({"inbound_update"})
    public ResponseResultVO<?> purchaseInboundUpdate(@Valid @RequestBody InboundVO inboundVO) {
        return inheritedPurchaseService.purchaseInboundUpdate(inboundVO);
    }

    /**
     * @desc   : 采购入库作废
     * @date   : 2024/3/26 9:51
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "采购入库作废",
            notes = "采购入库作废"
    )
    @PostMapping({"repeal/{id}"})
    public ResponseResultVO<?> purchaseInboundRepeal(@PathVariable String id) {
        return inheritedPurchaseService.purchaseInboundRepeal(id);
    }

    /**
     * @desc   : 获取单据信息（编辑用）
     * @date   : 2024/3/14 16:37
     * @author : 寇珊珊
     */
    @ApiOperation(value = "获取单据信息（编辑用）", notes = "获取单据信息（编辑用）")
    @PostMapping({"select_by_update/{id}"})
    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
        return inboundService.selectByUpdate(id);
    }

}
