A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat(badge): change badge_award entity
kumfo49ba98c6fc1c
diff --git a/internal/entity/badge_award_entity.go b/internal/entity/badge_award_entity.goindex a26fd8de..26369394 100644--- a/internal/entity/badge_award_entity.go+++ b/internal/entity/badge_award_entity.go@@ -28,7 +28,7 @@ type BadgeAward struct {UpdatedAt time.Time `json:"updated_at" xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`UserID string `json:"user_id" xorm:"not null index BIGINT(20) user_id"`BadgeID string `json:"badge_id" xorm:"not null index BIGINT(20) badge_id"`- ObjectID string `json:"object_id" xorm:"not null index BIGINT(20) object_id"`+ AwardKey string `json:"award_key" xorm:"not null index VARCHAR(64) award_key"`BadgeGroupID int8 `json:"badge_group_id" xorm:"not null index BIGINT(20) badge_group_id"`IsBadgeDeleted int8 `json:"is_badge_deleted" xorm:"not null index TINYINT(1) s_badge_deleted"`}diff --git a/internal/service/badge_award/badge_award_service.go b/internal/service/badge_award/badge_award_service.goindex b8e96545..7eb218fd 100644--- a/internal/service/badge_award/badge_award_service.go+++ b/internal/service/badge_award/badge_award_service.go@@ -21,16 +21,13 @@ package badge_awardimport ("context"- "github.com/apache/incubator-answer/internal/base/reason""github.com/apache/incubator-answer/internal/entity""github.com/apache/incubator-answer/internal/schema"answercommon "github.com/apache/incubator-answer/internal/service/answer_common""github.com/apache/incubator-answer/internal/service/object_info"questioncommon "github.com/apache/incubator-answer/internal/service/question_common"usercommon "github.com/apache/incubator-answer/internal/service/user_common"- "github.com/apache/incubator-answer/pkg/htmltext""github.com/jinzhu/copier"- "github.com/segmentfault/pacman/errors""github.com/segmentfault/pacman/log""time")@@ -103,24 +100,29 @@ func (b *BadgeAwardService) GetBadgeAwardList(resp = make([]*schema.GetBadgeAwardWithPageResp, 0, len(badgeAwardList))for i, badgeAward := range badgeAwardList {- objInfo, e := b.objectInfoService.GetInfo(ctx, badgeAward.ObjectID)- if e != nil {- err = e- return- }- if objInfo.IsDeleted() {- err = errors.BadRequest(reason.NewObjectAlreadyDeleted)- return+ var (+ objectID, questionID, answerID, commentID, objectType, urlTitle string+ )++ // if exist object info+ objInfo, e := b.objectInfoService.GetInfo(ctx, badgeAward.AwardKey)+ if e == nil && !objInfo.IsDeleted() {+ objectID = objInfo.ObjectID+ questionID = objInfo.QuestionID+ answerID = objInfo.AnswerID+ commentID = objInfo.CommentID+ objectType = objInfo.ObjectType+ urlTitle = objInfo.Title}row := &schema.GetBadgeAwardWithPageResp{CreatedAt: badgeAward.CreatedAt.Unix(),- ObjectID: badgeAward.ObjectID,- QuestionID: objInfo.QuestionID,- AnswerID: objInfo.AnswerID,- CommentID: objInfo.CommentID,- ObjectType: objInfo.ObjectType,- UrlTitle: htmltext.UrlTitle(objInfo.Title),+ ObjectID: objectID,+ QuestionID: questionID,+ AnswerID: answerID,+ CommentID: commentID,+ ObjectType: objectType,+ UrlTitle: urlTitle,AuthorUserInfo: schema.UserBasicInfo{},}