34 lines
890 B
Go
34 lines
890 B
Go
package permission
|
|
|
|
import (
|
|
domusecase "haixun-backend/internal/model/permission/domain/usecase"
|
|
"haixun-backend/internal/types"
|
|
)
|
|
|
|
func toPermissionNode(node domusecase.PermissionNode) types.PermissionNode {
|
|
out := types.PermissionNode{
|
|
ID: node.ID,
|
|
Parent: node.Parent,
|
|
Name: node.Name,
|
|
HTTPMethods: node.HTTPMethods,
|
|
HTTPPath: node.HTTPPath,
|
|
Status: node.Status,
|
|
Type: node.Type,
|
|
}
|
|
if len(node.Children) > 0 {
|
|
out.Children = make([]types.PermissionNode, 0, len(node.Children))
|
|
for _, child := range node.Children {
|
|
out.Children = append(out.Children, toPermissionNode(child))
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func toPermissionNodes(nodes []domusecase.PermissionNode) []types.PermissionNode {
|
|
out := make([]types.PermissionNode, 0, len(nodes))
|
|
for _, node := range nodes {
|
|
out = append(out, toPermissionNode(node))
|
|
}
|
|
return out
|
|
}
|