package cn.iocoder.yudao.module.product.controller.app.monitor;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.admin.deviceinfo.vo.MonitorUrLRespVO;
import cn.iocoder.yudao.module.product.service.deviceinfo.DeviceInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

@Api(tags = "APP移动端 - 监控信息")
@RestController
@RequestMapping("/product/monitor-info")
@Validated
public class MonitorAppController {

    @Resource
    private DeviceInfoService deviceInfoService;

    @GetMapping("/getMonitorPreviewURLByLandId")
    @PermitAll // 无需登陆
    @ApiOperation("获取监控播放地址")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "landId", value = "地块/鱼塘/牧场编码", required = true, example = "AECD202305041501UE6F", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "url前缀类型", required = true, example = "wss", dataTypeClass = String.class)
    })
    public CommonResult<List<MonitorUrLRespVO>> getMonitorPreviewURLByLandId(@RequestParam("landId") String landId, @RequestParam("type") String type) {
        return CommonResult.success(deviceInfoService.getMonitorPreviewURLByLandId(landId, type));
    }

}
