Draft: feat login

This commit is contained in:
ytshih committed 2025-09-10 02:53:48 +08:00
1 parent 6d7074198f
commit 3a9ffe7857
43 files changed
+1894 -91

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
package models
type Room struct {
Creater string
Type string
Status string
}
func (self Room) View() string {
return ""
}
+39
View File
@@ -0,0 +1,39 @@
package models
import (
"fmt"
"github.com/uptrace/bun"
)
type User struct {
bun.BaseModel `bun:"table:user" json:"-"`
Username string `bun:"username,pk"`
Password string `bun:"password"`
}
type UserState int
const (
UserStateIdle UserState = iota
UserStateGaming
)
var (
UserStateStr = []string{"Idle", "Gaming"}
)
type UserStatus struct {
bun.BaseModel `bun:"table:user_status"`
Username string `bun:"username,pk" json:"username"`
State UserState `bun:"state" json:"state"`
}
func (self UserStatus) View() string {
return fmt.Sprintf("%s [%s]",
self.Username,
UserStateStr[self.State],
)
}