Finish some move things.

This commit is contained in:
zicla
2019-04-10 00:26:32 +08:00
parent 5936f917b3
commit 7f7fba0425
5 changed files with 160 additions and 27 deletions

View File

@ -16,6 +16,7 @@ type ImageCacheService struct {
Bean
imageCacheDao *ImageCacheDao
userDao *UserDao
matterDao *MatterDao
}
//初始化方法
@ -33,6 +34,11 @@ func (this *ImageCacheService) Init() {
this.userDao = b
}
b = CONTEXT.GetBean(this.matterDao)
if b, ok := b.(*MatterDao); ok {
this.matterDao = b
}
}
//获取某个文件的详情,会把父级依次倒着装进去。如果中途出错,直接抛出异常。
@ -234,3 +240,21 @@ func (this *ImageCacheService) cacheImage(writer http.ResponseWriter, request *h
return imageCache
}
//删除一个Matter的所有缓存文件。如果matter是文件夹那么就删除该文件夹下的所有文件的缓存文件。
func (this *ImageCacheService) Delete(matter *Matter) {
//目录的话递归删除。
if matter.Dir {
matters := this.matterDao.List(matter.Uuid, matter.UserUuid, nil)
for _, f := range matters {
this.Delete(f)
}
} else {
this.imageCacheDao.DeleteByMatterUuid(matter.Uuid)
}
}