models

package
v0.0.0-...-f668870 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrDatabase = -1
	ErrSystem   = -2
	ErrDupRows  = -3
	ErrNotFound = -4
)

Predefined model error codes.

Variables

This section is empty.

Functions

func ChangePass

func ChangePass(id, oldPass, newPass string) (code int, err error)

ChangePass update password and salt information according to input id.

func IncTotalUserCount

func IncTotalUserCount(t time.Time) error

IncTotalUserCount increase user count in redis.

Types

type CodeInfo

type CodeInfo struct {
	Code int    `json:"code"`
	Info string `json:"info"`
}

CodeInfo definiton.

func NewErrorInfo

func NewErrorInfo(info string) *CodeInfo

NewErrorInfo return a CodeInfo represents error.

func NewNormalInfo

func NewNormalInfo(info string) *CodeInfo

NewNormalInfo return a CodeInfo represents OK.

type LoginForm

type LoginForm struct {
	Phone    string `form:"phone"    valid:"Required;Mobile"`
	Password string `form:"password" valid:"Required"`
}

LoginForm definiton.

type LoginInfo

type LoginInfo struct {
	Code     int   `json:"code"`
	UserInfo *User `json:"user"`
}

LoginInfo definiton.

type LogoutForm

type LogoutForm struct {
	Phone string `form:"phone" valid:"Required;Mobile"`
}

LogoutForm defintion.

type PasswdForm

type PasswdForm struct {
	Phone   string `form:"phone"        valid:"Required;Mobile"`
	OldPass string `form:"old_password" valid:"Required"`
	NewPass string `form:"new_password" valid:"Required"`
}

PasswdForm definition.

type RegisterForm

type RegisterForm struct {
	Phone    string `form:"phone"    valid:"Required;Mobile"`
	Name     string `form:"name"     valid:"Required"`
	Password string `form:"password" valid:"Required"`
}

RegisterForm definiton.

type Role

type Role struct {
	ID       int64     `json:"id,omitempty"`
	Name     string    `json:"name,omitempty"`
	Password string    `json:"password,omitempty"`
	RegDate  time.Time `json:"reg_date,omitempty"`
}

Role model definiton.

func GetAllRoles

func GetAllRoles(queryVal map[string]string, queryOp map[string]string, order map[string]string, limit int64, offset int64) (records []Role, err error)

GetAllRoles query all matched records.

func NewRole

func NewRole(f *RolePostForm, t time.Time) *Role

NewRole alloc and initialize a role.

func (*Role) ClearPass

func (r *Role) ClearPass()

ClearPass clear password information.

func (*Role) DeleteByID

func (r *Role) DeleteByID(id int64) (code int, err error)

DeleteByID delete a record accroding to input id.

func (*Role) FindByID

func (r *Role) FindByID(id int64) (code int, err error)

FindByID query a recode according to input id.

func (*Role) Insert

func (r *Role) Insert() (code int, err error)

Insert insert a role recode to database.

func (*Role) UpdateByID

func (r *Role) UpdateByID(id int64, f *RolePutForm) (code int, err error)

UpdateByID update a recode accroding to input id.

type RoleAuthForm

type RoleAuthForm struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

RoleAuthForm definiton.

type RoleAuthInfo

type RoleAuthInfo struct {
	Token string `json:"token"`
}

RoleAuthInfo definiton.

type RoleGetAllInfo

type RoleGetAllInfo struct {
	RolesInfo []Role `json:"roles"`
}

RoleGetAllInfo definiton.

type RoleGetOneInfo

type RoleGetOneInfo struct {
	RoleInfo *Role `json:"role"`
}

RoleGetOneInfo definiton.

type RolePostForm

type RolePostForm struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

RolePostForm definiton.

type RolePostInfo

type RolePostInfo struct {
	RoleInfo *Role `json:"role"`
}

RolePostInfo definiton.

type RolePutForm

type RolePutForm struct {
	Name     string `json:"name"`
	Password string `json:"password"`
}

RolePutForm definiton.

type RolePutInfo

type RolePutInfo struct {
	RoleInfo *Role `json:"role"`
}

RolePutInfo definiton.

type UploadsForm

type UploadsForm struct {
	Phone string `form:"phone" valid:"Required;Mobile"`
}

UploadsForm definiton.

type User

type User struct {
	ID       string    `bson:"_id"      json:"_id,omitempty"`
	Name     string    `bson:"name"     json:"name,omitempty"`
	Password string    `bson:"password" json:"password,omitempty"`
	Salt     string    `bson:"salt"     json:"salt,omitempty"`
	RegDate  time.Time `bson:"reg_date" json:"reg_date,omitempty"`
}

User model definiton.

func NewUser

func NewUser(r *RegisterForm, t time.Time) (u *User, err error)

NewUser alloc and initialize a user.

func (*User) CheckPass

func (u *User) CheckPass(pass string) (ok bool, err error)

CheckPass compare input password.

func (*User) ClearPass

func (u *User) ClearPass()

ClearPass clear password information.

func (*User) FindByID

func (u *User) FindByID(id string) (code int, err error)

FindByID query a document according to input id.

func (*User) Insert

func (u *User) Insert() (code int, err error)

Insert insert a document to collection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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