55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package robot
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
ScopeGame = "game-robot"
|
|
ScopeRoom = "room-robot"
|
|
|
|
StatusActive = "active"
|
|
StatusDisabled = "disabled"
|
|
|
|
DefaultGameID = "dice"
|
|
DefaultRoomScene = "voice_room"
|
|
)
|
|
|
|
// Robot 是 robot-service 对“真实 App 用户可作为机器人”的统一登记事实;
|
|
// game_id 和 room_scene 只是不同业务域的筛选维度,账号身份仍然由 user-service 拥有。
|
|
type Robot struct {
|
|
AppCode string
|
|
Scope string
|
|
GameID string
|
|
RoomScene string
|
|
UserID int64
|
|
Status string
|
|
CreatedByAdminID int64
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
LastUsedAtMS int64
|
|
UsedCount int64
|
|
}
|
|
|
|
func NormalizeStatus(status string) string {
|
|
status = strings.TrimSpace(status)
|
|
if status == "" {
|
|
return StatusActive
|
|
}
|
|
return status
|
|
}
|
|
|
|
func NormalizeGameID(gameID string) string {
|
|
gameID = strings.TrimSpace(gameID)
|
|
if gameID == "" {
|
|
return DefaultGameID
|
|
}
|
|
return gameID
|
|
}
|
|
|
|
func NormalizeRoomScene(scene string) string {
|
|
scene = strings.TrimSpace(scene)
|
|
if scene == "" {
|
|
return DefaultRoomScene
|
|
}
|
|
return scene
|
|
}
|