refactor, sketch SSE implementation
This commit is contained in:
17
models.go
17
models.go
@@ -8,16 +8,8 @@ import (
|
||||
"ytdlp-site/originals"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Username string `gorm:"unique"`
|
||||
Password string
|
||||
}
|
||||
|
||||
type TempURL struct {
|
||||
Token string `gorm:"uniqueIndex"`
|
||||
FilePath string
|
||||
@@ -37,15 +29,6 @@ type DownloadManager struct {
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
func CreateUser(db *gorm.DB, username, password string) error {
|
||||
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
user := User{Username: username, Password: string(hashedPassword)}
|
||||
if err := db.Create(&user).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetOriginalStatus(id uint, status originals.Status) error {
|
||||
return db.Model(&originals.Original{}).Where("id = ?", id).Update("status", status).Error
|
||||
}
|
||||
|
Reference in New Issue
Block a user