mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Initial commit
This commit is contained in:
26
server/model/image.go
Normal file
26
server/model/image.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Image struct {
|
||||
gorm.Model
|
||||
FileName string
|
||||
Width int
|
||||
Height int
|
||||
// An image can only belong to one resource, or it doesn't belong to any resource and is waiting for usage.
|
||||
Resource []Resource `gorm:"many2many:resource_images;"`
|
||||
}
|
||||
|
||||
type ImageView struct {
|
||||
ID uint `json:"id"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
}
|
||||
|
||||
func (i *Image) ToView() ImageView {
|
||||
return ImageView{
|
||||
ID: i.ID,
|
||||
Width: i.Width,
|
||||
Height: i.Height,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user