package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.domain.Warehouse;
import com.tuoheng.admin.entity.request.warehouse.QueryWarehouseListRequest;
import com.tuoheng.admin.entity.request.warehouse.QueryWarehousePageListRequest;
import com.tuoheng.admin.service.warehouse.IWarehouseService;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc: 仓库 前端控制器
 * @team: tuoheng
 * @author: wanjing
 * @date: 2023-02-06
 */
@RestController
@RequestMapping("/warehouse")
public class WarehouseController {

    @Autowired
    private IWarehouseService warehouseService;

    /**
     * 查询仓库列表
     */
    @GetMapping("/list")
    public JsonResult getlist(QueryWarehouseListRequest request) {
        return warehouseService.getList(request);
    }

    /**
     * 查询仓库分页列表
     */
    @GetMapping("/page/list")
    public JsonResult getPagelist(QueryWarehousePageListRequest request) {
        return warehouseService.getPageList(request);
    }

    /**
     * 获取仓库详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getOneById(@PathVariable("id") Integer id) {
        return warehouseService.getOneById(id);
    }

    /**
     * 添加仓库
     *
     * @param entity 实体对象
     * @return
     */
    @PostMapping("/add")
    public JsonResult add(@RequestBody Warehouse entity) {
        return warehouseService.editInfo(entity);
    }

    /**
     * 编辑仓库
     *
     * @param entity 实体对象
     * @return
     */
    @PutMapping("/edit")
    public JsonResult edit(@RequestBody Warehouse entity) {
        return warehouseService.editInfo(entity);
    }

    /**
     * 删除仓库
     *
     * @param ids 摄像头ID
     * @return
     */
    @DeleteMapping("/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return warehouseService.deleteByIds(ids);
    }

}
