package v1 import "github.com/gogf/gf/v2/frame/g" // AdminItem is one row of the admin list. type AdminItem struct { Id uint64 `json:"id"` Username string `json:"username"` Nickname string `json:"nickname"` Status int `json:"status"` RoleIds []uint64 `json:"roleIds"` RoleNames []string `json:"roleNames"` CreatedAt string `json:"createdAt"` } // AdminListReq pages the administrators. type AdminListReq struct { g.Meta `path:"/admins" method:"get" tags:"Admin/Admin" summary:"Admin list"` Page int `json:"page" d:"1" v:"min:1"` Size int `json:"size" d:"10" v:"min:1|max:100"` Keyword string `json:"keyword"` // matches username or nickname } // AdminListRes is the response of AdminListReq. type AdminListRes struct { List []*AdminItem `json:"list"` Total int `json:"total"` } // AdminCreateReq creates an administrator. type AdminCreateReq struct { g.Meta `path:"/admins" method:"post" tags:"Admin/Admin" summary:"Create admin"` Username string `json:"username" v:"required"` Password string `json:"password" v:"required|min-length:6#password required|password too short"` Nickname string `json:"nickname"` RoleIds []uint64 `json:"roleIds"` } // AdminCreateRes is the response of AdminCreateReq. type AdminCreateRes struct { Id uint64 `json:"id"` } // AdminUpdateReq updates profile/status/roles of an administrator. type AdminUpdateReq struct { g.Meta `path:"/admins/{id}" method:"put" tags:"Admin/Admin" summary:"Update admin"` Id uint64 `json:"id" in:"path" v:"required"` Nickname string `json:"nickname"` Status int `json:"status"` RoleIds []uint64 `json:"roleIds"` } // AdminUpdateRes is the response of AdminUpdateReq. type AdminUpdateRes struct{} // AdminResetPwdReq resets an administrator's password. type AdminResetPwdReq struct { g.Meta `path:"/admins/{id}/password" method:"put" tags:"Admin/Admin" summary:"Reset admin password"` Id uint64 `json:"id" in:"path" v:"required"` Password string `json:"password" v:"required|min-length:6#password required|password too short"` } // AdminResetPwdRes is the response of AdminResetPwdReq. type AdminResetPwdRes struct{} // AdminDeleteReq deletes an administrator (soft delete). type AdminDeleteReq struct { g.Meta `path:"/admins/{id}" method:"delete" tags:"Admin/Admin" summary:"Delete admin"` Id uint64 `json:"id" in:"path" v:"required"` } // AdminDeleteRes is the response of AdminDeleteReq. type AdminDeleteRes struct{}