package dto import "joylink.club/bj-rtsts-server/db/model" // 角色创建 type AuthRoleReqDto struct { Id int32 `json:"id" form:"id"` Name string `json:"name" form:"name"` DelPaths []int32 `json:"delPaths" form:"delPaths"` AddPaths []int32 `json:"addPaths" form:"addPaths"` } type AuthRoleRspDto struct { Id int32 `json:"id" form:"id"` Name string `json:"name" form:"name"` } func ConvertFromAuthRole(auths []*model.AuthRole) []*AuthRoleRspDto { var result = make([]*AuthRoleRspDto, len(auths)) for i, a := range auths { result[i] = &AuthRoleRspDto{Id: a.ID, Name: a.Name} } return result } type AuthRoleDetailRspDto struct { Id int32 `json:"id" form:"id"` Name string `json:"name" form:"name"` Paths []*model.AuthAPIPath `json:"paths" form:"paths"` } type AuthApiPathPageReqDto struct { PageQueryDto Name string `json:"name" form:"name"` } type AuthApiPathReqDto struct { Id int32 `json:"id" form:"id"` Name string `json:"name" form:"name"` Path string `json:"path" form:"path"` Method string `json:"method" form:"method"` } type AuthRoleUserReqDto struct { Uid int32 `json:"uid" form:"uid"` AddRids []int32 `json:"addRids" form:"addRids"` DelRids []int32 `json:"delRids" form:"delRids"` } // 角色类型 type AuthRoleType int32 const ( ADMIN AuthRoleType = iota + 1 USER ) func IsSystemRole(role int32) bool { return role == int32(ADMIN) || role == int32(USER) } func GetDefaultAuthRole() *AuthRoleRspDto { return &AuthRoleRspDto{Id: int32(USER), Name: "普通用户"} } type AuthUserStorageDto struct { UID int32 `json:"uid" form:"uid"` IsAdmin bool `json:"isAdmin" form:"isAdmin"` RoleIds []int32 `json:"roleIds" form:"roleIds"` AuthPaths []*AuthPath `json:"authPath" form:"authPath"` } type AuthPath struct { Path string `json:"path" form:"path"` Method string `json:"method" form:"method"` } func ConvertFromAuthPath(paths []*model.AuthAPIPath) []*AuthPath { var result = make([]*AuthPath, len(paths)) for i, a := range paths { result[i] = &AuthPath{Path: a.Path, Method: a.Method} } return result }