GetQuestion get question details @Summary get question details @Description get question details @Tags Question @Accept json @Produce json @Param id query string true "Question TagID" default(1) @Success 200 {string} string "" @Router /answer/api/v1/question/info [get]
(ctx *gin.Context)
| 230 | // @Success 200 {string} string "" |
| 231 | // @Router /answer/api/v1/question/info [get] |
| 232 | func (qc *QuestionController) GetQuestion(ctx *gin.Context) { |
| 233 | id := ctx.Query("id") |
| 234 | id = uid.DeShortID(id) |
| 235 | userID := middleware.GetLoginUserIDFromContext(ctx) |
| 236 | req := schema.QuestionPermission{} |
| 237 | req.IsAdminModerator = middleware.GetUserIsAdminModerator(ctx) |
| 238 | canList, err := qc.rankService.CheckOperationPermissions(ctx, userID, []string{ |
| 239 | permission.QuestionEdit, |
| 240 | permission.QuestionDelete, |
| 241 | permission.QuestionClose, |
| 242 | permission.QuestionReopen, |
| 243 | permission.QuestionPin, |
| 244 | permission.QuestionUnPin, |
| 245 | permission.QuestionHide, |
| 246 | permission.QuestionShow, |
| 247 | permission.AnswerInviteSomeoneToAnswer, |
| 248 | permission.QuestionUnDelete, |
| 249 | }) |
| 250 | if err != nil { |
| 251 | handler.HandleResponse(ctx, err, nil) |
| 252 | return |
| 253 | } |
| 254 | objectOwner := qc.rankService.CheckOperationObjectOwner(ctx, userID, id) |
| 255 | |
| 256 | req.CanEdit = canList[0] || objectOwner |
| 257 | req.CanDelete = canList[1] |
| 258 | req.CanClose = canList[2] |
| 259 | req.CanReopen = canList[3] |
| 260 | req.CanPin = canList[4] |
| 261 | req.CanUnPin = canList[5] |
| 262 | req.CanHide = canList[6] |
| 263 | req.CanShow = canList[7] |
| 264 | req.CanInviteOtherToAnswer = canList[8] |
| 265 | req.CanRecover = canList[9] |
| 266 | |
| 267 | info, err := qc.questionService.GetQuestionAndAddPV(ctx, id, userID, req) |
| 268 | if err != nil { |
| 269 | handler.HandleResponse(ctx, err, nil) |
| 270 | return |
| 271 | } |
| 272 | if handler.GetEnableShortID(ctx) { |
| 273 | info.ID = uid.EnShortID(info.ID) |
| 274 | } |
| 275 | handler.HandleResponse(ctx, nil, info) |
| 276 | } |
| 277 | |
| 278 | // GetQuestionInviteUserInfo get question invite user info |
| 279 | // @Summary get question invite user info |
nothing calls this directly
no test coverage detected