busniess-user-center/internal/models/user/user.go

86 lines
1.7 KiB
Go

package models
import (
appModel "busniess-user-center/internal/models/application"
orgModel "busniess-user-center/internal/models/organization"
roleModel "busniess-user-center/internal/models/role"
)
type UserStatus int
const (
EnableUserStatus UserStatus = 0
DisableUserStatus UserStatus = 1
)
type LoginInfo struct {
Account string
Pwd string
}
type AddInfo struct {
Account string `json:"account" binding:"required"`
Name string `json:"name" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
Email string `json:"email" binding:"required"`
Sex int `json:"sex"`
Pwd string `json:"pwd" binding:"required"`
}
type UserInfo struct {
Account string
Name string
Mobile string
Email string
Sex int
}
type User struct {
Id uint
UserInfo
Roles []roleModel.Role
Orgs []orgModel.Organization
Menus appModel.MenuTree
}
type ModifyInfo struct {
Name string `json:"name" binding:"required"`
Sex int `json:"sex"`
}
type Query struct {
Page int `form:"page" json:"page" `
PageSize int `form:"page_size" json:"page_size"`
Keyword string `form:"keyword" Json:"keyword"`
Sort string `form:"sort" json:"sort" binding:"sql_sort"`
}
type ResetPwdReq struct {
Id uint `json:"id" binding:"required"`
OldPwd string `json:"old_pwd" binding:"required"`
Pwd string `json:"pwd" binding:"required"`
}
type GetUserReq struct {
Account string `form:"account" json:"account" binding:"required"`
AppCode string `form:"app_code" json:"app_code" binding:"required"`
}
func (q *Query) Default() {
if q.Page < 0 {
q.Page = 0
}
if q.PageSize <= 0 {
q.PageSize = 20
}
if len(q.Sort) == 0 {
q.Sort = "created_on desc"
}
}
type Enable struct {
Id uint `json:"id" binding:"required"`
}