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.WarehouseCheckPlanEntity;
import com.njzscloud.dispose.wh.pojo.param.AddWarehouseCheckPlanParam;
import com.njzscloud.dispose.wh.pojo.param.SearchWarehouseCheckPlanParam;
import com.njzscloud.dispose.wh.pojo.result.SearchWarehouseCheckPlanResult;
import com.njzscloud.dispose.wh.service.WarehouseCheckPlanService;
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_plan")
@RequiredArgsConstructor
public class WarehouseCheckPlanController {
    private final WarehouseCheckPlanService warehouseCheckPlanService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddWarehouseCheckPlanParam addWarehouseCheckPlanParam) {
        warehouseCheckPlanService.add(addWarehouseCheckPlanParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody WarehouseCheckPlanEntity warehouseCheckPlanEntity) {
        warehouseCheckPlanService.modify(warehouseCheckPlanEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchWarehouseCheckPlanResult>> paging(PageParam pageParam, SearchWarehouseCheckPlanParam searchWarehouseCheckPlanParam) {
        return R.success(warehouseCheckPlanService.paging(pageParam, searchWarehouseCheckPlanParam));
    }
}
