package com.tuoheng.admin.controller;

import com.tuoheng.admin.request.iotequipment.AddIotEquipmentRequest;
import com.tuoheng.admin.request.iotequipment.EditIotEquipmentRequest;
import com.tuoheng.admin.request.iotequipment.QueryIotEquipmentListRequest;
import com.tuoheng.admin.request.iotequipment.QueryIotEquipmentPageListRequest;
import com.tuoheng.admin.service.iotequipment.IotEquipmentService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 物联设备前端控制器
 *
 * @Author wanjing
 * @Date 2023-11-25
 */
@RestController
@RequestMapping("/iot/equipment")
@RequiredArgsConstructor
public class IotEquipmentController {

    private final IotEquipmentService iotEquipmentService;

    /**
     * 查询物联设备分页列表
     */
    @GetMapping("/page/list")
    public JsonResult getPageList(QueryIotEquipmentPageListRequest request) {
        return iotEquipmentService.getPageList(request);
    }

    /**
     * 查询物联设备列表
     */
    @GetMapping("/list")
    public JsonResult getList(QueryIotEquipmentListRequest request) {
        return iotEquipmentService.getList(request);
    }

    /**
     * 获取物联设备信息
     */
    @GetMapping(value = "/info/{id}")
    public JsonResult getInfo(@PathVariable("id") String id) {
        return iotEquipmentService.getInfo(id);
    }

    /**
     * 新增获取物联设备
     *
     * @param request
     * @return
     */
    @PostMapping("/add")
    public JsonResult add(@RequestBody AddIotEquipmentRequest request) {
        return iotEquipmentService.add(request);
    }

    /**
     * 修改获取物联设备
     */
    @PutMapping("/edit")
    public JsonResult edit(@RequestBody EditIotEquipmentRequest request) {
        return iotEquipmentService.edit(request);
    }


    /**
     * 删除获取物联设备
     */
    @DeleteMapping("/delete/{id}")
    public JsonResult deletedById(@PathVariable("id") String id) {
        return iotEquipmentService.deletedById(id);
    }


    /**
     * 启用禁用算法
     */
    @PutMapping("/enable/{id}/{status}")
    public JsonResult isEnabled(@PathVariable("id") String id,@PathVariable("status") Integer status ) {
        return iotEquipmentService.isEnabled(id,status);
    }

}
