feat: file uploads
This commit is contained in:
12
server/internal/models/file.go
Normal file
12
server/internal/models/file.go
Normal file
@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
type File struct {
|
||||
ID uint32 `gorm:"primaryKey"`
|
||||
|
||||
Name string
|
||||
Data []byte
|
||||
|
||||
// User
|
||||
UserID uint
|
||||
User User
|
||||
}
|
@ -1,8 +1,32 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
userv1 "github.com/spotdemo4/trevstack/server/internal/services/user/v1"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uint32 `gorm:"primaryKey"`
|
||||
|
||||
Username string
|
||||
Password string
|
||||
|
||||
// Profile picture
|
||||
ProfilePictureID *uint
|
||||
ProfilePicture *File
|
||||
}
|
||||
|
||||
func (u User) ToConnectV1() *userv1.User {
|
||||
var ppid *string
|
||||
if u.ProfilePicture != nil {
|
||||
id := fmt.Sprintf("/file/%d", u.ProfilePicture.ID)
|
||||
ppid = &id
|
||||
}
|
||||
|
||||
return &userv1.User{
|
||||
Id: u.ID,
|
||||
Username: u.Username,
|
||||
ProfilePicture: ppid,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user