Documentation ¶
Index ¶
- Constants
- func ChangePass(id, oldPass, newPass string) (code int, err error)
- func IncTotalUserCount(t time.Time) error
- type CodeInfo
- type LoginForm
- type LoginInfo
- type LogoutForm
- type PasswdForm
- type RegisterForm
- type Role
- type RoleAuthForm
- type RoleAuthInfo
- type RoleGetAllInfo
- type RoleGetOneInfo
- type RolePostForm
- type RolePostInfo
- type RolePutForm
- type RolePutInfo
- type UploadsForm
- type User
Constants ¶
const ( ErrDatabase = -1 ErrSystem = -2 ErrDupRows = -3 ErrNotFound = -4 )
Predefined model error codes.
Variables ¶
This section is empty.
Functions ¶
func ChangePass ¶
ChangePass update password and salt information according to input id.
func IncTotalUserCount ¶
IncTotalUserCount increase user count in redis.
Types ¶
type CodeInfo ¶
CodeInfo definiton.
func NewErrorInfo ¶
NewErrorInfo return a CodeInfo represents error.
func NewNormalInfo ¶
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 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) DeleteByID ¶
DeleteByID delete a record accroding to input id.
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 ¶
RolePutForm 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.