|
|
@ -20,6 +20,7 @@ type MatterService struct { |
|
|
Bean |
|
|
Bean |
|
|
matterDao *MatterDao |
|
|
matterDao *MatterDao |
|
|
userDao *UserDao |
|
|
userDao *UserDao |
|
|
|
|
|
imageCacheDao *ImageCacheDao |
|
|
imageCacheService *ImageCacheService |
|
|
imageCacheService *ImageCacheService |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -38,6 +39,11 @@ func (this *MatterService) Init() { |
|
|
this.userDao = b |
|
|
this.userDao = b |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = CONTEXT.GetBean(this.imageCacheDao) |
|
|
|
|
|
if b, ok := b.(*ImageCacheDao); ok { |
|
|
|
|
|
this.imageCacheDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
b = CONTEXT.GetBean(this.imageCacheService) |
|
|
b = CONTEXT.GetBean(this.imageCacheService) |
|
|
if b, ok := b.(*ImageCacheService); ok { |
|
|
if b, ok := b.(*ImageCacheService); ok { |
|
|
this.imageCacheService = b |
|
|
this.imageCacheService = b |
|
|
@ -644,7 +650,6 @@ func (this *MatterService) adjustPath(matter *Matter, parentMatter *Matter) { |
|
|
|
|
|
|
|
|
//调整该文件夹下文件的Path.
|
|
|
//调整该文件夹下文件的Path.
|
|
|
matters := this.matterDao.List(matter.Uuid, matter.UserUuid, nil) |
|
|
matters := this.matterDao.List(matter.Uuid, matter.UserUuid, nil) |
|
|
|
|
|
|
|
|
for _, m := range matters { |
|
|
for _, m := range matters { |
|
|
this.adjustPath(m, matter) |
|
|
this.adjustPath(m, matter) |
|
|
} |
|
|
} |
|
|
@ -652,9 +657,12 @@ func (this *MatterService) adjustPath(matter *Matter, parentMatter *Matter) { |
|
|
} else { |
|
|
} else { |
|
|
//如果源是普通文件
|
|
|
//如果源是普通文件
|
|
|
|
|
|
|
|
|
|
|
|
//删除该文件的所有缓存
|
|
|
|
|
|
this.imageCacheDao.DeleteByMatterUuid(matter.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//调整path
|
|
|
matter.Path = parentMatter.Path + "/" + matter.Name |
|
|
matter.Path = parentMatter.Path + "/" + matter.Name |
|
|
matter = this.matterDao.Save(matter) |
|
|
matter = this.matterDao.Save(matter) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -671,6 +679,7 @@ func (this *MatterService) Move(srcMatter *Matter, destMatter *Matter) { |
|
|
destAbsolutePath := destMatter.AbsolutePath() + "/" + srcMatter.Name |
|
|
destAbsolutePath := destMatter.AbsolutePath() + "/" + srcMatter.Name |
|
|
srcAbsolutePath := srcMatter.AbsolutePath() |
|
|
srcAbsolutePath := srcMatter.AbsolutePath() |
|
|
|
|
|
|
|
|
|
|
|
//物理文件一口气移动
|
|
|
err := os.Rename(srcAbsolutePath, destAbsolutePath) |
|
|
err := os.Rename(srcAbsolutePath, destAbsolutePath) |
|
|
this.PanicError(err) |
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
@ -681,8 +690,6 @@ func (this *MatterService) Move(srcMatter *Matter, destMatter *Matter) { |
|
|
|
|
|
|
|
|
//调整该文件夹下文件的Path.
|
|
|
//调整该文件夹下文件的Path.
|
|
|
matters := this.matterDao.List(srcMatter.Uuid, srcMatter.UserUuid, nil) |
|
|
matters := this.matterDao.List(srcMatter.Uuid, srcMatter.UserUuid, nil) |
|
|
|
|
|
|
|
|
//调整该文件夹下面所有文件的Path值
|
|
|
|
|
|
for _, m := range matters { |
|
|
for _, m := range matters { |
|
|
this.adjustPath(m, srcMatter) |
|
|
this.adjustPath(m, srcMatter) |
|
|
} |
|
|
} |
|
|
@ -693,11 +700,12 @@ func (this *MatterService) Move(srcMatter *Matter, destMatter *Matter) { |
|
|
destAbsolutePath := destMatter.AbsolutePath() + "/" + srcMatter.Name |
|
|
destAbsolutePath := destMatter.AbsolutePath() + "/" + srcMatter.Name |
|
|
srcAbsolutePath := srcMatter.AbsolutePath() |
|
|
srcAbsolutePath := srcMatter.AbsolutePath() |
|
|
|
|
|
|
|
|
|
|
|
//物理文件进行移动
|
|
|
err := os.Rename(srcAbsolutePath, destAbsolutePath) |
|
|
err := os.Rename(srcAbsolutePath, destAbsolutePath) |
|
|
this.PanicError(err) |
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
//删除对应的缓存。
|
|
|
//删除对应的缓存。
|
|
|
this.imageCacheService.Delete(srcMatter) |
|
|
this.imageCacheDao.DeleteByMatterUuid(srcMatter.Uuid) |
|
|
|
|
|
|
|
|
//修改数据库中信息
|
|
|
//修改数据库中信息
|
|
|
srcMatter.Puuid = destMatter.Uuid |
|
|
srcMatter.Puuid = destMatter.Uuid |
|
|
@ -708,3 +716,54 @@ func (this *MatterService) Move(srcMatter *Matter, destMatter *Matter) { |
|
|
|
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将一个srcMatter 重命名为 name
|
|
|
|
|
|
func (this *MatterService) Rename(srcMatter *Matter, name string) { |
|
|
|
|
|
|
|
|
|
|
|
if srcMatter.Dir { |
|
|
|
|
|
//如果源是文件夹
|
|
|
|
|
|
|
|
|
|
|
|
oldAbsolutePath := srcMatter.AbsolutePath() |
|
|
|
|
|
absoluteDirPath := GetDirOfPath(oldAbsolutePath) |
|
|
|
|
|
relativeDirPath := GetDirOfPath(srcMatter.Path) |
|
|
|
|
|
newAbsolutePath := absoluteDirPath + "/" + name |
|
|
|
|
|
|
|
|
|
|
|
//物理文件一口气移动
|
|
|
|
|
|
err := os.Rename(oldAbsolutePath, newAbsolutePath) |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
|
|
|
//修改数据库中信息
|
|
|
|
|
|
srcMatter.Name = name |
|
|
|
|
|
srcMatter.Path = relativeDirPath + "/" + name |
|
|
|
|
|
srcMatter = this.matterDao.Save(srcMatter) |
|
|
|
|
|
|
|
|
|
|
|
//调整该文件夹下文件的Path.
|
|
|
|
|
|
matters := this.matterDao.List(srcMatter.Uuid, srcMatter.UserUuid, nil) |
|
|
|
|
|
for _, m := range matters { |
|
|
|
|
|
this.adjustPath(m, srcMatter) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
//如果源是普通文件
|
|
|
|
|
|
|
|
|
|
|
|
oldAbsolutePath := srcMatter.AbsolutePath() |
|
|
|
|
|
absoluteDirPath := GetDirOfPath(oldAbsolutePath) |
|
|
|
|
|
relativeDirPath := GetDirOfPath(srcMatter.Path) |
|
|
|
|
|
newAbsolutePath := absoluteDirPath + "/" + name |
|
|
|
|
|
|
|
|
|
|
|
//物理文件进行移动
|
|
|
|
|
|
err := os.Rename(oldAbsolutePath, newAbsolutePath) |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
|
|
|
//删除对应的缓存。
|
|
|
|
|
|
this.imageCacheDao.DeleteByMatterUuid(srcMatter.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//修改数据库中信息
|
|
|
|
|
|
srcMatter.Name = name |
|
|
|
|
|
srcMatter.Path = relativeDirPath + "/" + name |
|
|
|
|
|
srcMatter = this.matterDao.Save(srcMatter) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|