MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Detail

Method Detail

internal/api/post.go:191–215  ·  view source on GitHub ↗

Detail 获取帖子详情

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

189
190// Detail 获取帖子详情
191func (ph *PostHandler) Detail(ctx *gin.Context) {
192 var req req.DetailReq
193 if err := ctx.ShouldBindUri(&req); err != nil {
194 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
195 return
196 }
197
198 uc, ok := requireUser(ctx)
199 if !ok {
200 return
201 }
202
203 post, err := ph.svc.GetPostById(ctx, req.PostId, uc.Uid)
204 if err != nil {
205 apiresponse.ErrorWithMessage(ctx, err.Error())
206 return
207 }
208
209 if post.Content == "" && post.Title == "" {
210 apiresponse.ErrorWithMessage(ctx, PostGetDetailERROR)
211 return
212 }
213
214 apiresponse.SuccessWithData(ctx, post)
215}
216
217// DetailPub 获取公开帖子详情
218func (ph *PostHandler) DetailPub(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 4

ErrorWithMessageFunction · 0.92
SuccessWithDataFunction · 0.92
requireUserFunction · 0.85
GetPostByIdMethod · 0.65

Tested by

no test coverage detected