Documentation ¶
Index ¶
- Variables
- func InitDB() error
- type Account
- func (a Account) FindById(ctx context.Context, id uint64) (account *Account, err error)
- func (a Account) FindByUserId(ctx context.Context, id uint64) (account *Account, err error)
- func (a Account) FindByUsername(ctx context.Context, username string) (account *Account, err error)
- func (a Account) RegisterNewUser(ctx context.Context, username, passwordHash string) (user *User, err error)
- func (a Account) Update(ctx context.Context, account *Account) error
- type AllTable
- type Building
- func (b Building) FindAllEnabled(ctx context.Context) (buildings []*Building, err error)
- func (b Building) FindById(ctx context.Context, id uint64) (building *Building, err error)
- func (b Building) FindByNum(ctx context.Context, num string) (building *Building, err error)
- func (b Building) PluckAllEnabledIds(ctx context.Context) (ids []uint64, err error)
- type Dorm
- func (d Dorm) Allocate(ctx context.Context, buildingId uint64, memberCnt uint64, gender string) (dorm *Dorm, err error)
- func (d Dorm) FindAllEnabled(ctx context.Context) (dorms []*Dorm, err error)
- func (d Dorm) FindById(ctx context.Context, id uint64) (dorm *Dorm, err error)
- func (d Dorm) SumRemainCntByBuildingId(ctx context.Context, id uint64) (sum int64, err error)
- func (d Dorm) Update(ctx context.Context, dorm *Dorm) error
- type Order
- func (o Order) Create(ctx context.Context, order *Order) error
- func (o Order) Delete(ctx context.Context, order *Order) error
- func (o Order) FindAllByTeamIdWithDeleted(ctx context.Context, id uint64) (orders []*Order, err error)
- func (o Order) FindByCodeWithDeleted(ctx context.Context, code string) (order *Order, err error)
- func (o Order) FindById(ctx context.Context, id uint64) (order *Order, err error)
- func (o Order) FindByIdWithDeleted(ctx context.Context, id uint64) (order *Order, err error)
- func (o Order) FindSuccessByTeamId(ctx context.Context, id uint64) (order *Order, err error)
- func (o Order) TransCreateAndDecreaseDormRemainCnt(ctx context.Context, order *Order, dorm *Dorm, memberCnt uint64) error
- func (o Order) TransDeleteAndIncreaseDormRemainCnt(ctx context.Context, order *Order, dorm *Dorm, memberCnt uint64) error
- func (o Order) Update(ctx context.Context, order *Order) error
- type Team
- func (t Team) CheckIfHasTeam(ctx context.Context, userId uint64) (*Team, error)
- func (t Team) Delete(ctx context.Context, team *Team) error
- func (t Team) FindByCode(ctx context.Context, code string) (team *Team, err error)
- func (t Team) FindByInnerJoinUserId(ctx context.Context, id uint64) (*Team, error)
- func (t Team) FindByOwnerId(ctx context.Context, id uint64) (*Team, error)
- func (t Team) GenNew(ctx context.Context, owner *User) (team *Team, err error)
- func (t Team) TransSetNewOwner(ctx context.Context, team *Team, memberRel *TeamUser) error
- func (t Team) Update(ctx context.Context, team *Team) error
- type TeamUser
- func (t TeamUser) CntTeamMember(ctx context.Context, teamId uint64) (cnt uint64, err error)
- func (t TeamUser) Create(ctx context.Context, teamUser *TeamUser) error
- func (t TeamUser) Delete(ctx context.Context, teamUser *TeamUser) error
- func (t TeamUser) FindByTeamIdAndUserId(ctx context.Context, teamId, userId uint64) (rel *TeamUser, err error)
- func (t TeamUser) PluckAllUserIdsByTeamId(ctx context.Context, teamId uint64) (userIds []uint64, err error)
- type Token
- type User
- func (u User) Create(ctx context.Context, user *User) error
- func (u User) FindAll(ctx context.Context) (users []*User, err error)
- func (u User) FindAllByIds(ctx context.Context, ids []uint64) (users []*User, err error)
- func (u User) FindById(ctx context.Context, userId uint64) (user *User, err error)
- func (u User) FindByStudentNum(ctx context.Context, studentNum string) (user *User, err error)
- func (u User) Update(ctx context.Context, user *User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
Types ¶
type Account ¶
type Account struct { Id uint64 `gorm:"primaryKey"` UserId uint64 `gorm:"not null"` Username string `gorm:"not null; unique"` Password string `gorm:"not null"` Deleted gorm.DeletedAt }
func (Account) FindByUserId ¶
func (Account) FindByUsername ¶
type AllTable ¶
type AllTable struct { Account Account Building Building Dorm Dorm Order Order Team Team TeamUser TeamUser Token Token User User }
var Table AllTable
type Building ¶
type Building struct { Id uint64 `gorm:"primaryKey" json:"-"` Num string `gorm:"size:10; not null; unique" json:"num,omitempty"` Info string `json:"info,omitempty"` ImgUrl string `json:"imgUrl,omitempty"` Enabled bool `gorm:"not null" json:"enabled,omitempty"` Deleted gorm.DeletedAt }
func (Building) FindAllEnabled ¶
type Dorm ¶
type Dorm struct { Id uint64 `gorm:"primaryKey" json:"-"` Num string `gorm:"size:10; not null; unique" json:"num,omitempty"` BuildingId uint64 `gorm:"not null" json:"buildingId,omitempty"` Gender string `gorm:"size:10; not null" json:"gender,omitempty"` RemainCnt uint64 `gorm:"not null" json:"remainCnt,omitempty"` BedCnt uint64 `gorm:"not null" json:"bedCnt,omitempty"` Info string `json:"info,omitempty"` Enabled bool `gorm:"not null" json:"enabled,omitempty"` Deleted gorm.DeletedAt }
func (Dorm) Allocate ¶
func (d Dorm) Allocate(ctx context.Context, buildingId uint64, memberCnt uint64, gender string) (dorm *Dorm, err error)
Allocate find a suitable dorm for the order
func (Dorm) FindAllEnabled ¶
func (Dorm) SumRemainCntByBuildingId ¶
type Order ¶
type Order struct { Id uint64 `gorm:"primaryKey"` BuildingId uint64 `gorm:"not null"` DormId uint64 `gorm:"not null; default:0"` TeamId uint64 `gorm:"not null"` Code string `gorm:"not null; unique"` Info string Success bool `gorm:"not null; default:0"` Deleted gorm.DeletedAt }
func (Order) FindAllByTeamIdWithDeleted ¶
func (Order) FindByCodeWithDeleted ¶
FindByCodeWithDeleted is to make sure code is unique, this will include deleted records
func (Order) FindByIdWithDeleted ¶
func (Order) FindSuccessByTeamId ¶
func (Order) TransCreateAndDecreaseDormRemainCnt ¶
func (o Order) TransCreateAndDecreaseDormRemainCnt(ctx context.Context, order *Order, dorm *Dorm, memberCnt uint64) error
TransCreateAndDecreaseDormRemainCnt create an order and decrease the corresponding dorm's remain count
type Team ¶
type Team struct { Id uint64 `gorm:"primaryKey"` Code string `gorm:"not null; unique"` Gender string `gorm:"size:10; not null"` OwnerId uint64 `gorm:"not null; unique"` Deleted gorm.DeletedAt }
func (Team) CheckIfHasTeam ¶
CheckIfHasTeam checks if a user is a team owner OR a team member
func (Team) FindByCode ¶
func (Team) FindByInnerJoinUserId ¶
FindByInnerJoinUserId only finds team member, for owner please use FindByOwnerId
func (Team) FindByOwnerId ¶
func (Team) TransSetNewOwner ¶
type TeamUser ¶
type TeamUser struct { Id uint64 `gorm:"primaryKey"` TeamId uint64 `gorm:"not null"` UserId uint64 `gorm:"not null"` Deleted gorm.DeletedAt }
func (TeamUser) CntTeamMember ¶
func (TeamUser) FindByTeamIdAndUserId ¶
type Token ¶
type Token struct { Id uint64 `gorm:"primaryKey" json:"-"` RefreshToken string `gorm:"not null" json:"refreshToken,omitempty"` UserId uint64 `gorm:"not null" json:"-"` CreateTime time.Time `gorm:"not null" json:"createTime,omitempty"` ExpTime time.Time `gorm:"not null" json:"expTime,omitempty"` Deleted gorm.DeletedAt }
func (Token) FindByRefreshToken ¶
type User ¶
type User struct { Id uint64 `gorm:"primaryKey" json:"-"` StudentNum string `gorm:"not null; unique" json:"studentNum,omitempty"` Name string `gorm:"size:20; not null" json:"name,omitempty"` Gender string `gorm:"size:10; not null" json:"gender,omitempty"` Role int32 `gorm:"not null; default:1" json:"-"` Deleted gorm.DeletedAt }
func (User) FindAllByIds ¶
func (User) FindByStudentNum ¶
Click to show internal directories.
Click to hide internal directories.