account

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	db.Model
	Name     string `gorm:"uniqueIndex"`
	Password string
	Roles    []*Role `gorm:"many2many:account_role"`
}

Account 描述账户

func (*Account) BeforeSave

func (a *Account) BeforeSave(tx *gorm.DB) error

BeforeSave 将Account保存到数据库之前加密Password

type Address added in v0.0.3

type Address struct {
	db.Model
	ProfileUUID string
	Country     string
	Province    string
	City        string
	Detail      string
}

type Email added in v0.0.3

type Email struct {
	db.Model
	ProfileUUID string
	Address     string // 电子邮件地址
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager 管理Account的Manager

func DefaultManager

func DefaultManager() *Manager

DefaultManager 使用默认的数据库创建Manager

func NewManager

func NewManager(db *gorm.DB) *Manager

NewManager 新建Manager

func (*Manager) AccountExists added in v0.0.3

func (m *Manager) AccountExists(name string) bool

AccountExists 检查账户名对应的账户是否存在

func (*Manager) AddAccount added in v0.0.3

func (m *Manager) AddAccount(account Account) (*Account, error)

AddAccount 添加账户

func (*Manager) AddRole added in v0.0.3

func (m *Manager) AddRole(name string) (*Role, error)

AddRole 添加角色

func (*Manager) GetAccount added in v0.0.3

func (m *Manager) GetAccount(name string) (*Account, error)

GetAccount 根据账户名获取账户

func (*Manager) RegisterAccount added in v0.0.3

func (m *Manager) RegisterAccount(name, password string) error

RegisterAccount 注册账户

type MobilePhone added in v0.0.3

type MobilePhone struct {
	db.Model
	ProfileUUID string
	Prefix      string // 国家地区码
	Number      string // 手机号码
}

MobilePhone 记录手机号码

type Profile added in v0.0.3

type Profile struct {
	db.Model
	AccountUUID            string
	Account                Account
	Name                   string
	PrimaryMobilePhoneUUID string
	PrimaryMobilePhone     MobilePhone
	MobilePhone            []MobilePhone
	PrimaryEmailUUID       string
	PrimaryEmail           Email
	Emails                 []Email
	PrimaryAddressUUID     string
	PrimaryAddress         Address
	Addresses              []Address
}

Profile 用于对账户进行描述

type Role

type Role struct {
	db.Model
	Name        string `gorm:"uniqueIndex"`
	Description string
	Accounts    []*Account `gorm:"many2many:account_role"`
}

Role 分配给账户的角色

type User

type User struct {
	db.Model
	AccountUUID string
	Account     Account
	Name        string
	Gender      string
	Country     string
	Province    string
	City        string
}

User 对帐户的拥有者的描述

Jump to

Keyboard shortcuts

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