package com.xhkjedu.slive.controller.agora;

import com.xhkjedu.slive.service.agora.AgoraRedisService;
import com.xhkjedu.slive.vo.agora.AgoraRedisVo;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ywx
 * @classname AgoraRedisController
 * @description 
 * @date 2021/1/25 14:41
 **/
@RestController
@RequestMapping("/agora_redis")
@Slf4j
public class AgoraRedisController {
    @Resource
    private AgoraRedisService agoraRedisService;

    @PostMapping("/room_address")
    public ResultVo roomAddress(@RequestBody AgoraRedisVo redis) {
        Integer rid = redis.getRid();
        N_Utils.validation(new Object[]{rid,"房间id",1,redis.getUserid(),"用户id",1});
        String address = agoraRedisService.getRoomAddress(rid,redis.getUserid());
        if (N_Utils.isNotEmpty(address)) {
            return new ResultVo(0, "获取房间服务地址成功", address);
        } else {
            return new ResultVo(1, "暂无可用的服务地址");
        }
    }
}
