|
|
|
@ -391,11 +391,6 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
|
|
|
|
|
return serializer.Err(serializer.CodeNotFound, "对象不存在", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果对象是目录, 先尝试返回缓存结果
|
|
|
|
|
if cacheRes, ok := cache.Get(fmt.Sprintf("folder_props_%d", res)); ok {
|
|
|
|
|
return serializer.Response{Data: cacheRes.(serializer.ObjectProps)}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
folder, err := model.GetFoldersByIDs([]uint{res}, user.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return serializer.DBErr("找不到目录", err)
|
|
|
|
@ -404,6 +399,14 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
|
|
|
|
|
props.CreatedAt = folder[0].CreatedAt
|
|
|
|
|
props.UpdatedAt = folder[0].UpdatedAt
|
|
|
|
|
|
|
|
|
|
// 如果对象是目录, 先尝试返回缓存结果
|
|
|
|
|
if cacheRes, ok := cache.Get(fmt.Sprintf("folder_props_%d", res)); ok {
|
|
|
|
|
res := cacheRes.(serializer.ObjectProps)
|
|
|
|
|
res.CreatedAt = props.CreatedAt
|
|
|
|
|
res.UpdatedAt = props.UpdatedAt
|
|
|
|
|
return serializer.Response{Data: res}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 统计子目录
|
|
|
|
|
childFolders, err := model.GetRecursiveChildFolder([]uint{folder[0].ID},
|
|
|
|
|
user.ID, true)
|
|
|
|
|