MCPcopy
hub / github.com/apache/answer / GetComment

Method GetComment

internal/controller/comment_controller.go:297–318  ·  view source on GitHub ↗

GetComment godoc @Summary get comment by id @Description get comment by id @Tags Comment @Produce json @Param id query string true "id" @Success 200 {object} handler.RespBody{data=pager.PageModel{list=[]schema.GetCommentResp}} @Router /answer/api/v1/comment [get]

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

295// @Success 200 {object} handler.RespBody{data=pager.PageModel{list=[]schema.GetCommentResp}}
296// @Router /answer/api/v1/comment [get]
297func (cc *CommentController) GetComment(ctx *gin.Context) {
298 req := &schema.GetCommentReq{}
299 if handler.BindAndCheck(ctx, req) {
300 return
301 }
302
303 req.UserID = middleware.GetLoginUserIDFromContext(ctx)
304 req.IsAdminModerator = middleware.GetUserIsAdminModerator(ctx)
305 canList, err := cc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
306 permission.CommentEdit,
307 permission.CommentDelete,
308 })
309 if err != nil {
310 handler.HandleResponse(ctx, err, nil)
311 return
312 }
313 req.CanEdit = canList[0]
314 req.CanDelete = canList[1]
315
316 resp, err := cc.commentService.GetComment(ctx, req)
317 handler.HandleResponse(ctx, err, resp)
318}

Callers

nothing calls this directly

Calls 6

BindAndCheckFunction · 0.92
GetUserIsAdminModeratorFunction · 0.92
HandleResponseFunction · 0.92
GetCommentMethod · 0.65

Tested by

no test coverage detected