1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tree.go 751 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2024-01-31 17:14 . 添加相册树结构
package xalbum
// 相册树
type TreeAlbumn struct {
Id uint `json:"id" form:"id" xml:"id"` // 相册ID
Label string `json:"label" form:"label" xml:"label"` // 相册名称
Child []TreeAlbumn `json:"children" form:"children" xml:"children"` // 子相册列表
}
// 获取相册目录树
func Tree(uid uint, fid uint) ([]TreeAlbumn, error) {
fids := []TreeAlbumn{}
lis, err := List(uid, fid)
if err != nil {
return nil, err
}
if len(lis) == 0 {
return fids, nil
}
for i := 0; i < len(lis); i++ {
childs, err := Tree(uid, lis[i].Id)
if err != nil {
continue
}
fids = append(fids, TreeAlbumn{
Id: lis[i].Id,
Label: lis[i].Name,
Child: childs,
})
}
return fids, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.15

搜索帮助

344bd9b3 5694891 D2dac590 5694891