dual check v0.1
This commit is contained in:
1 parent
78bad1fa3d
commit
c137299016
36 files changed
+3727
-81
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// Package dual_check 双验工具后端实现
|
||||
// 一个发起方(initiator)+ 多个参与方(participant)
|
||||
// 发起方提交文本作为"标准答案",每个参与方各自提交文本后与发起方比对
|
||||
package dual_check
|
||||
|
||||
import "time"
|
||||
|
||||
// ── 创建会话 ──
|
||||
|
||||
type CreateRequest struct {
|
||||
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
|
||||
}
|
||||
|
||||
// CreateResponse 创建成功
|
||||
type CreateResponse struct {
|
||||
SessionID string `json:"session_id"`
|
||||
Nickname string `json:"nickname"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
TTL int `json:"ttl_seconds"`
|
||||
}
|
||||
|
||||
// ── 提交文本(通用:发起方 & 参与方) ──
|
||||
|
||||
type SubmitRequest struct {
|
||||
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
|
||||
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
|
||||
Role string `json:"role" binding:"required,oneof=initiator participant"`
|
||||
Text string `json:"text" binding:"required"`
|
||||
}
|
||||
|
||||
// SubmitResponse 参与者提交后的结果(如果发起方已提交则 match 已算出)
|
||||
type SubmitResponse struct {
|
||||
Submitted bool `json:"submitted"`
|
||||
InitiatorReady bool `json:"initiator_ready"` // 发起方是否已提交标准答案
|
||||
Match *bool `json:"match,omitempty"` // 发起方已提交时立即有值
|
||||
}
|
||||
|
||||
// ── 参与者加入 ──
|
||||
|
||||
type JoinRequest struct {
|
||||
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
|
||||
}
|
||||
|
||||
// JoinResponse 返回当前会话全量状态,供参与者初始化 UI
|
||||
type JoinResponse struct {
|
||||
InitiatorNickname string `json:"initiator_nickname,omitempty"`
|
||||
InitiatorReady bool `json:"initiator_ready"`
|
||||
Participants []ParticipantResp `json:"participants"`
|
||||
}
|
||||
|
||||
// ── 会话全量状态(发起方拉取 / 发起方 WS 初始化) ──
|
||||
|
||||
// SessionResponse 发起方看到的会话状态(完整参与者列表)
|
||||
type SessionResponse struct {
|
||||
SessionID string `json:"session_id"`
|
||||
InitiatorNickname string `json:"initiator_nickname"`
|
||||
InitiatorReady bool `json:"initiator_ready"`
|
||||
AllowResubmit bool `json:"allow_resubmit"`
|
||||
Participants []ParticipantResp `json:"participants"`
|
||||
TTLSeconds int64 `json:"ttl_seconds"`
|
||||
}
|
||||
|
||||
// ParticipantResp 单个参与者的状态
|
||||
type ParticipantResp struct {
|
||||
Nickname string `json:"nickname"`
|
||||
Joined bool `json:"joined"`
|
||||
Submitted bool `json:"submitted"`
|
||||
Match *bool `json:"match,omitempty"`
|
||||
}
|
||||
|
||||
// ── 会话校验(加入前预检查) ──
|
||||
|
||||
type CheckResponse struct {
|
||||
Exists bool `json:"exists"`
|
||||
InitiatorReady bool `json:"initiator_ready"`
|
||||
AllowResubmit bool `json:"allow_resubmit"`
|
||||
ParticipantCount int `json:"participant_count"`
|
||||
TTLSeconds int64 `json:"ttl_seconds"`
|
||||
}
|
||||
|
||||
// ── 发起方设置接口 ──
|
||||
|
||||
// SetResubmitRequest 发起方切换"允许参与者重新提交"开关
|
||||
type SetResubmitRequest struct {
|
||||
Allow bool `json:"allow"`
|
||||
}
|
||||
Reference in new issue
Block a user