package com.shkj.wms.controller.base;

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wms.domain.WcsDevice;
import com.shkj.wms.service.IBasePointService;
import com.shkj.wms.service.IWcsDeviceService;
import com.shkj.wms.vo.BaseDeviceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备管理Controller
 *
 * @author zjx
 * @date 2023-04-20
 */
@RestController
@RequestMapping("/wcs/device/")
public class WcsDeviceController extends BaseController
{

    @Autowired
    private IWcsDeviceService iWcsDeviceService;

    /**
     * 查询设备管理列表
     */
    @GetMapping("/list")
    public TableDataInfo<WcsDevice> list(WcsDevice wcsDevice)
    {
        startPage();
        List<WcsDevice> list = iWcsDeviceService.selectWcsDeviceList(wcsDevice);
        return getDataTable(list);

    }


    /**
     * 获取设备管理详细信息
     */
    @GetMapping("/getWcsDeviceByid")
    public Result<WcsDevice> getInfo(@RequestParam("id") Long id){
        return Result.ok().data(iWcsDeviceService.selectWcsDeviceById(id));
    }

    /**
     * 获取设备管理
     */
    @GetMapping("/getWcsDeviceInfo")
    public Result<WcsDevice> getWcsDeviceInfo(WcsDevice wcsDevice){
        return Result.ok().data(iWcsDeviceService.selectWcsDeviceList(wcsDevice));
    }

    /**
     * 获取设备管理
     */
    @GetMapping("/gettAllDeviceList")
    public Result<BaseDeviceVo> gettAllDeviceList(WcsDevice wcsDevice){
        return Result.ok().data(iWcsDeviceService.selectAllDeviceList(wcsDevice));
    }



    /**
     * 新增设备管理
     */
    @Log(title = "设备管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody WcsDevice wcsDevice) {
        return iWcsDeviceService.insertWcsDevice(wcsDevice);
    }

    /**
     * 修改设备管理
     */
    @Log(title = "设备管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@RequestBody WcsDevice wcsDevice){
        return iWcsDeviceService.updateWcsDevice(wcsDevice);
    }

    /**
     * 删除设备管理
     */
    @Log(title = "设备管理", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public Result<Boolean> remove(@RequestParam Long id){
        return iWcsDeviceService.deleteWcsDeviceById(id);
    }





}
