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.PurchaseRecordEntity;
import com.njzscloud.dispose.wh.pojo.result.PurchaseRecordResult;
import com.njzscloud.dispose.wh.service.PurchaseRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 采购记录
 */
@Slf4j
@RestController
@RequestMapping("/purchase_record")
@RequiredArgsConstructor
public class PurchaseRecordController {
    private final PurchaseRecordService purchaseRecordService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody PurchaseRecordEntity purchaseRecordEntity) {
        purchaseRecordService.add(purchaseRecordEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody PurchaseRecordEntity purchaseRecordEntity) {
        purchaseRecordService.modify(purchaseRecordEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<PurchaseRecordResult>> paging(PageParam pageParam, PurchaseRecordEntity purchaseRecordEntity) {
        return R.success(purchaseRecordService.paging(pageParam, purchaseRecordEntity));
    }
}
