rts-sim-testing-service/dto/auth.go
2023-08-30 09:28:21 +08:00

76 lines
1.9 KiB
Go

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
USER
)
type AuthUserStorageDto struct {
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
}