models

package
v0.0.0-...-79cb864 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRole

func AddRole(m *Role) (id int64, err error)

AddRole insert a new Role into database and returns last inserted Id on success

func AddUser

func AddUser(m *User) (id int64, err error)

AddUser insert a new User into database and returns last inserted Id on success.

func DeleteRole

func DeleteRole(id int) (err error)

DeleteRole deletes Role by Id and returns errors if the record to be deleted doesn't exist

func DeleteUser

func DeleteUser(id int) (err error)

DeleteUser deletes User by Id and returns errors if the record to be deleted doesn't exist

func GetAllUser

func GetAllUser(query map[string]string, fields []string, sortby []string, order []string,
	offset int64, limit int64) (ml []interface{}, err error)

GetAllUser retrieves all User matches certain condition. Returns empty list if no records exist

func UpdateRoleById

func UpdateRoleById(m *Role) (err error)

UpdateRoleById updates Role by Id and returns errors if the record to be updated doesn't exist

func UpdateUserById

func UpdateUserById(m *User) (err error)

UpdateUser updates User by Id and returns errors if the record to be updated doesn't exist

Types

type Role

type Role struct {
	Id          int `orm:"column(id);auto"`
	RoleName    string
	Description string
	CreateTime  time.Time
	UpdateTime  time.Time
}

func GetRoleById

func GetRoleById(id int) (v *Role, err error)

GetRoleById retrieves Role by Id. Returns errors if Id doesn't exist

func (*Role) TableName

func (t *Role) TableName() string

type User

type User struct {
	Id         int `orm:"column(id);auto"`
	Username   string
	Password   string
	RealName   string
	Mobile     string
	Email      string
	CreateTime time.Time
	UpdateTime time.Time
}

func GetUserById

func GetUserById(id int) (v *User, err error)

GetUserById retrieves User by Id. Returns errors if Id doesn't exist

func GetUserByUsername

func GetUserByUsername(username string) (user User, exist bool)

GetUserByUsername retrieves User by username. Returns false if user doesn't exist or have multi record

func (*User) TableName

func (t *User) TableName() string

Jump to

Keyboard shortcuts

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