Feat: download file from single file share

This commit is contained in:
HFO4
2020-01-28 12:41:00 +08:00
parent 0977b36f8b
commit 7f0feebf42
13 changed files with 199 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ type User struct {
Avatar string
Options string `json:"-",gorm:"size:4096"`
Authn string `gorm:"size:8192"`
Score int
// 关联模型
Group Group `gorm:"association_autoupdate:false"`
@@ -93,6 +94,20 @@ func (user *User) IncreaseStorage(size uint64) bool {
return false
}
// PayScore 扣除积分,返回是否成功
// todo 测试
func (user *User) PayScore(score int) bool {
if score == 0 {
return true
}
if score <= user.Score {
user.Score -= score
DB.Model(user).UpdateColumn("score", gorm.Expr("score - ?", score))
return true
}
return false
}
// IncreaseStorageWithoutCheck 忽略可用容量,增加用户已用容量
func (user *User) IncreaseStorageWithoutCheck(size uint64) {
if size == 0 {