签入签出

This commit is contained in:
duoaohui
2026-05-22 01:02:34 +08:00
parent c9765c0f80
commit 19aac86f48
2 changed files with 147 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ package controller
import (
"errors"
"strconv"
"strings"
"github.com/echochat/backend/app/constants"
"github.com/echochat/backend/app/dto"
@@ -32,6 +33,8 @@ func NewMeetingController(meetingService *service.MeetingService, meetingConfig
type cloudLawCreateMeetingRequest struct {
CallID string `json:"callId"`
CallerID int64 `json:"callerId"`
CallerPhone string `json:"callerPhone"`
CallerName string `json:"callerName"`
ReceiverID int64 `json:"receiverId"`
ReceiverType string `json:"receiverType"`
Title string `json:"title"`
@@ -103,6 +106,8 @@ func (ctl *MeetingController) handleError(c *gin.Context, err error, fallbackMsg
errors.Is(err, service.ErrKickSelfForbidden),
errors.Is(err, service.ErrTransferToSelf),
errors.Is(err, service.ErrTransferTargetInvalid),
errors.Is(err, service.ErrCloudLawCallerPhoneRequired),
errors.Is(err, service.ErrCloudLawCallerPhoneInvalid),
// P2-7 会议聊天服务端校验失败:内容为空 / 超长 / 触发限流
// 当前使用 400由 ResponseBadRequest 返回),保持与其余业务错误一致;
// 未来若需要精细区分(如 ErrChatRateLimited → 429、ErrChatContentTooLong → 413可拆分分支
@@ -213,11 +218,22 @@ func (ctl *MeetingController) CloudLawCreateMeeting(c *gin.Context) {
utils.ResponseBadRequest(c, "callerId不能为空")
return
}
req.CallerPhone = strings.TrimSpace(req.CallerPhone)
req.CallerName = strings.TrimSpace(req.CallerName)
if req.CallerPhone == "" {
utils.ResponseBadRequest(c, "callerPhone不能为空")
return
}
title := req.Title
if title == "" {
title = "云律立即连线"
}
room, _, _, err := ctl.meetingService.CreateRoom(c.Request.Context(), req.CallerID, &dto.CreateMeetingRoomRequest{
hostUser, created, err := ctl.meetingService.EnsureCloudLawUserByPhone(c.Request.Context(), req.CallerPhone, req.CallerName)
if err != nil {
ctl.handleError(c, err, "创建云律会议主持人失败")
return
}
room, _, _, err := ctl.meetingService.CreateRoomForInternal(c.Request.Context(), hostUser.ID, &dto.CreateMeetingRoomRequest{
Title: title,
MaxMembers: 2,
})
@@ -225,8 +241,12 @@ func (ctl *MeetingController) CloudLawCreateMeeting(c *gin.Context) {
ctl.handleError(c, err, "创建云律会议失败")
return
}
payload := cloudLawMeetingPayload(room, 1)
payload := cloudLawMeetingPayload(room, 0)
payload["callId"] = req.CallID
payload["callerId"] = req.CallerID
payload["callerPhone"] = req.CallerPhone
payload["echoChatHostUserId"] = strconv.FormatInt(hostUser.ID, 10)
payload["echoChatHostUserCreated"] = created
payload["receiverId"] = req.ReceiverID
payload["receiverType"] = req.ReceiverType
payload["callType"] = req.CallType