|
|
@ -7,6 +7,7 @@ import ( |
|
|
"github.com/eyebluecn/tank/code/tool/util" |
|
|
"github.com/eyebluecn/tank/code/tool/util" |
|
|
gouuid "github.com/nu7hatch/gouuid" |
|
|
gouuid "github.com/nu7hatch/gouuid" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
"os" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
@ -18,6 +19,15 @@ type UserService struct { |
|
|
|
|
|
|
|
|
//file lock
|
|
|
//file lock
|
|
|
locker *cache.Table |
|
|
locker *cache.Table |
|
|
|
|
|
|
|
|
|
|
|
matterDao *MatterDao |
|
|
|
|
|
matterService *MatterService |
|
|
|
|
|
imageCacheDao *ImageCacheDao |
|
|
|
|
|
shareDao *ShareDao |
|
|
|
|
|
shareService *ShareService |
|
|
|
|
|
downloadTokenDao *DownloadTokenDao |
|
|
|
|
|
uploadTokenDao *UploadTokenDao |
|
|
|
|
|
footprintDao *FootprintDao |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (this *UserService) Init() { |
|
|
func (this *UserService) Init() { |
|
|
@ -33,6 +43,41 @@ func (this *UserService) Init() { |
|
|
this.sessionDao = b |
|
|
this.sessionDao = b |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.matterDao) |
|
|
|
|
|
if b, ok := b.(*MatterDao); ok { |
|
|
|
|
|
this.matterDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.matterService) |
|
|
|
|
|
if b, ok := b.(*MatterService); ok { |
|
|
|
|
|
this.matterService = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.imageCacheDao) |
|
|
|
|
|
if b, ok := b.(*ImageCacheDao); ok { |
|
|
|
|
|
this.imageCacheDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.shareService) |
|
|
|
|
|
if b, ok := b.(*ShareService); ok { |
|
|
|
|
|
this.shareService = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.downloadTokenDao) |
|
|
|
|
|
if b, ok := b.(*DownloadTokenDao); ok { |
|
|
|
|
|
this.downloadTokenDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.uploadTokenDao) |
|
|
|
|
|
if b, ok := b.(*UploadTokenDao); ok { |
|
|
|
|
|
this.uploadTokenDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b = core.CONTEXT.GetBean(this.footprintDao) |
|
|
|
|
|
if b, ok := b.(*FootprintDao); ok { |
|
|
|
|
|
this.footprintDao = b |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//create a lock cache.
|
|
|
//create a lock cache.
|
|
|
this.locker = cache.NewTable() |
|
|
this.locker = cache.NewTable() |
|
|
} |
|
|
} |
|
|
@ -187,3 +232,49 @@ func (this *UserService) RemoveCacheUserByUuid(userUuid string) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//delete user
|
|
|
|
|
|
func (this *UserService) DeleteUser(request *http.Request, currentUser *User) { |
|
|
|
|
|
|
|
|
|
|
|
//delete from cache
|
|
|
|
|
|
this.logger.Info("delete from cache userUuid = %s", currentUser.Uuid) |
|
|
|
|
|
this.RemoveCacheUserByUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete download tokens
|
|
|
|
|
|
this.logger.Info("delete download tokens") |
|
|
|
|
|
this.downloadTokenDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete upload tokens
|
|
|
|
|
|
this.logger.Info("delete upload tokens") |
|
|
|
|
|
this.uploadTokenDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete footprints
|
|
|
|
|
|
this.logger.Info("delete footprints") |
|
|
|
|
|
this.footprintDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete session
|
|
|
|
|
|
this.logger.Info("delete session") |
|
|
|
|
|
this.sessionDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete shares and bridges
|
|
|
|
|
|
this.logger.Info("elete shares and bridges") |
|
|
|
|
|
this.shareService.DeleteSharesByUser(request, currentUser) |
|
|
|
|
|
|
|
|
|
|
|
//delete caches
|
|
|
|
|
|
this.logger.Info("delete caches") |
|
|
|
|
|
this.imageCacheDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete matters
|
|
|
|
|
|
this.logger.Info("delete matters") |
|
|
|
|
|
this.matterDao.DeleteByUserUuid(currentUser.Uuid) |
|
|
|
|
|
|
|
|
|
|
|
//delete this user
|
|
|
|
|
|
this.logger.Info("delete this user.") |
|
|
|
|
|
this.userDao.Delete(currentUser) |
|
|
|
|
|
|
|
|
|
|
|
//delete files from disk.
|
|
|
|
|
|
this.logger.Info("delete files from disk. %s", GetUserSpaceRootDir(currentUser.Username)) |
|
|
|
|
|
err := os.RemoveAll(GetUserSpaceRootDir(currentUser.Username)) |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|