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.InventoryEntity;
import com.njzscloud.dispose.wh.pojo.param.AddInventoryParam;
import com.njzscloud.dispose.wh.pojo.param.SearchInventoryParam;
import com.njzscloud.dispose.wh.pojo.result.SearchInventoryResult;
import com.njzscloud.dispose.wh.service.InventoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 库存信息
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/inventory")
@RequiredArgsConstructor
public class InventoryController {
    private final InventoryService inventoryService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddInventoryParam addInventoryParam) {
        inventoryService.add(addInventoryParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody InventoryEntity inventoryEntity) {
        inventoryService.modify(inventoryEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchInventoryResult>> paging(PageParam pageParam, SearchInventoryParam param) {
        return R.success(inventoryService.paging(pageParam, param));
    }
}
