This commit is contained in:
12600k-rog-d4
2025-12-09 20:33:57 +08:00
parent 144ed3cbdf
commit 8f4d399cfd
1498 changed files with 3778 additions and 3654 deletions

View File

@@ -0,0 +1,37 @@
package render
import "bbs-go/internal/models"
func BuildDict(element models.Dict) models.DictResponse {
item := models.DictResponse{
Id: element.Id,
TypeId: element.TypeId,
Name: element.Name,
Label: element.Label,
Value: element.Value,
SortNo: element.SortNo,
Status: element.Status,
CreateTime: element.CreateTime,
UpdateTime: element.UpdateTime,
}
if element.ParentId > 0 {
item.ParentId = &element.ParentId
}
return item
}
func BuildDictTree(parentId int64, list []models.Dict) (ret []models.DictListResponse) {
for _, element := range list {
if element.ParentId == parentId {
item := models.DictListResponse{
DictResponse: BuildDict(element),
Children: BuildDictTree(element.Id, list),
}
ret = append(ret, item)
}
}
if len(ret) == 0 {
return
}
return
}