init
This commit is contained in:
@@ -52,10 +52,11 @@ public class ChatManager {
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
private String setWsToken(Long roomId,Long fromUid,Long toUid){
|
||||
private String setWsToken(Long roomId,Long fromUid,Long toUid,Long userId){
|
||||
String token = IdManager.nextIdStr();
|
||||
String tokenKey = String.format(RedisConstant.WS_TOKEN, token);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("userId",userId);
|
||||
map.put("roomId",roomId);
|
||||
map.put("fromUid",fromUid);
|
||||
map.put("toUid",toUid);
|
||||
@@ -84,7 +85,7 @@ public class ChatManager {
|
||||
roomId = webSocketManager.createRoom(call.getId());
|
||||
}
|
||||
String wsSocketUrlFormat = systemConfigManager.getSystemConfig(SystemConfigEnum.WS_SOCKET_URL);
|
||||
String token = setWsToken(roomId, fromUser.getId(), toUser.getId());
|
||||
String token = setWsToken(roomId, fromUser.getId(), toUser.getId(),userId);
|
||||
String weSocketUrl = String.format(wsSocketUrlFormat,token,roomId);
|
||||
Long guardPrice = systemConfigManager.getSystemConfigOfLong(SystemConfigEnum.GUARD_PRICE);
|
||||
// 获取鉴黄规则 TODO
|
||||
@@ -125,7 +126,9 @@ public class ChatManager {
|
||||
User fromUser = userMap.get(userCall.getFromUid());
|
||||
User toUser = userMap.get(userCall.getToUid());
|
||||
Anchor anchor = anchorService.getByUserId(toUser.getId());
|
||||
String weSocketUrl = String.format(properties.getWebSocketUrl(),"token",roomId);
|
||||
String wsSocketUrlFormat = systemConfigManager.getSystemConfig(SystemConfigEnum.WS_SOCKET_URL);
|
||||
String token = setWsToken(userCall.getId(), fromUser.getId(), toUser.getId(), userId);
|
||||
String weSocketUrl = String.format(wsSocketUrlFormat,token,roomId);
|
||||
GetRoomResp getRoomResp = new GetRoomResp();
|
||||
getRoomResp.setRoomId(userCall.getId()+"");
|
||||
getRoomResp.setFromUid(userCall.getFromUid());
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ruoyi.cai.controller.app;
|
||||
|
||||
import com.ruoyi.cai.chat.ChatManager;
|
||||
import com.ruoyi.cai.dto.app.query.CallReq;
|
||||
import com.ruoyi.cai.dto.app.vo.chat.CallResp;
|
||||
import com.ruoyi.cai.dto.app.vo.chat.GetRoomResp;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/room")
|
||||
@Tag(name = "直播相关接口")
|
||||
@Validated
|
||||
public class RoomController {
|
||||
|
||||
@Autowired
|
||||
private ChatManager chatManager;
|
||||
|
||||
@PostMapping("/call")
|
||||
@Operation(summary = "发起直播")
|
||||
public R<CallResp> call(@RequestBody CallReq req){
|
||||
CallResp call = chatManager.call(req);
|
||||
return R.ok(call);
|
||||
}
|
||||
|
||||
@GetMapping("/getRoom")
|
||||
@Operation(summary = "获取房间信息")
|
||||
public R<GetRoomResp> getRoom(@NotEmpty(message = "房间不存在") String roomId){
|
||||
GetRoomResp room = chatManager.getRoom(roomId);
|
||||
return R.ok(room);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,6 @@ public class GetRoomResp {
|
||||
private String toAvatar;
|
||||
@Schema(description = "wsUrl")
|
||||
private String socketUrl;
|
||||
@Schema(description = "技能名称")
|
||||
private String skillName;
|
||||
@Schema(description = "技能头像")
|
||||
private String skillIcon;
|
||||
@Schema(description = "价格")
|
||||
private Long price;
|
||||
@Schema(description = "评分")
|
||||
|
||||
Reference in New Issue
Block a user