48 lines
1.7 KiB
Java
48 lines
1.7 KiB
Java
package com.ruoyi.cai.chat;
|
|
|
|
import com.ruoyi.cai.domain.CaiAnchor;
|
|
import com.ruoyi.cai.domain.CaiUser;
|
|
import com.ruoyi.cai.dto.app.query.AnchorListQuery;
|
|
import com.ruoyi.cai.dto.app.query.CallReq;
|
|
import com.ruoyi.cai.service.CaiAnchorService;
|
|
import com.ruoyi.cai.service.CaiUserService;
|
|
import com.ruoyi.cai.ws.manager.WebSocketManager;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.helper.LoginHelper;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
public class ChatManager {
|
|
@Autowired
|
|
private CaiUserService userService;
|
|
@Autowired
|
|
private CaiAnchorService anchorService;
|
|
@Autowired
|
|
private WebSocketManager webSocketManager;
|
|
|
|
public void call(CallReq callReq){
|
|
Long userId = LoginHelper.getUserId();
|
|
CaiUser formUser = userService.getById(userId);
|
|
CaiUser toUser = userService.getById(callReq.getToUid());
|
|
if(toUser.getIsAnchor() != 1){
|
|
throw new ServiceException("对方未通过女神认证,不能接听视频");
|
|
}
|
|
if(formUser.getGender() == 1 && toUser.getGender() == 1){
|
|
throw new ServiceException("主播和主播之间,不可以拨打视频哦~");
|
|
}
|
|
CaiAnchor anchor = anchorService.getByUserId(toUser.getId());
|
|
if(anchor == null){
|
|
throw new ServiceException("主播技能不存在");
|
|
}
|
|
String roomId = webSocketManager.checkOnlineRoom(formUser.getId(), toUser.getId());
|
|
if (StringUtils.isNotEmpty(roomId)) {
|
|
throw new ServiceException("'服务繁忙'");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|