34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package model
|
|
|
|
import "github.com/uptrace/bun"
|
|
|
|
const (
|
|
USER_TYPE_ENT int8 = iota
|
|
USER_TYPE_SUP
|
|
USER_TYPE_OPS
|
|
)
|
|
|
|
type User struct {
|
|
bun.BaseModel `bun:"table:user,alias:u"`
|
|
Created `bun:"extend"`
|
|
Id string `bun:",pk,notnull" json:"id"`
|
|
Username string `bun:",notnull" json:"username"`
|
|
Password string `bun:",notnull" json:"-"`
|
|
ResetNeeded bool `bun:",notnull" json:"resetNeeded"`
|
|
Type int8 `bun:"type:smallint,notnull" json:"type"`
|
|
Enabled bool `bun:",notnull" json:"enabled"`
|
|
Detail *UserDetail `bun:"rel:has-one,join:id=id" json:"-"`
|
|
Charges []*UserCharge `bun:"rel:has-many,join:id=user_id" json:"-"`
|
|
}
|
|
|
|
type UserWithCredentials struct {
|
|
bun.BaseModel `bun:"table:user,alias:u"`
|
|
Created `bun:"extend"`
|
|
Id string `bun:",pk,notnull" json:"id"`
|
|
Username string `bun:",notnull" json:"username"`
|
|
Password string `bun:",notnull" json:"credential"`
|
|
ResetNeeded bool `bun:",notnull" json:"resetNeeded"`
|
|
Type int8 `bun:"type:smallint,notnull" json:"type"`
|
|
Enabled bool `bun:",notnull" json:"enabled"`
|
|
}
|