package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.iot.domain.VcDeviceGroup;
import com.usky.iot.service.VcDeviceGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author han
 * @since 2024-10-23
 */
@RestController
@RequestMapping("/vcDeviceGroup")
public class VcDeviceGroupController {
    @Autowired
    private VcDeviceGroupService vcDeviceGroupService;

    /**
     * 站点分组-新增
     *
     * @param groupName 站点分组名称
     * @return
     */
    @GetMapping("vcDeviceGroupAdd")
    public ApiResult<Void> vcDeviceGroupAdd(@RequestParam String groupName) {
        vcDeviceGroupService.vcDeviceGroupAdd(groupName);
        return ApiResult.success();
    }

    /**
     * 站点分组-修改
     *
     * @param groupName 站点分组名称
     * @param id           站点分组ID
     * @return
     */
    @GetMapping("vcDeviceGroupUpdate")
    public ApiResult<Void> vcDeviceGroupUpdate(@RequestParam String groupName, @RequestParam Integer id) {
        vcDeviceGroupService.vcDeviceGroupUpdate(groupName, id);
        return ApiResult.success();
    }

    /**
     * 站点分组-删除
     */
    @DeleteMapping("/{id}")
    public ApiResult<Void> remove(@PathVariable("id") Integer id)
    {
        vcDeviceGroupService.removeById(id);
        return ApiResult.success();
    }

    /**
     * 站点分组-列表
     *
     * @param groupName 站点分组名称
     * @return
     */
    @GetMapping("vcDeviceGroupList")
    public ApiResult<List<VcDeviceGroup>> vcDeviceGroupList(@RequestParam(value = "groupName", required = false, defaultValue = "") String groupName) {
        return ApiResult.success(vcDeviceGroupService.vcDeviceGroupList(groupName));
    }
}

