mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: generate share URL
This commit is contained in:
@@ -28,6 +28,7 @@ type GroupOption struct {
|
||||
ArchiveDownloadEnabled bool `json:"archive_download"`
|
||||
ArchiveTaskEnabled bool `json:"archive_task"`
|
||||
OneTimeDownloadEnabled bool `json:"one_time_download"`
|
||||
ShareDownloadEnabled bool `json:"share_download"`
|
||||
}
|
||||
|
||||
// GetAria2Option 获取用户离线下载设备
|
||||
|
||||
@@ -29,7 +29,7 @@ func migration() {
|
||||
if conf.DatabaseConfig.Type == "mysql" {
|
||||
DB = DB.Set("gorm:table_options", "ENGINE=InnoDB")
|
||||
}
|
||||
DB.AutoMigrate(&User{}, &Setting{}, &Group{}, &Policy{}, &Folder{}, &File{}, &StoragePack{})
|
||||
DB.AutoMigrate(&User{}, &Setting{}, &Group{}, &Policy{}, &Folder{}, &File{}, &StoragePack{}, &Share{})
|
||||
|
||||
// 创建初始存储策略
|
||||
addDefaultPolicy()
|
||||
@@ -161,6 +161,8 @@ Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; verti
|
||||
{Name: "task_queue_token", Value: ``, Type: "task"},
|
||||
{Name: "secret_key", Value: util.RandStringRunes(256), Type: "auth"},
|
||||
{Name: "temp_path", Value: "temp", Type: "path"},
|
||||
{Name: "score_enabled", Value: "1", Type: "score"},
|
||||
{Name: "share_score_rate", Value: "80", Type: "score"},
|
||||
}
|
||||
|
||||
for _, value := range defaultSettings {
|
||||
|
||||
31
models/share.go
Normal file
31
models/share.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/jinzhu/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Share 分享模型
|
||||
type Share struct {
|
||||
gorm.Model
|
||||
Password string // 分享密码,空值为非加密分享
|
||||
IsDir bool // 原始资源是否为目录
|
||||
UserID uint // 创建用户ID
|
||||
SourceID uint // 原始资源ID
|
||||
Views int // 浏览数
|
||||
Downloads int // 下载数
|
||||
RemainDownloads int // 剩余下载配额,负值标识无限制
|
||||
Expires *time.Time // 过期时间,空值表示无过期时间
|
||||
Score int // 每人次下载扣除积分
|
||||
}
|
||||
|
||||
// Create 创建分享
|
||||
// TODO 测试
|
||||
func (share *Share) Create() (uint, error) {
|
||||
if err := DB.Create(share).Error; err != nil {
|
||||
util.Log().Warning("无法插入数据库记录, %s", err)
|
||||
return 0, err
|
||||
}
|
||||
return share.ID, nil
|
||||
}
|
||||
Reference in New Issue
Block a user