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.PurchaseOrderEntity;
import com.njzscloud.dispose.wh.service.PurchaseOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 采购单
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/purchase_order")
@RequiredArgsConstructor
public class PurchaseOrderController {
    private final PurchaseOrderService purchaseOrderService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody PurchaseOrderEntity entity) {
        purchaseOrderService.add(entity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody PurchaseOrderEntity purchaseOrderEntity) {
        purchaseOrderService.modify(purchaseOrderEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<PurchaseOrderEntity>> paging(PageParam pageParam, PurchaseOrderEntity orderEntity) {
        return R.success(purchaseOrderService.paging(pageParam, orderEntity));
    }
}
