1. 需求确认
2. 结构的一些变更
This commit is contained in:
@@ -2,48 +2,56 @@ package model
|
||||
|
||||
// CreateAccountRequest 创建账号请求
|
||||
type CreateAccountRequest struct {
|
||||
Username string `json:"username" validate:"required,min=3,max=50"`
|
||||
Phone string `json:"phone" validate:"required,len=11"`
|
||||
Password string `json:"password" validate:"required,min=8,max=32"`
|
||||
UserType int `json:"user_type" validate:"required,min=1,max=4"`
|
||||
ShopID *uint `json:"shop_id"`
|
||||
ParentID *uint `json:"parent_id"`
|
||||
Username string `json:"username" validate:"required,min=3,max=50" required:"true" minLength:"3" maxLength:"50" description:"用户名"`
|
||||
Phone string `json:"phone" validate:"required,len=11" required:"true" minLength:"11" maxLength:"11" description:"手机号"`
|
||||
Password string `json:"password" validate:"required,min=8,max=32" required:"true" minLength:"8" maxLength:"32" description:"密码"`
|
||||
UserType int `json:"user_type" validate:"required,min=1,max=4" required:"true" minimum:"1" maximum:"4" description:"用户类型 (1:Root, 2:Admin, 3:Agent, 4:Merchant)"`
|
||||
ShopID *uint `json:"shop_id" description:"关联店铺ID"`
|
||||
ParentID *uint `json:"parent_id" description:"父账号ID"`
|
||||
}
|
||||
|
||||
// UpdateAccountRequest 更新账号请求
|
||||
type UpdateAccountRequest struct {
|
||||
Username *string `json:"username" validate:"omitempty,min=3,max=50"`
|
||||
Phone *string `json:"phone" validate:"omitempty,len=11"`
|
||||
Password *string `json:"password" validate:"omitempty,min=8,max=32"`
|
||||
Status *int `json:"status" validate:"omitempty,min=0,max=1"`
|
||||
Username *string `json:"username" validate:"omitempty,min=3,max=50" minLength:"3" maxLength:"50" description:"用户名"`
|
||||
Phone *string `json:"phone" validate:"omitempty,len=11" minLength:"11" maxLength:"11" description:"手机号"`
|
||||
Password *string `json:"password" validate:"omitempty,min=8,max=32" minLength:"8" maxLength:"32" description:"密码"`
|
||||
Status *int `json:"status" validate:"omitempty,min=0,max=1" minimum:"0" maximum:"1" description:"状态 (0:禁用, 1:启用)"`
|
||||
}
|
||||
|
||||
// AccountListRequest 账号列表查询请求
|
||||
type AccountListRequest struct {
|
||||
Page int `json:"page" query:"page" validate:"omitempty,min=1"`
|
||||
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100"`
|
||||
Username string `json:"username" query:"username" validate:"omitempty,max=50"`
|
||||
Phone string `json:"phone" query:"phone" validate:"omitempty,max=20"`
|
||||
UserType *int `json:"user_type" query:"user_type" validate:"omitempty,min=1,max=4"`
|
||||
Status *int `json:"status" query:"status" validate:"omitempty,min=0,max=1"`
|
||||
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
||||
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量"`
|
||||
Username string `json:"username" query:"username" validate:"omitempty,max=50" maxLength:"50" description:"用户名模糊查询"`
|
||||
Phone string `json:"phone" query:"phone" validate:"omitempty,max=20" maxLength:"20" description:"手机号模糊查询"`
|
||||
UserType *int `json:"user_type" query:"user_type" validate:"omitempty,min=1,max=4" minimum:"1" maximum:"4" description:"用户类型"`
|
||||
Status *int `json:"status" query:"status" validate:"omitempty,min=0,max=1" minimum:"0" maximum:"1" description:"状态"`
|
||||
}
|
||||
|
||||
// AccountResponse 账号响应
|
||||
type AccountResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Phone string `json:"phone"`
|
||||
UserType int `json:"user_type"`
|
||||
ShopID *uint `json:"shop_id,omitempty"`
|
||||
ParentID *uint `json:"parent_id,omitempty"`
|
||||
Status int `json:"status"`
|
||||
Creator uint `json:"creator"`
|
||||
Updater uint `json:"updater"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
ID uint `json:"id" description:"账号ID"`
|
||||
Username string `json:"username" description:"用户名"`
|
||||
Phone string `json:"phone" description:"手机号"`
|
||||
UserType int `json:"user_type" description:"用户类型"`
|
||||
ShopID *uint `json:"shop_id,omitempty" description:"关联店铺ID"`
|
||||
ParentID *uint `json:"parent_id,omitempty" description:"父账号ID"`
|
||||
Status int `json:"status" description:"状态"`
|
||||
Creator uint `json:"creator" description:"创建人ID"`
|
||||
Updater uint `json:"updater" description:"更新人ID"`
|
||||
CreatedAt string `json:"created_at" description:"创建时间"`
|
||||
UpdatedAt string `json:"updated_at" description:"更新时间"`
|
||||
}
|
||||
|
||||
// AssignRolesRequest 分配角色请求
|
||||
type AssignRolesRequest struct {
|
||||
RoleIDs []uint `json:"role_ids" validate:"required,min=1"`
|
||||
RoleIDs []uint `json:"role_ids" validate:"required,min=1" required:"true" minItems:"1" description:"角色ID列表"`
|
||||
}
|
||||
|
||||
// AccountPageResult 账号分页响应
|
||||
type AccountPageResult struct {
|
||||
Items []AccountResponse `json:"items" description:"账号列表"`
|
||||
Total int64 `json:"total" description:"总记录数"`
|
||||
Page int `json:"page" description:"当前页码"`
|
||||
Size int `json:"size" description:"每页数量"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user