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

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultUtil;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.ivt.InboundItem;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.ivt.InboundItemQuery;
import com.dk.mdm.model.response.ivt.InboundItemResponse;
import com.dk.mdm.model.vo.ivt.InboundItemVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import com.dk.mdm.service.ivt.inbound.InboundItemService;

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

@Api(tags = "入库明细API接口")
@RestController
@RequestMapping("/ivt/inboundItem")
public class InboundItemController{

    public BaseService<InboundItem> getService() {
        return inboundItemService;
    }

    @Autowired
    private InboundItemService inboundItemService;
    
    /**
     * @desc   : 条件查询
     * @author : 常皓宁
     * @date   : 2024/3/13 14:35
     */
    @ApiOperation(
            value = "分页、关联、条件查询",
            notes = "分页、关联、条件查询"
    )
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<InboundItemResponse>> selectByCond(@RequestBody InboundItemQuery inboundItemQuery) {
        return inboundItemService.selectByCond(inboundItemQuery);
    }


    /**
     * @desc : 新建入库单明细
     * @author : 王英杰
     * @date : 2024/3/6 10:36
     */
    @ApiOperation(value = "新建出库单", notes = "新建出库单")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody InboundItemVO inboundItemVO) {
        return inboundItemService.insert(inboundItemVO);
    }



    /**
     * @desc   : 条件查询(入库成本核对用)
     * @author : 常皓宁
     * @date   : 2024/3/13 14:35
     */
    @ApiOperation(
            value = "分页、关联、条件查询",
            notes = "分页、关联、条件查询"
    )
    @PostMapping({"select_cost_check"})
    public ResponseResultVO<PageList<InboundItemResponse>> selectCostCheck(@RequestBody InboundItemQuery inboundItemQuery) {
        return inboundItemService.selectCostCheck(inboundItemQuery);
    }

    /**
     * @desc   : 入库成本核对
     * @author : 常皓宁
     * @date   : 2024/4/17 15:24
     */
    @ApiOperation(
            value = "入库成本核对",
            notes = "入库成本核对"
    )
    @PostMapping({"cost_check_ok"})
    public ResponseResultVO<?> CostCheckOk(@Valid @RequestBody List<InboundItemQuery> inboundItemQuery) {
        return inboundItemService.CostCheckOk(inboundItemQuery);
    }
}
