Draft: feat login
This commit is contained in:
39
models/user.go
Normal file
39
models/user.go
Normal 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],
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user