package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.iot.domain.VcDevice;
import com.usky.iot.domain.VcStream;
import com.usky.iot.service.VcStreamService;
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("/vcStream")
public class VcStreamController {

    @Autowired
    private VcStreamService vcStreamService;

    /**
     * 流媒体信息分页查询
     *
     * @param platformAddress
     * @param platformType
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public ApiResult<CommonPage<VcStream>> pageList(@RequestParam(value = "platformAddress", required = false, defaultValue = "") String platformAddress,
                                                    @RequestParam(value = "platformType", required = false, defaultValue = "") Integer platformType,
                                                    @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                    @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(vcStreamService.pageList(platformAddress, platformType, pageNum, pageSize));
    }

    /**
     * 新增
     * @param vcStream
     * @return
     */
    @PostMapping("/add")
    public ApiResult<Void> add(@RequestBody VcStream vcStream){
        vcStreamService.add(vcStream);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param vcStream
     * @return
     */
    @PutMapping("/edit")
    public ApiResult<Void> edit(@RequestBody VcStream vcStream){
        vcStreamService.update(vcStream);
        return ApiResult.success();
    }

    /**
     * 删除记录
     */
    @DeleteMapping("/{id}")
    public ApiResult<Void> remove(@PathVariable("id") Integer id)
    {
        vcStreamService.remove(id);
        return ApiResult.success();
    }
}

