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.WarehouseCheckDetailEntity;
import com.njzscloud.dispose.wh.pojo.param.AddWarehouseCheckDetailParam;
import com.njzscloud.dispose.wh.pojo.param.SearchWarehouseCheckDetailParam;
import com.njzscloud.dispose.wh.pojo.result.SearchWarehouseCheckDetailResult;
import com.njzscloud.dispose.wh.service.WarehouseCheckDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 库存盘点明细
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/warehouse_check_detail")
@RequiredArgsConstructor
public class WarehouseCheckDetailController {
    private final WarehouseCheckDetailService warehouseCheckDetailService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddWarehouseCheckDetailParam addWarehouseCheckDetailParam) {
        warehouseCheckDetailService.add(addWarehouseCheckDetailParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody WarehouseCheckDetailEntity warehouseCheckDetailEntity) {
        warehouseCheckDetailService.modify(warehouseCheckDetailEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchWarehouseCheckDetailResult>> paging(PageParam pageParam, SearchWarehouseCheckDetailParam searchWarehouseCheckDetailParam) {
        return R.success(warehouseCheckDetailService.paging(pageParam, searchWarehouseCheckDetailParam));
    }
}
