model_user

package
v0.0.0-...-9e8b3cb Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//StatusNormal    = 0
	StatusLogin  = 1
	StatusLogout = 2
)
View Source
const (

	//UserPermissionAll    = "USER_ALL"
	UserPermissionSelect = "USER_SELECT"
	UserPermissionCreate = "USER_CREATE"
	UserPermissionEdit   = "USER_EDIT"
	UserPermissionDelete = "USER_DELETE"
)

Variables

This section is empty.

Functions

func UpdateLoginStatus

func UpdateLoginStatus(token string, status int) error

status 0 退出登录,1 登录

return mongo.Update(shareDB.DocManagerDBName(), todoCollection, bson.M{"_id": t.Id}, bson.M{"$set": bson.M{"title": t.Title, "completed": t.Completed, "updated_at": t.UpdatedAt}})

Types

type Login

type Login struct {
	Id         int64  `json:"id,omitempty" bson:"_id,omitempty"`
	UserId     int64  `bson:"user_id"`     // 用户ID
	Token      string `bson:"token"`       // 用户TOKEN
	CreateTime int64  `bson:"create_time"` // 登录日期
	LoginIp    string `bson:"login_ip"`    // 登录IP
	Status     state  `bson:"status"`      //status 1 已登录,2表示退出登录
	Forbidden  bool   `bson:"forbidden"`   //false 表示未禁言
	UserAgent  string `bson:"user_agent"`  //用户UA
	UpdatedAt  int64  `json:"updated_at,omitempty" bson:"updated_at"`
}

func FindLoginByToken

func FindLoginByToken(token string) (l *Login, err error)

func UserLogin

func UserLogin(userID int64, userAgent, token, ip string) (l *Login, err error)

func (Login) FindAll

func (l Login) FindAll() ([]Login, error)

func (*Login) Insert

func (l *Login) Insert() error

func (Login) ToJson

func (l Login) ToJson() string

type User

type User struct {
	Id          int64             `json:"id,omitempty" bson:"_id,omitempty"`
	Username    string            `json:"username,omitempty" bson:"username,omitempty"` //用户名
	Password    string            `json:"password,omitempty" bson:"password,omitempty"`
	Avatar      string            `json:"avatar,omitempty" bson:"avatar,omitempty"`
	Email       string            `json:"email,omitempty" bson:"email,omitempty"`
	Phone       string            `json:"phone,omitempty" bson:"phone,omitempty"`
	Gender      int               `json:"gender,omitempty" bson:"gender,omitempty"` // 1男 2女
	Name        string            `json:"name,omitempty" bson:"name,omitempty"`     // 名字!
	Nick        string            `json:"nick,omitempty" bson:"nick,omitempty"`     // 昵称
	Title       string            `json:"title,omitempty" bson:"title,omitempty"`
	Enabled     bool              `json:"enabled,omitempty" bson:"enabled"`      //1 激活,
	Note        string            `json:"note,omitempty"  bson:"note,omitempty"` //备注,
	CreateTime  int64             `json:"createTime,omitempty"  bson:"create_time,omitempty"`
	Roles       []model_role.Role `json:"roles,omitempty" bson:"roles,omitempty"`
	RolesString []string          `json:"roles_string,omitempty" bson:"roles_string,omitempty"`
	Permissions []string          `json:"permissions,omitempty" bson:"permissions,omitempty"`
}

func LoginUser

func LoginUser(username, pass string) (user User, err error)

func (User) CheckPassword

func (u User) CheckPassword() bool

func (User) FindAll

func (u User) FindAll() ([]User, error)

func (User) FindOne

func (u User) FindOne() (User, error)

func (User) FindPageFilter

func (u User) FindPageFilter(page, limit int, query, selector interface{}, fields ...string) ([]User, error)

func (User) FindPageTreeFilter

func (u User) FindPageTreeFilter(page, limit int, query, selector interface{}, fields ...string) ([]User, error)

func (User) FindRoles

func (u User) FindRoles() (User, error)

func (User) FindTreeOne

func (u User) FindTreeOne() (User, error)

func (*User) Insert

func (u *User) Insert() error

userModify

func (User) Remove

func (u User) Remove() error

func (User) ToJson

func (u User) ToJson() string

func (User) TotalCount

func (u User) TotalCount(query, selector interface{}) (int, error)

func (User) Update

func (u User) Update() error

func (User) UpdateAvatar

func (u User) UpdateAvatar() error

func (User) UpdateMail

func (u User) UpdateMail() error

func (User) UpdatePassword

func (u User) UpdatePassword() error

Jump to

Keyboard shortcuts

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