This commit performs a significant cleanup of the codebase by removing unused functions, methods, and entire files across various internal modules. This reduces technical debt and simplifies the project structure. Key changes include: - **cache**: Removed unused cache key generators and metrics snapshots. - **dto**: Removed redundant converter functions and segment creation helpers. - **middleware**: Deleted the unused `logger.go` middleware and simplified `ratelimit.go` and `casbin.go`. - **model**: Removed unused ID helpers, database closing functions, and batch decryption logic. - **pkg**: Cleaned up unused utility functions in `circuitbreaker`, `crypto`, `cursor`, `hook`, and `utils`. - **service**: Deleted `account_cleanup_service.go` and removed unused helper functions in `log_cleanup_service.go` and `sensitive_service.go`. - **repository**: Removed unused private loading methods in `comment_repo.go`.
146 lines
4.8 KiB
Go
146 lines
4.8 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
"with_you/internal/model"
|
|
)
|
|
|
|
// ==================== Call Request DTOs ====================
|
|
|
|
// StartCallRequest 发起通话请求
|
|
type StartCallRequest struct {
|
|
ConversationID string `json:"conversation_id" binding:"required"` // 会话ID
|
|
CallType model.CallType `json:"call_type" binding:"required"` // 通话类型: private, group
|
|
}
|
|
|
|
// AnswerCallRequest 接听通话请求
|
|
type AnswerCallRequest struct {
|
|
SDP string `json:"sdp" binding:"required"` // SDP Answer
|
|
}
|
|
|
|
// SendSDPRequest 发送SDP请求
|
|
type SendSDPRequest struct {
|
|
SDP string `json:"sdp" binding:"required"` // SDP Offer/Answer
|
|
Type string `json:"type" binding:"required"` // offer 或 answer
|
|
}
|
|
|
|
// SendICECandidateRequest 发送ICE候选请求
|
|
type SendICECandidateRequest struct {
|
|
Candidate string `json:"candidate" binding:"required"` // candidate 字符串
|
|
SDPMid string `json:"sdp_mid"` // SDP mid
|
|
SDPMLineIndex int16 `json:"sdp_mline_index"` // SDP m-line index
|
|
}
|
|
|
|
// ==================== Call Response DTOs ====================
|
|
|
|
// CallSessionResponse 通话会话响应
|
|
type CallSessionResponse struct {
|
|
ID string `json:"id"` // 通话ID
|
|
ConversationID string `json:"conversation_id"` // 会话ID
|
|
GroupID string `json:"group_id,omitempty"`
|
|
CallerID string `json:"caller_id"` // 发起者ID
|
|
CallType model.CallType `json:"call_type"` // 通话类型
|
|
Status model.CallStatus `json:"status"` // 通话状态
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
EndedAt *time.Time `json:"ended_at,omitempty"`
|
|
Duration int64 `json:"duration"` // 通话时长(秒)
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Participants []CallParticipantResponse `json:"participants"` // 参与者列表
|
|
Caller *UserResponse `json:"caller,omitempty"` // 发起者信息
|
|
}
|
|
|
|
// CallParticipantResponse 通话参与者响应
|
|
type CallParticipantResponse struct {
|
|
UserID string `json:"user_id"`
|
|
Status model.ParticipantStatus `json:"status"`
|
|
JoinedAt *time.Time `json:"joined_at,omitempty"`
|
|
LeftAt *time.Time `json:"left_at,omitempty"`
|
|
User *UserResponse `json:"user,omitempty"`
|
|
}
|
|
|
|
// ==================== Call SSE Event DTOs ====================
|
|
|
|
// CallInviteEvent 来电邀请事件
|
|
type CallInviteEvent struct {
|
|
CallID string `json:"call_id"`
|
|
ConversationID string `json:"conversation_id"`
|
|
GroupID string `json:"group_id,omitempty"`
|
|
CallerID string `json:"caller_id"`
|
|
CallType model.CallType `json:"call_type"`
|
|
Caller *UserResponse `json:"caller,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// CallAnswerEvent 接听响应事件
|
|
type CallAnswerEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
SDP string `json:"sdp"` // SDP Answer
|
|
}
|
|
|
|
// CallRejectEvent 拒绝通话事件
|
|
type CallRejectEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
}
|
|
|
|
// CallEndEvent 结束通话事件
|
|
type CallEndEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
Duration int64 `json:"duration"`
|
|
}
|
|
|
|
// CallICECandidateEvent ICE候选事件
|
|
type CallICECandidateEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
Candidate string `json:"candidate"`
|
|
SDPMid string `json:"sdp_mid"`
|
|
SDPMLineIndex int16 `json:"sdp_mline_index"`
|
|
}
|
|
|
|
// CallSDPOfferEvent SDP Offer事件
|
|
type CallSDPOfferEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
SDP string `json:"sdp"`
|
|
}
|
|
|
|
// CallSDPAnswerEvent SDP Answer事件
|
|
type CallSDPAnswerEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
SDP string `json:"sdp"`
|
|
}
|
|
|
|
// CallUserJoinedEvent 用户加入通话事件(群聊)
|
|
type CallUserJoinedEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
User *UserResponse `json:"user,omitempty"`
|
|
}
|
|
|
|
// CallUserLeftEvent 用户离开通话事件(群聊)
|
|
type CallUserLeftEvent struct {
|
|
CallID string `json:"call_id"`
|
|
UserID string `json:"user_id"`
|
|
}
|
|
|
|
// ==================== ICE Server Config ====================
|
|
|
|
// ICEServerConfig ICE服务器配置
|
|
type ICEServerConfig struct {
|
|
URLs []string `json:"urls"`
|
|
Username string `json:"username,omitempty"`
|
|
Credential string `json:"credential,omitempty"`
|
|
CredentialType string `json:"credential_type,omitempty"`
|
|
}
|
|
|
|
// CallConfigResponse 通话配置响应
|
|
type CallConfigResponse struct {
|
|
ICEServers []ICEServerConfig `json:"ice_servers"`
|
|
}
|
|
|