diff --git a/internal/controller/answer_controller.go b/internal/controller/answer_controller.go index 93803c0e..55b3895e 100644 --- a/internal/controller/answer_controller.go +++ b/internal/controller/answer_controller.go @@ -81,6 +81,7 @@ func (ac *AnswerController) RemoveAnswer(ctx *gin.Context) { // @Success 200 {string} string "" func (ac *AnswerController) Get(ctx *gin.Context) { id := ctx.Query("id") + id = uid.DeShortID(id) userID := middleware.GetLoginUserIDFromContext(ctx) info, questionInfo, has, err := ac.answerService.Get(ctx, id, userID) @@ -181,6 +182,7 @@ func (ac *AnswerController) Update(ctx *gin.Context) { return } req.UserID = middleware.GetLoginUserIDFromContext(ctx) + req.QuestionID = uid.DeShortID(req.QuestionID) canList, err := ac.rankService.CheckOperationPermissions(ctx, req.UserID, []string{ permission.AnswerEdit, @@ -232,6 +234,7 @@ func (ac *AnswerController) AnswerList(ctx *gin.Context) { } req.UserID = middleware.GetLoginUserIDFromContext(ctx) + req.QuestionID = uid.DeShortID(req.QuestionID) canList, err := ac.rankService.CheckOperationPermissions(ctx, req.UserID, []string{ permission.AnswerEdit, @@ -272,6 +275,8 @@ func (ac *AnswerController) Accepted(ctx *gin.Context) { } req.UserID = middleware.GetLoginUserIDFromContext(ctx) + req.AnswerID = uid.DeShortID(req.AnswerID) + req.QuestionID = uid.DeShortID(req.QuestionID) can, err := ac.rankService.CheckOperationPermission(ctx, req.UserID, permission.AnswerAccept, req.QuestionID) if err != nil { handler.HandleResponse(ctx, err, nil) @@ -301,6 +306,7 @@ func (ac *AnswerController) AdminSetAnswerStatus(ctx *gin.Context) { if handler.BindAndCheck(ctx, req) { return } + req.AnswerID = uid.DeShortID(req.AnswerID) req.UserID = middleware.GetLoginUserIDFromContext(ctx)