-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.model.go
35 lines (30 loc) · 1.21 KB
/
post.model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package models
import (
"time"
"github.com/google/uuid"
)
type Post struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id,omitempty"`
Title string `gorm:"uniqueIndex;not null" json:"title,omitempty"`
Content string `gorm:"not null" json:"content,omitempty"`
Image string `gorm:"not null" json:"image,omitempty"`
User uuid.UUID `gorm:"not null" json:"user,omitempty"`
CreatedAt time.Time `gorm:"not null" json:"created_at,omitempty"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at,omitempty"`
}
type CreatePostRequest struct {
Title string `json:"title" binding:"required"`
Content string `json:"content" binding:"required"`
Image string `json:"image" binding:"required"`
User string `json:"user,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type UpdatePost struct {
Title string `json:"title,omitempty"`
Content string `json:"content,omitempty"`
Image string `json:"image,omitempty"`
User string `json:"user,omitempty"`
CreateAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}