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.WarehouseEntity;
import com.njzscloud.dispose.wh.pojo.param.AddWarehouseParam;
import com.njzscloud.dispose.wh.service.WarehouseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 仓库信息
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/warehouse")
@RequiredArgsConstructor
public class WarehouseController {
    private final WarehouseService warehouseService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddWarehouseParam addWarehouseParam) {
        warehouseService.add(addWarehouseParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody WarehouseEntity warehouseEntity) {
        warehouseService.modify(warehouseEntity);
        return R.success();
    }

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

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

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