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.OutOrderEntity;
import com.njzscloud.dispose.wh.pojo.param.AddOutOrderParam;
import com.njzscloud.dispose.wh.pojo.param.SearchOutOrderParam;
import com.njzscloud.dispose.wh.pojo.result.SearchOutOrderResult;
import com.njzscloud.dispose.wh.service.OutOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 出库单
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/out_order")
@RequiredArgsConstructor
public class OutOrderController {
    private final OutOrderService outOrderService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddOutOrderParam addOutOrderParam) {
        outOrderService.add(addOutOrderParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OutOrderEntity outOrderEntity) {
        outOrderService.modify(outOrderEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchOutOrderResult>> paging(PageParam pageParam, SearchOutOrderParam searchOutOrderParam) {
        return R.success(outOrderService.paging(pageParam, searchOutOrderParam));
    }
}
