@@ -20,13 +20,14 @@ func PostsIndex(ctr *container.Container) echo.HandlerFunc {
20
20
}
21
21
22
22
posts , err := ctr .PostService .Index (
23
- user .ID ,
23
+ user .Id ,
24
24
utils .StringToID (ctx .QueryParams ().Get ("lastId" ), ^ uint64 (0 )),
25
25
utils .StringToInt (ctx .QueryParams ().Get ("count" ), 100 , 10 ),
26
26
)
27
27
if err != nil {
28
28
return errors .WithStack (err )
29
29
}
30
+
30
31
return ctx .JSON (http .StatusCreated , map [string ]interface {}{
31
32
"posts" : posts ,
32
33
})
@@ -65,7 +66,7 @@ func PostsStore(ctr *container.Container) echo.HandlerFunc {
65
66
"message" : "Audio file not found." ,
66
67
})
67
68
}
68
- if s , _ := ctr .PostService .FindBy ("audio_id" , audio .ID ); s != nil {
69
+ if s , _ := ctr .PostService .FindBy ("audio_id" , audio .Id ); s != nil {
69
70
return ctx .JSON (http .StatusUnprocessableEntity , map [string ]string {
70
71
"message" : "The selected file is already in use." ,
71
72
})
@@ -91,12 +92,12 @@ func PostsStore(ctr *container.Container) echo.HandlerFunc {
91
92
"message" : "Image file not found." ,
92
93
})
93
94
}
94
- if s , _ := ctr .PostService .FindBy ("image_id" , image .ID ); s != nil {
95
+ if s , _ := ctr .PostService .FindBy ("image_id" , image .Id ); s != nil {
95
96
return ctx .JSON (http .StatusUnprocessableEntity , map [string ]string {
96
97
"message" : "The selected file is already in use." ,
97
98
})
98
99
}
99
- if s , _ := ctr .UserService .FindBy ("image_id" , image .ID ); s != nil {
100
+ if s , _ := ctr .UserService .FindBy ("image_id" , image .Id ); s != nil {
100
101
return ctx .JSON (http .StatusUnprocessableEntity , map [string ]string {
101
102
"message" : "The selected file is already in use." ,
102
103
})
@@ -110,15 +111,15 @@ func PostsStore(ctr *container.Container) echo.HandlerFunc {
110
111
"message" : "The selected file is not an image." ,
111
112
})
112
113
}
113
- imageId = & image .ID
114
+ imageId = & image .Id
114
115
}
115
116
116
117
id , err := ctr .PostService .Create (& models.Post {
117
- UserID : user .ID ,
118
+ UserId : user .Id ,
118
119
Title : r .Title ,
119
120
Description : r .Description ,
120
- AudioID : audio .ID ,
121
- ImageID : imageId ,
121
+ AudioId : audio .Id ,
122
+ ImageId : imageId ,
122
123
LikesCount : 0 ,
123
124
CommentsCount : 0 ,
124
125
})
@@ -137,11 +138,6 @@ func PostsStore(ctr *container.Container) echo.HandlerFunc {
137
138
}
138
139
}
139
140
140
- type postsUpdateCaptionRequest struct {
141
- Title string `json:"title" validate:"required,min=1,max=50"`
142
- Description string `json:"description" validate:"max=300"`
143
- }
144
-
145
141
func PostsShow (ctr * container.Container ) echo.HandlerFunc {
146
142
return func (ctx echo.Context ) error {
147
143
post , err := ctr .PostService .FindById (utils .StringToID (ctx .Param ("postId" ), 0 ))
@@ -157,6 +153,11 @@ func PostsShow(ctr *container.Container) echo.HandlerFunc {
157
153
}
158
154
}
159
155
156
+ type postsUpdateCaptionRequest struct {
157
+ Title string `json:"title" validate:"required,min=1,max=50"`
158
+ Description string `json:"description" validate:"max=300"`
159
+ }
160
+
160
161
func PostsUpdate (ctr * container.Container ) echo.HandlerFunc {
161
162
return func (ctx echo.Context ) error {
162
163
user := ctx .Get ("user" ).(* models.User )
@@ -169,7 +170,7 @@ func PostsUpdate(ctr *container.Container) echo.HandlerFunc {
169
170
return ctx .NoContent (http .StatusNotFound )
170
171
}
171
172
172
- if post .UserID != user .ID {
173
+ if post .UserId != user .Id {
173
174
return ctx .JSON (http .StatusForbidden , map [string ]string {
174
175
"message" : "You do not have permission to perform this action." ,
175
176
})
@@ -207,7 +208,7 @@ func PostsDelete(ctr *container.Container) echo.HandlerFunc {
207
208
return ctx .NoContent (http .StatusNotFound )
208
209
}
209
210
210
- if post .UserID != user .ID {
211
+ if post .UserId != user .Id {
211
212
return ctx .JSON (http .StatusForbidden , map [string ]string {
212
213
"message" : "You do not have permission to perform this action." ,
213
214
})
0 commit comments