mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-05-22 02:45:20 +08:00
refactor: 后端包结构重构、去除无用的文件
This commit is contained in:
26
server/internal/sys/api/vo/account.go
Normal file
26
server/internal/sys/api/vo/account.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"mayfly-go/pkg/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AccountManageVO struct {
|
||||
model.Model
|
||||
Username *string `json:"username"`
|
||||
Status int `json:"status"`
|
||||
LastLoginTime *time.Time `json:"lastLoginTime"`
|
||||
}
|
||||
|
||||
// 账号角色信息
|
||||
type AccountRoleVO struct {
|
||||
Name *string `json:"name"`
|
||||
Status int `json:"status"`
|
||||
CreateTime *time.Time `json:"createTime"`
|
||||
Creator string `json:"creator"`
|
||||
}
|
||||
|
||||
// 账号个人信息
|
||||
type AccountPersonVO struct {
|
||||
Roles []AccountRoleVO `json:"roles"` // 角色信息
|
||||
}
|
||||
92
server/internal/sys/api/vo/resource.go
Normal file
92
server/internal/sys/api/vo/resource.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package vo
|
||||
|
||||
import "time"
|
||||
|
||||
type AccountResourceVO struct {
|
||||
Id int `json:"id"`
|
||||
Pid int `json:"pid"`
|
||||
Name *string `json:"name"`
|
||||
Code *string `json:"code"`
|
||||
Type int8 `json:"type"`
|
||||
Meta string `json:"meta"`
|
||||
}
|
||||
|
||||
// 账号拥有的资源vo
|
||||
type AccountResourceVOList []AccountResourceVO
|
||||
|
||||
type resourceItem struct {
|
||||
AccountResourceVO
|
||||
Children []resourceItem `json:"children"`
|
||||
}
|
||||
|
||||
func (m *AccountResourceVOList) ToTrees(pid int) []resourceItem {
|
||||
var resourceTree []resourceItem
|
||||
|
||||
list := m.findChildren(pid)
|
||||
if len(list) == 0 {
|
||||
return resourceTree
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
Children := m.ToTrees(int(v.Id))
|
||||
resourceTree = append(resourceTree, resourceItem{v, Children})
|
||||
}
|
||||
|
||||
return resourceTree
|
||||
}
|
||||
|
||||
func (m *AccountResourceVOList) findChildren(pid int) []AccountResourceVO {
|
||||
child := []AccountResourceVO{}
|
||||
|
||||
for _, v := range *m {
|
||||
if v.Pid == pid {
|
||||
child = append(child, v)
|
||||
}
|
||||
}
|
||||
return child
|
||||
}
|
||||
|
||||
// 系统管理/资源管理
|
||||
type ResourceManageVO struct {
|
||||
Id int `json:"id"`
|
||||
Pid int `json:"pid"`
|
||||
Name string `json:"name"`
|
||||
Type int `json:"type"`
|
||||
Status int `json:"status"`
|
||||
Creator string `json:"creator"`
|
||||
CreateTime *time.Time `json:"createTime"`
|
||||
}
|
||||
|
||||
type ResourceManageVOList []ResourceManageVO
|
||||
|
||||
type resourceManageItem struct {
|
||||
ResourceManageVO
|
||||
Children []resourceManageItem `json:"children"`
|
||||
}
|
||||
|
||||
func (m *ResourceManageVOList) ToTrees(pid int) []resourceManageItem {
|
||||
var resourceTree []resourceManageItem
|
||||
|
||||
list := m.findChildren(pid)
|
||||
if len(list) == 0 {
|
||||
return resourceTree
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
Children := m.ToTrees(int(v.Id))
|
||||
resourceTree = append(resourceTree, resourceManageItem{v, Children})
|
||||
}
|
||||
|
||||
return resourceTree
|
||||
}
|
||||
|
||||
func (m *ResourceManageVOList) findChildren(pid int) []ResourceManageVO {
|
||||
child := []ResourceManageVO{}
|
||||
|
||||
for _, v := range *m {
|
||||
if v.Pid == pid {
|
||||
child = append(child, v)
|
||||
}
|
||||
}
|
||||
return child
|
||||
}
|
||||
Reference in New Issue
Block a user