models

package
v0.0.0-...-c9b56a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

数据库模型定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Student

type Student struct {
	// 「用户 ID」
	UserID base.ID `gorm:"type:bigint;primaryKey;not null"`

	User *User

	// 「学校」
	University string `gorm:"not null"`

	// 「学院」
	School string `gorm:"not null"`

	// 「行政班」
	ClassID string `gorm:"not null"`

	// 「学号」(用户输入的)
	UntrustedID string `gorm:"not null"`

	// 「学号」 经过审核的,全局唯一
	TrustedID null.String `gorm:"unique,default:null"`

	// 「审核资料」 学生证照片
	VerifyImageURL null.String `gorm:"default:null"`
}

学生用户模型

func FindOrCreateStudentFromUser

func FindOrCreateStudentFromUser(tx *gorm.DB, user *User) (*Student, error)

func (*Student) GetUser

func (student *Student) GetUser(tx *gorm.DB) (*User, error)

type User

type User struct {

	// 「用户 ID」请不要使用自增主键 ( auto increment primary key )
	ID base.ID `gorm:"type:bigint;primaryKey;not null"`

	// 「用户名」用于用户名、密码组合登陆中的用户名,全局唯一;可空,若空,则该用户未设置用户名,无法使用 "用户名、密码组合登陆"
	UserName null.String `gorm:"unique;default:null"`
	// 「密码」用于用户名、密码组合登陆中的密码
	Password string `json:"-"`

	// 「手机号」用于手机号、验证码登陆组合,全局唯一。可空,若空,则该用户未设置手机号,无法使用 "手机号、验证码组合登陆"
	// 格式为 <国家编号><手机号>,如 8615511123234
	PhoneNumber int64 `gorm:"unique;default:null"`

	// 「真实姓名」未设置为空字符串
	RealName string `gorm:"not null"`

	// 「头像」 URL 未设置为空字符串
	AvatarURI string `gorm:"not null"`

	// 「昵称」用于对外展示
	NickName string `gorm:"not null"`

	// 「性别」,true为男性, false为女性
	Gender null.Bool `gorm:"default:null"`

	// 「是否为内部用户」,内部用户可登陆后台管理页面
	IsStaff null.Bool `gorm:"not null;default:false"`

	// 「是否为超级管理员」
	IsSuper null.Bool `gorm:"not null;default:false"`

	// 「账号是否被禁用」
	IsDisabled null.Bool `gorm:"not null;default:false"`
}

用户模型

func FindOrCreateUserByPhoneNumber

func FindOrCreateUserByPhoneNumber(tx *gorm.DB, phoneNumber int64) *User

func FindUserById

func FindUserById(tx *gorm.DB, id int64) *User

func FindUserByUserName

func FindUserByUserName(tx *gorm.DB, userName string) *User

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

func (*User) SetGender

func (user *User) SetGender(gender null.Bool) error

func (*User) SetNickName

func (user *User) SetNickName(nickName string) error

func (*User) SetPassword

func (user *User) SetPassword(passWord string) error

func (*User) SetRealName

func (user *User) SetRealName(realName string) error

func (*User) SetUserName

func (user *User) SetUserName(tx *gorm.DB, userName string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL