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.
fix: rename DeleteUserBadge to DeleteUserBadgeAward
Luffyd328ea417577
diff --git a/cmd/wire_gen.go b/cmd/wire_gen.goindex 4363f08b..c45d2f39 100644--- a/cmd/wire_gen.go+++ b/cmd/wire_gen.go@@ -227,11 +227,11 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,contentRevisionService := content.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService, objService, questionRepo, answerRepo, tagRepo, tagCommonService, notificationQueueService, activityQueueService, reportRepo, reviewService, reviewActivityRepo)revisionController := controller.NewRevisionController(contentRevisionService, rankService)rankController := controller.NewRankController(rankService)- badgeRepo := badge.NewBadgeRepo(dataData, uniqueIDRepo)+ badgeAwardRepo := badge_award.NewBadgeAwardRepo(dataData, uniqueIDRepo)notificationRepo := notification2.NewNotificationRepo(dataData)pluginUserConfigRepo := plugin_config.NewPluginUserConfigRepo(dataData)userAdminRepo := user.NewUserAdminRepo(dataData, authRepo)- userAdminService := user_admin.NewUserAdminService(userAdminRepo, userRoleRelService, authService, userCommon, userActiveActivityRepo, siteInfoCommonService, emailService, questionRepo, answerRepo, commentCommonRepo, userExternalLoginRepo, notificationRepo, pluginUserConfigRepo, badgeRepo)+ userAdminService := user_admin.NewUserAdminService(userAdminRepo, userRoleRelService, authService, userCommon, userActiveActivityRepo, siteInfoCommonService, emailService, questionRepo, answerRepo, commentCommonRepo, userExternalLoginRepo, notificationRepo, pluginUserConfigRepo, badgeAwardRepo)userAdminController := controller_admin.NewUserAdminController(userAdminService)reasonRepo := reason.NewReasonRepo(configService)reasonService := reason2.NewReasonService(reasonRepo)@@ -241,6 +241,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,siteInfoController := controller_admin.NewSiteInfoController(siteInfoService)controllerSiteInfoController := controller.NewSiteInfoController(siteInfoCommonService)notificationCommon := notificationcommon.NewNotificationCommon(dataData, notificationRepo, userCommon, activityRepo, followRepo, objService, notificationQueueService, userExternalLoginRepo, siteInfoCommonService)+ badgeRepo := badge.NewBadgeRepo(dataData, uniqueIDRepo)notificationService := notification.NewNotificationService(dataData, notificationRepo, notificationCommon, revisionService, userRepo, reportRepo, reviewService, badgeRepo)notificationController := controller.NewNotificationController(notificationService, rankService)dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configService, siteInfoCommonService, serviceConf, reviewService, revisionRepo, dataData)@@ -263,7 +264,6 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,metaService := meta2.NewMetaService(metaCommonService, userCommon, answerRepo, questionRepo, eventQueueService)metaController := controller.NewMetaController(metaService)badgeGroupRepo := badge_group.NewBadgeGroupRepo(dataData, uniqueIDRepo)- badgeAwardRepo := badge_award.NewBadgeAwardRepo(dataData, uniqueIDRepo)eventRuleRepo := badge.NewEventRuleRepo(dataData)badgeAwardService := badge2.NewBadgeAwardService(badgeAwardRepo, badgeRepo, userCommon, objService, notificationQueueService)badgeEventService := badge2.NewBadgeEventService(dataData, eventQueueService, badgeRepo, eventRuleRepo, badgeAwardService)diff --git a/internal/repo/badge/badge_repo.go b/internal/repo/badge/badge_repo.goindex 4c5e51ae..d52fc122 100644--- a/internal/repo/badge/badge_repo.go+++ b/internal/repo/badge/badge_repo.go@@ -149,12 +149,3 @@ func (r *badgeRepo) UpdateAwardCount(ctx context.Context, badgeID string, awardC}return}--// DeleteUserBadge delete user badge-func (r *badgeRepo) DeleteUserBadge(ctx context.Context, userID string) (err error) {- _, err = r.data.DB.Context(ctx).Where("user_id = ?", userID).Delete(&entity.BadgeAward{})- if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- }- return-}diff --git a/internal/repo/badge_award/badge_award_repo.go b/internal/repo/badge_award/badge_award_repo.goindex c1ce1e58..8c8dd985 100644--- a/internal/repo/badge_award/badge_award_repo.go+++ b/internal/repo/badge_award/badge_award_repo.go@@ -184,3 +184,12 @@ func (r *badgeAwardRepo) GetByUserIdAndBadgeIdAndAwardKey(ctx context.Context, u}return}++// DeleteUserBadgeAward delete user badge award+func (r *badgeAwardRepo) DeleteUserBadgeAward(ctx context.Context, userID string) (err error) {+ _, err = r.data.DB.Context(ctx).Where("user_id = ?", userID).Delete(&entity.BadgeAward{})+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return+}diff --git a/internal/service/badge/badge_award_service.go b/internal/service/badge/badge_award_service.goindex feb95a65..5b0df289 100644--- a/internal/service/badge/badge_award_service.go+++ b/internal/service/badge/badge_award_service.go@@ -52,6 +52,8 @@ type BadgeAwardRepo interface {GetByUserIdAndBadgeId(ctx context.Context, userID string, badgeID string) (badgeAward *entity.BadgeAward, exists bool, err error)GetByUserIdAndBadgeIdAndAwardKey(ctx context.Context, userID string, badgeID string, awardKey string) (badgeAward *entity.BadgeAward, exists bool, err error)++ DeleteUserBadgeAward(ctx context.Context, userID string) (err error)}type BadgeAwardService struct {diff --git a/internal/service/badge/badge_service.go b/internal/service/badge/badge_service.goindex 5ed4c157..0ab538a3 100644--- a/internal/service/badge/badge_service.go+++ b/internal/service/badge/badge_service.go@@ -45,8 +45,6 @@ type BadgeRepo interface {UpdateStatus(ctx context.Context, id string, status int8) (err error)UpdateAwardCount(ctx context.Context, badgeID string, awardCount int) (err error)-- DeleteUserBadge(ctx context.Context, userID string) (err error)}type BadgeService struct {diff --git a/internal/service/user_admin/user_backyard.go b/internal/service/user_admin/user_backyard.goindex 6f436b0c..6c1d50c1 100644--- a/internal/service/user_admin/user_backyard.go+++ b/internal/service/user_admin/user_backyard.go@@ -84,7 +84,7 @@ type UserAdminService struct {userExternalLoginRepo user_external_login.UserExternalLoginReponotificationRepo notificationcommon.NotificationRepopluginUserConfigRepo plugin_common.PluginUserConfigRepo- badgeRepo badge.BadgeRepo+ badgeAwardRepo badge.BadgeAwardRepo}// NewUserAdminService new user admin service@@ -102,7 +102,7 @@ func NewUserAdminService(userExternalLoginRepo user_external_login.UserExternalLoginRepo,notificationRepo notificationcommon.NotificationRepo,pluginUserConfigRepo plugin_common.PluginUserConfigRepo,- badgeRepo badge.BadgeRepo,+ badgeAwardRepo badge.BadgeAwardRepo,) *UserAdminService {return &UserAdminService{userRepo: userRepo,@@ -118,7 +118,7 @@ func NewUserAdminService(userExternalLoginRepo: userExternalLoginRepo,notificationRepo: notificationRepo,pluginUserConfigRepo: pluginUserConfigRepo,- badgeRepo: badgeRepo,+ badgeAwardRepo: badgeAwardRepo,}}@@ -194,9 +194,9 @@ func (us *UserAdminService) removeAllUserConfiguration(ctx context.Context, userif err != nil {log.Errorf("remove all user plugin config error: %v", err)}- err = us.badgeRepo.DeleteUserBadge(ctx, userID)+ err = us.badgeAwardRepo.DeleteUserBadgeAward(ctx, userID)if err != nil {- log.Errorf("remove all user badge error: %v", err)+ log.Errorf("remove all user badge award error: %v", err)}}