mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: download file from single file share
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user