Skip to content

Commit

Permalink
fix: rename DeleteUserBadge to DeleteUserBadgeAward
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored and LinkinStars committed Jan 3, 2025
1 parent d9bd3a2 commit ac8d027
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions internal/repo/badge/badge_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions internal/repo/badge_award/badge_award_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions internal/service/badge/badge_award_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions internal/service/badge/badge_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions internal/service/user_admin/user_backyard.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type UserAdminService struct {
userExternalLoginRepo user_external_login.UserExternalLoginRepo
notificationRepo notificationcommon.NotificationRepo
pluginUserConfigRepo plugin_common.PluginUserConfigRepo
badgeRepo badge.BadgeRepo
badgeAwardRepo badge.BadgeAwardRepo
}

// NewUserAdminService new user admin service
Expand All @@ -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,
Expand All @@ -118,7 +118,7 @@ func NewUserAdminService(
userExternalLoginRepo: userExternalLoginRepo,
notificationRepo: notificationRepo,
pluginUserConfigRepo: pluginUserConfigRepo,
badgeRepo: badgeRepo,
badgeAwardRepo: badgeAwardRepo,
}
}

Expand Down Expand Up @@ -194,9 +194,9 @@ func (us *UserAdminService) removeAllUserConfiguration(ctx context.Context, user
if 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)
}
}

Expand Down

0 comments on commit ac8d027

Please sign in to comment.