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

98 lines
1.9 KiB
Go

package role
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"`
}
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 CreateReq struct {
Code string `json:"code" binding:"required"`
Name string `json:"name" binding:"required"`
}
type SaveReq struct {
Id uint `json:"id" binding:"required"`
Name string `json:"name" binding:"required"`
Code string `json:"code" binding:"required"`
}
type DelReq struct {
Id uint `json:"id" binding:"required"`
}
type GetReq struct {
Id uint `form:"id" json:"id" binding:"required"`
}
type AddUsersReq struct {
RoleId uint `json:"role_id"`
Ids []uint `json:"ids"`
}
type RemoveUsersReq struct {
Ids []uint `json:"ids"`
RoleId uint `json:"role_id"`
}
type OrgAuthorRoleType int
const (
ExcludeChildrenOrgAuthor OrgAuthorRoleType = 0
IncludeChildrenOrgAuthor OrgAuthorRoleType = 1
)
type OrgAuthorBrief struct {
Id uint `json:"id" binding:"required"`
Type OrgAuthorRoleType `json:"type"`
}
type AddOrgsReq struct {
Orgs []OrgAuthorBrief `json:"orgs"`
RoleId uint `json:"role_id"`
}
type RemoveOrgsReq struct {
Ids []uint `json:"ids"`
RoleId uint `json:"role_id"`
}
type RoleUsersReq struct {
Id uint `json:"id" binding:"required"`
Query
}
type RoleOrgsReq struct {
Id uint `json:"id" binding:"required"`
Query
}
type AuthorRoleMenuReq struct {
AppCode string `json:"app_code" binding:"required"`
Ids []uint `json:"ids" binding:"required"`
}
type RemoveReleMenuReq struct {
Ids []uint `json:"ids"`
}
type RoleMenuListReq struct {
AppCode string `json:"app_code" binding:"required"`
RoleId uint `json:"role_id" binding:"required"`
}