Merge branch 'feat/1.0.7/short-id' into test

This commit is contained in:
aichy126
2023-03-17 10:55:18 +08:00
4 changed files with 6 additions and 2 deletions
+1
View File
@@ -113,6 +113,7 @@ func (ac *AnswerController) Add(ctx *gin.Context) {
if handler.BindAndCheck(ctx, req) {
return
}
req.QuestionID = uid.DeShortID(req.QuestionID)
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
can, err := ac.rankService.CheckOperationPermission(ctx, req.UserID, permission.AnswerAdd, "")
+2 -1
View File
@@ -23,6 +23,7 @@ import (
"github.com/answerdev/answer/internal/service/role"
usercommon "github.com/answerdev/answer/internal/service/user_common"
"github.com/answerdev/answer/pkg/encryption"
"github.com/answerdev/answer/pkg/uid"
"github.com/segmentfault/pacman/errors"
"github.com/segmentfault/pacman/log"
)
@@ -167,7 +168,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
if err != nil {
log.Error("IncreaseAnswerCount error", err.Error())
}
err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionID, insertData.ID)
err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionID, uid.DeShortID(insertData.ID))
if err != nil {
log.Error("UpdateLastAnswer error", err.Error())
}
@@ -198,7 +198,7 @@ func (ns *NotificationCommon) SendNotificationToAllFollower(ctx context.Context,
}
condObjectID := msg.ObjectID
if len(questionID) > 0 {
condObjectID = questionID
condObjectID = uid.DeShortID(questionID)
}
userIDs, err := ns.followRepo.GetFollowUserIDs(ctx, condObjectID)
if err != nil {
+2
View File
@@ -15,6 +15,7 @@ import (
"github.com/answerdev/answer/internal/service/role"
usercommon "github.com/answerdev/answer/internal/service/user_common"
"github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/pkg/uid"
"github.com/segmentfault/pacman/errors"
"github.com/segmentfault/pacman/log"
"xorm.io/xorm"
@@ -124,6 +125,7 @@ func (rs *RankService) CheckOperationPermissions(ctx context.Context, userID str
// CheckOperationObjectOwner check operation object owner
func (rs *RankService) CheckOperationObjectOwner(ctx context.Context, userID, objectID string) bool {
objectID = uid.DeShortID(objectID)
objectInfo, err := rs.objectInfoService.GetInfo(ctx, objectID)
if err != nil {
log.Error(err)