package com.njzscloud.dispose.wh.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.wh.pojo.entity.InOrderEntity;
import com.njzscloud.dispose.wh.pojo.param.AddInOrderParam;
import com.njzscloud.dispose.wh.pojo.param.SearchInOrderParam;
import com.njzscloud.dispose.wh.pojo.result.SearchInOrderResult;
import com.njzscloud.dispose.wh.service.InOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 入库单
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/in_order")
@RequiredArgsConstructor
public class InOrderController {
    private final InOrderService inOrderService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddInOrderParam addInOrderParam) {
        inOrderService.add(addInOrderParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody InOrderEntity inOrderEntity) {
        inOrderService.modify(inOrderEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        inOrderService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<SearchInOrderResult> detail(@RequestParam("id") Long id) {
        return R.success(inOrderService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchInOrderResult>> paging(PageParam pageParam, SearchInOrderParam searchInOrderParam) {
        return R.success(inOrderService.paging(pageParam, searchInOrderParam));
    }
}
