|
|
@@ -61,6 +61,7 @@ type PlaceRepo interface {
|
|
|
UpdateStatus(ctx context.Context, id, status, comment string) error
|
|
|
SoftDelete(ctx context.Context, id string) error
|
|
|
HardDelete(ctx context.Context, id string) error
|
|
|
+ Restore(ctx context.Context, id string) error
|
|
|
GetPlaceImages(ctx context.Context, placeID string) ([]models.PlaceImage, error)
|
|
|
SetTags(ctx context.Context, placeID string, tags []models.Tag) error
|
|
|
SetFeatures(ctx context.Context, placeID string, features []models.Feature) error
|
|
|
@@ -376,3 +377,27 @@ func (s *PlaceService) HardDelete(ctx context.Context, id, moderatorID string) e
|
|
|
|
|
|
return s.placeRepo.HardDelete(ctx, id)
|
|
|
}
|
|
|
+
|
|
|
+func (s *PlaceService) Restore(ctx context.Context, id, moderatorID string) error {
|
|
|
+ place, err := s.placeRepo.GetByIDRaw(ctx, id)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if place == nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ entry := &models.ModerationLog{
|
|
|
+ ModeratorID: moderatorID,
|
|
|
+ TargetType: "place",
|
|
|
+ TargetID: id,
|
|
|
+ Action: "restore",
|
|
|
+ OldStatus: &place.Status,
|
|
|
+ NewStatus: pointer.Str("published"),
|
|
|
+ }
|
|
|
+ if err := s.moderationLogRepo.Create(ctx, entry); err != nil {
|
|
|
+ return fmt.Errorf("log restore: %w", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ return s.placeRepo.Restore(ctx, id)
|
|
|
+}
|