update short id

This commit is contained in:
aichy126 2023-03-09 14:59:07 +08:00
parent 3fe2ffa0f3
commit 3367ecd203
3 changed files with 8 additions and 4 deletions

View File

@ -210,7 +210,9 @@ func (ar *answerRepo) GetByUserIDQuestionID(ctx context.Context, userID string,
// SearchList
func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearch) ([]*entity.Answer, int64, error) {
search.QuestionID = uid.DeShortID(search.QuestionID)
if search.QuestionID != "" {
search.QuestionID = uid.DeShortID(search.QuestionID)
}
search.ID = uid.DeShortID(search.ID)
var count int64
var err error

View File

@ -173,7 +173,7 @@ func (qr *questionRepo) SearchByTitleLike(ctx context.Context, title string) (qu
func (qr *questionRepo) FindByID(ctx context.Context, id []string) (questionList []*entity.Question, err error) {
for key, itemID := range id {
id[key] = uid.EnShortID(itemID)
id[key] = uid.DeShortID(itemID)
}
questionList = make([]*entity.Question, 0)
err = qr.data.DB.Table("question").In("id", id).Find(&questionList)
@ -181,7 +181,7 @@ func (qr *questionRepo) FindByID(ctx context.Context, id []string) (questionList
return nil, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
for _, item := range questionList {
item.ID = uid.DeShortID(item.ID)
item.ID = uid.EnShortID(item.ID)
}
return
}

View File

@ -26,6 +26,7 @@ import (
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
usercommon "github.com/answerdev/answer/internal/service/user_common"
"github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/pkg/uid"
"github.com/jinzhu/copier"
"github.com/segmentfault/pacman/errors"
"github.com/segmentfault/pacman/i18n"
@ -719,12 +720,13 @@ func (qs *QuestionService) SearchUserAnswerList(ctx context.Context, userName, o
for _, item := range answerList {
answerinfo := qs.questioncommon.AnswerCommon.ShowFormat(ctx, item)
answerlist = append(answerlist, answerinfo)
questionIDs = append(questionIDs, item.QuestionID)
questionIDs = append(questionIDs, uid.DeShortID(item.QuestionID))
}
questionMaps, err := qs.questioncommon.FindInfoByID(ctx, questionIDs, loginUserID)
if err != nil {
return userAnswerlist, count, err
}
for _, item := range answerlist {
_, ok := questionMaps[item.QuestionID]
if ok {