MCPcopy Index your code
hub / github.com/apache/answer / CloseQuestion

Method CloseQuestion

internal/controller/question_controller.go:171–190  ·  view source on GitHub ↗

CloseQuestion Close question @Summary Close question @Description Close question @Tags Question @Accept json @Produce json @Security ApiKeyAuth @Param data body schema.CloseQuestionReq true "question" @Success 200 {object} handler.RespBody @Router /answer/api/v1/question/status [put]

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

169// @Success 200 {object} handler.RespBody
170// @Router /answer/api/v1/question/status [put]
171func (qc *QuestionController) CloseQuestion(ctx *gin.Context) {
172 req := &schema.CloseQuestionReq{}
173 if handler.BindAndCheck(ctx, req) {
174 return
175 }
176 req.ID = uid.DeShortID(req.ID)
177 req.UserID = middleware.GetLoginUserIDFromContext(ctx)
178 can, err := qc.rankService.CheckOperationPermission(ctx, req.UserID, permission.QuestionClose, "")
179 if err != nil {
180 handler.HandleResponse(ctx, err, nil)
181 return
182 }
183 if !can {
184 handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), nil)
185 return
186 }
187
188 err = qc.questionService.CloseQuestion(ctx, req)
189 handler.HandleResponse(ctx, err, nil)
190}
191
192// ReopenQuestion reopen question
193// @Summary reopen question

Callers

nothing calls this directly

Calls 5

BindAndCheckFunction · 0.92
DeShortIDFunction · 0.92
HandleResponseFunction · 0.92

Tested by

no test coverage detected