Skip to content

Commit

Permalink
update short id
Browse files Browse the repository at this point in the history
  • Loading branch information
aichy126 committed Mar 21, 2023
1 parent 0c817fd commit 9e8debc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/controller/answer_controller.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9e8debc

Please sign in to comment.