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)
| 169 | // @Success 200 {object} handler.RespBody |
| 170 | // @Router /answer/api/v1/question/status [put] |
| 171 | func (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 |
nothing calls this directly
no test coverage detected