mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 01:22:48 +00:00
play sounds from web ui - store uploaded sounds in database
This commit is contained in:
28
server/webserver/model/sound.go
Normal file
28
server/webserver/model/sound.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type Sound struct {
|
||||
ID uint `gorm:"primary_key" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt *time.Time `json:"deleted_at"`
|
||||
Name string `gorm:"unique" json:"name"`
|
||||
Extension string `json:"extension"`
|
||||
UserID string `json:"user_id"`
|
||||
User User `json:"user"`
|
||||
}
|
||||
|
||||
func SoundCreate(conn *gorm.DB, sound *Sound) error {
|
||||
return conn.Create(sound).Error
|
||||
}
|
||||
|
||||
func SoundList(conn *gorm.DB) ([]Sound, error) {
|
||||
sound := []Sound{}
|
||||
err := conn.Set("gorm:auto_preload", true).Find(&sound).Error
|
||||
return sound, err
|
||||
}
|
||||
Reference in New Issue
Block a user