models

package
v0.0.0-...-4353b78 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDTYPE_USERID = 1
	IDTYPE_NAME   = 2
	IDTYPE_MAIL   = 3
	IDTYPE_PHONE  = 4
)

用户标识类别

View Source
const (
	GENDER_FEMALE = 0
	GENDER_MALE   = 1
)

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(user *User) (userId uint, err error)

创建用户

func InitTables

func InitTables(db *gorm.DB)

需要初始化的表

func IsEmailExisted

func IsEmailExisted(email string) (isExisted bool, err error)

邮箱是否存在

func IsPhoneExisted

func IsPhoneExisted(phone string) (isExisted bool, err error)

电话是否存在

func IsUserNameExisted

func IsUserNameExisted(name string) (isExisted bool, err error)

用户名是否存在

func UserPasswordCheck

func UserPasswordCheck(userId uint, password string) (bool, error)

密码检查

Types

type User

type User struct {
	gorm.Model
	Name     string `json:"name" gorm:"index,unique"`
	Password string `json:"password"`
	Avatar   string `json:"avatar"`
	Gender   int8   `json:"gender"`
	Mail     string `json:"mail" gorm:"index,unique"`
	Phone    string `json:"phone" gorm:"index,unique"`
}

type UserInfo

type UserInfo struct {
	Id     uint   `json:"id"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
	Gender int8   `json:"gender"`
	Mail   string `json:"mail"`
	Phone  string `json:"phone"`
}

func GetUserInfoByAccount

func GetUserInfoByAccount(account string) (*UserInfo, error)

账号,获取用户信息

func GetUserInfoByMail

func GetUserInfoByMail(mail string) (*UserInfo, error)

邮箱,获取用户信息

func GetUserInfoByName

func GetUserInfoByName(name string) (*UserInfo, error)

用户名,获取用户信息

func GetUserInfoByPhone

func GetUserInfoByPhone(phone string) (*UserInfo, error)

手机号,获取用户信息

func GetUserInfoByUserId

func GetUserInfoByUserId(userId int64) (*UserInfo, error)

用户名,用户电话,用户邮箱唯一 用户id,获取用户信息

Jump to

Keyboard shortcuts

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