package models import ( "fmt" "github.com/uptrace/bun" ) type RoomType int const ( RoomTypeWordle RoomType = iota ) var ( RoomTypeStr = []string{"Wordle"} ) type RoomStatus int const ( RoomStatusWaiting RoomStatus = iota RoomStatusPlaying RoomStatusEnded ) var ( RoomStatusStr = []string{"Waiting", "Playing", "Ended"} ) type Room struct { bun.BaseModel `bun:"table:room"` Id int `bun:"id,pk,autoincrement"` Creater string `bun:"creater"` Type RoomType `bun:"type"` Status RoomStatus `bun:"status"` } func (self Room) View() string { return fmt.Sprintf("%2d. %10s %10s [%s]", self.Id, self.Creater, RoomTypeStr[self.Type], RoomStatusStr[self.Status], ) }