From 2177bc7baabef29775b257645fd07a8e044d401d Mon Sep 17 00:00:00 2001 From: Mykhailo Svishchov Date: Thu, 5 Mar 2026 13:14:41 +0200 Subject: [PATCH] cleanup 3 --- DEPLOYMENT_GUIDE.md | 4 +- ...mplate => honey-config.properties.template | 10 ++--- nginx.conf.template | 2 +- .../honey/config/TelegramProperties.java | 6 +-- .../honey/controller/PromotionController.java | 2 +- .../honey/honey/dto/AdminTransactionDto.java | 1 - .../honey/honey/dto/GameHistoryEntryDto.java | 29 -------------- .../InsufficientBalanceException.java | 8 ---- .../exception/InvalidBetAmountException.java | 30 -------------- .../exception/RoomNotJoinableException.java | 14 ------- .../exception/UserAlreadyJoinedException.java | 12 ------ .../java/com/honey/honey/model/GamePhase.java | 13 ------ .../honey/honey/service/AdminUserService.java | 1 - .../honey/service/ConfigurationService.java | 40 +------------------ .../honey/service/DataCleanupService.java | 2 +- .../honey/service/LocalizationService.java | 2 +- .../honey/honey/service/TelegramService.java | 2 +- .../migration/V29__set_initial_balance_a.sql | 5 --- .../V50__set_initial_balance_a_5_tickets.sql | 4 -- ...feature_switches_referral_tasks_50_100.sql | 1 - .../V57__seed_first_net_win_promotion.sql | 1 - ...ture_switch_manual_pay_for_all_payouts.sql | 1 - src/main/resources/logback-spring.xml | 2 +- 23 files changed, 17 insertions(+), 175 deletions(-) rename lottery-config.properties.template => honey-config.properties.template (88%) delete mode 100644 src/main/java/com/honey/honey/dto/GameHistoryEntryDto.java delete mode 100644 src/main/java/com/honey/honey/exception/InsufficientBalanceException.java delete mode 100644 src/main/java/com/honey/honey/exception/InvalidBetAmountException.java delete mode 100644 src/main/java/com/honey/honey/exception/RoomNotJoinableException.java delete mode 100644 src/main/java/com/honey/honey/exception/UserAlreadyJoinedException.java delete mode 100644 src/main/java/com/honey/honey/model/GamePhase.java delete mode 100644 src/main/resources/db/migration/V29__set_initial_balance_a.sql delete mode 100644 src/main/resources/db/migration/V50__set_initial_balance_a_5_tickets.sql delete mode 100644 src/main/resources/db/migration/V51__feature_switches_referral_tasks_50_100.sql delete mode 100644 src/main/resources/db/migration/V57__seed_first_net_win_promotion.sql delete mode 100644 src/main/resources/db/migration/V65__feature_switch_manual_pay_for_all_payouts.sql diff --git a/DEPLOYMENT_GUIDE.md b/DEPLOYMENT_GUIDE.md index 9634328..803d485 100644 --- a/DEPLOYMENT_GUIDE.md +++ b/DEPLOYMENT_GUIDE.md @@ -156,10 +156,10 @@ sudo mkdir -p /run/secrets cd /opt/app/backend # Check if template file exists -ls -la lottery-config.properties.template +ls -la honey-config.properties.template # If it exists, copy it -sudo cp lottery-config.properties.template /run/secrets/lottery-config.properties +sudo cp honey-config.properties.template /run/secrets/lottery-config.properties ``` **Option 2: Create the file directly (if template wasn't copied)** diff --git a/lottery-config.properties.template b/honey-config.properties.template similarity index 88% rename from lottery-config.properties.template rename to honey-config.properties.template index 3451b89..0478e79 100644 --- a/lottery-config.properties.template +++ b/honey-config.properties.template @@ -1,5 +1,5 @@ -# Lottery Application Configuration -# Copy this file to /run/secrets/lottery-config.properties on your VPS +# Honey Application Configuration +# Copy this file to /run/secrets/honey-config.properties on your VPS # Replace all placeholder values with your actual configuration # ============================================ @@ -13,9 +13,9 @@ # * The MySQL service is named 'db', so use 'db' as the hostname # * Both containers are on the same Docker network, so 'db' resolves to the MySQL container # - Port: '3306' (default MySQL port, internal to Docker network) -# - Database name: 'lottery_db' (must match MYSQL_DATABASE in docker-compose.prod.yml) +# - Database name: 'honey_db' (must match MYSQL_DATABASE in docker-compose.prod.yml) # -# Example: jdbc:mysql://db:3306/lottery_db +# Example: jdbc:mysql://db:3306/honey_db # └─┬─┘ └┬┘ └─┬──┘ └───┬────┘ # │ │ │ └─ Database name # │ │ └─ Port (3306 is MySQL default) @@ -24,7 +24,7 @@ # # IMPORTANT: Use 'db' as hostname, NOT 'localhost' or '127.0.0.1' # This is an internal Docker network connection -SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/lottery_db +SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/honey_db SPRING_DATASOURCE_USERNAME=root SPRING_DATASOURCE_PASSWORD=your_secure_database_password_here diff --git a/nginx.conf.template b/nginx.conf.template index 2176aac..1bc31e5 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -1,4 +1,4 @@ -# Nginx configuration for Lottery Application +# Nginx configuration for Honey Application # Place this file at: /opt/app/nginx/nginx.conf # # This configuration assumes: diff --git a/src/main/java/com/honey/honey/config/TelegramProperties.java b/src/main/java/com/honey/honey/config/TelegramProperties.java index e435a2f..f26a0d6 100644 --- a/src/main/java/com/honey/honey/config/TelegramProperties.java +++ b/src/main/java/com/honey/honey/config/TelegramProperties.java @@ -13,21 +13,21 @@ public class TelegramProperties { /** * Bot token for checking channel membership. * Can be set via environment variable TELEGRAM_CHANNEL_CHECKER_BOT_TOKEN - * or in mounted file at /run/secrets/lottery-config.properties as telegram.channel-checker-bot-token + * or in mounted file at /run/secrets/honey-config.properties as telegram.channel-checker-bot-token */ private String channelCheckerBotToken; /** * Channel ID for follow tasks (e.g., "@win_spin_news" or numeric ID). * Can be set via environment variable TELEGRAM_FOLLOW_TASK_CHANNEL_ID - * or in mounted file at /run/secrets/lottery-config.properties as telegram.follow-task-channel-id + * or in mounted file at /run/secrets/honey-config.properties as telegram.follow-task-channel-id */ private String followTaskChannelId; /** * Channel ID for follow withdrawals channel task (e.g., "@win_spin_withdrawals" or numeric ID). * Can be set via environment variable TELEGRAM_FOLLOW_TASK_CHANNEL_ID_2 - * or in mounted file at /run/secrets/lottery-config.properties as telegram.follow-task-channel-id-2 + * or in mounted file at /run/secrets/honey-config.properties as telegram.follow-task-channel-id-2 */ private String followTaskChannelId2; } diff --git a/src/main/java/com/honey/honey/controller/PromotionController.java b/src/main/java/com/honey/honey/controller/PromotionController.java index d58cca2..7fada10 100644 --- a/src/main/java/com/honey/honey/controller/PromotionController.java +++ b/src/main/java/com/honey/honey/controller/PromotionController.java @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** - * Public API for the lottery app: list and view promotion details (leaderboard, user progress). + * Public API: list and view promotion details (leaderboard, user progress). * Excludes INACTIVE promotions. Requires Bearer auth (app user). * When promotions feature switch is false, all endpoints return 404. */ diff --git a/src/main/java/com/honey/honey/dto/AdminTransactionDto.java b/src/main/java/com/honey/honey/dto/AdminTransactionDto.java index 557fdd7..782f72c 100644 --- a/src/main/java/com/honey/honey/dto/AdminTransactionDto.java +++ b/src/main/java/com/honey/honey/dto/AdminTransactionDto.java @@ -16,7 +16,6 @@ public class AdminTransactionDto { private Long amount; // In bigint format private String type; private Integer taskId; - private Long roundId; private Instant createdAt; } diff --git a/src/main/java/com/honey/honey/dto/GameHistoryEntryDto.java b/src/main/java/com/honey/honey/dto/GameHistoryEntryDto.java deleted file mode 100644 index dbde84f..0000000 --- a/src/main/java/com/honey/honey/dto/GameHistoryEntryDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.honey.honey.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * DTO for a single game history entry. - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class GameHistoryEntryDto { - /** - * Amount in bigint format (positive for wins, negative for losses). - * Example: +900000000 means +900.0000 (win of 900 tickets) - * Example: -100000000 means -100.0000 (loss of 100 tickets) - */ - private Long amount; - - /** - * Date formatted as dd.MM at HH:mm (e.g., "13.01 at 22:29") - */ - private String date; -} - - diff --git a/src/main/java/com/honey/honey/exception/InsufficientBalanceException.java b/src/main/java/com/honey/honey/exception/InsufficientBalanceException.java deleted file mode 100644 index 8e01221..0000000 --- a/src/main/java/com/honey/honey/exception/InsufficientBalanceException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.honey.honey.exception; - -public class InsufficientBalanceException extends GameException { - public InsufficientBalanceException(String localizedMessage) { - super(localizedMessage); - } -} - diff --git a/src/main/java/com/honey/honey/exception/InvalidBetAmountException.java b/src/main/java/com/honey/honey/exception/InvalidBetAmountException.java deleted file mode 100644 index 5711da8..0000000 --- a/src/main/java/com/honey/honey/exception/InvalidBetAmountException.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.honey.honey.exception; - -import com.honey.honey.service.LocalizationService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * Exception for invalid bet amounts. - * Uses localization service to get user's language preference. - */ -public class InvalidBetAmountException extends GameException { - public InvalidBetAmountException(String localizedMessage) { - super(localizedMessage); - } - - /** - * Factory method to create exception with localized message. - * Converts bigint values to display format (divide by 1,000,000). - */ - public static InvalidBetAmountException create(LocalizationService localizationService, long minBet, long maxBet) { - // Convert bigint to display format for user-friendly message - double minBetDisplay = minBet / 1_000_000.0; - double maxBetDisplay = maxBet / 1_000_000.0; - String message = localizationService.getMessage("game.error.invalidBetAmount", - String.format("%.2f", minBetDisplay), - String.format("%.2f", maxBetDisplay)); - return new InvalidBetAmountException(message); - } -} - diff --git a/src/main/java/com/honey/honey/exception/RoomNotJoinableException.java b/src/main/java/com/honey/honey/exception/RoomNotJoinableException.java deleted file mode 100644 index 6980f85..0000000 --- a/src/main/java/com/honey/honey/exception/RoomNotJoinableException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.honey.honey.exception; - -import com.honey.honey.model.GamePhase; -import com.honey.honey.service.LocalizationService; - -public class RoomNotJoinableException extends GameException { - public RoomNotJoinableException(GamePhase currentPhase, LocalizationService localizationService) { - super(localizationService.getMessage("game.error.roomNotJoinable")); - } -} - - - - diff --git a/src/main/java/com/honey/honey/exception/UserAlreadyJoinedException.java b/src/main/java/com/honey/honey/exception/UserAlreadyJoinedException.java deleted file mode 100644 index 73fbf31..0000000 --- a/src/main/java/com/honey/honey/exception/UserAlreadyJoinedException.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.honey.honey.exception; - -public class UserAlreadyJoinedException extends GameException { - public UserAlreadyJoinedException() { - super("You have already joined this round. Please wait for the next round."); - } -} - - - - - diff --git a/src/main/java/com/honey/honey/model/GamePhase.java b/src/main/java/com/honey/honey/model/GamePhase.java deleted file mode 100644 index 86e7597..0000000 --- a/src/main/java/com/honey/honey/model/GamePhase.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.honey.honey.model; - -public enum GamePhase { - WAITING, // Zero or one player joined - COUNTDOWN, // 30 seconds countdown started - SPINNING, // Spin animation in progress - RESOLUTION // Winner resolved, payout applied -} - - - - - diff --git a/src/main/java/com/honey/honey/service/AdminUserService.java b/src/main/java/com/honey/honey/service/AdminUserService.java index 5ab69f0..83b4b4c 100644 --- a/src/main/java/com/honey/honey/service/AdminUserService.java +++ b/src/main/java/com/honey/honey/service/AdminUserService.java @@ -606,7 +606,6 @@ public class AdminUserService { .amount(t.getAmount()) .type(t.getType().name()) .taskId(t.getTaskId()) - .roundId(t.getRoundId()) .createdAt(t.getCreatedAt()) .build()); } diff --git a/src/main/java/com/honey/honey/service/ConfigurationService.java b/src/main/java/com/honey/honey/service/ConfigurationService.java index 6c4f2f3..59e032f 100644 --- a/src/main/java/com/honey/honey/service/ConfigurationService.java +++ b/src/main/java/com/honey/honey/service/ConfigurationService.java @@ -1,53 +1,15 @@ package com.honey.honey.service; -import com.honey.honey.model.Configuration; import com.honey.honey.repository.ConfigurationRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; /** - * Configurations: key-value store for app-wide settings (e.g. lottery_bot_max_participants_before_join). + * Configurations: key-value store for app-wide settings. */ @Service @RequiredArgsConstructor public class ConfigurationService { - public static final String KEY_BOT_MAX_PARTICIPANTS_BEFORE_JOIN = "lottery_bot_max_participants_before_join"; - private static final int DEFAULT_MAX_PARTICIPANTS_BEFORE_JOIN = 1; - private static final int MIN_MAX_PARTICIPANTS = 0; - private static final int MAX_MAX_PARTICIPANTS = 10; - private final ConfigurationRepository configurationRepository; - - @Transactional(readOnly = true) - public int getMaxParticipantsBeforeBotJoin() { - return configurationRepository.findById(KEY_BOT_MAX_PARTICIPANTS_BEFORE_JOIN) - .map(c -> parsePositiveInt(c.getValue(), DEFAULT_MAX_PARTICIPANTS_BEFORE_JOIN)) - .orElse(DEFAULT_MAX_PARTICIPANTS_BEFORE_JOIN); - } - - @Transactional - public int setMaxParticipantsBeforeBotJoin(int value) { - int clamped = Math.max(MIN_MAX_PARTICIPANTS, Math.min(MAX_MAX_PARTICIPANTS, value)); - Configuration c = configurationRepository.findById(KEY_BOT_MAX_PARTICIPANTS_BEFORE_JOIN) - .orElseGet(() -> { - Configuration newConfig = new Configuration(); - newConfig.setKey(KEY_BOT_MAX_PARTICIPANTS_BEFORE_JOIN); - return newConfig; - }); - c.setValue(String.valueOf(clamped)); - configurationRepository.save(c); - return clamped; - } - - private static int parsePositiveInt(String value, int defaultValue) { - if (value == null || value.isBlank()) return defaultValue; - try { - int v = Integer.parseInt(value.trim()); - return Math.max(MIN_MAX_PARTICIPANTS, Math.min(MAX_MAX_PARTICIPANTS, v)); - } catch (NumberFormatException e) { - return defaultValue; - } - } } diff --git a/src/main/java/com/honey/honey/service/DataCleanupService.java b/src/main/java/com/honey/honey/service/DataCleanupService.java index 9e6fbc8..269e631 100644 --- a/src/main/java/com/honey/honey/service/DataCleanupService.java +++ b/src/main/java/com/honey/honey/service/DataCleanupService.java @@ -59,7 +59,7 @@ public class DataCleanupService { log.debug("Deleted {} old transactions in batch {}", deleted, batchesProcessed); } - // Sleep between batches to let database process WebSocket inserts + // Sleep between batches between batches if (deleted > 0 && batchesProcessed < maxBatchesPerRun) { try { Thread.sleep(batchSleepMs); diff --git a/src/main/java/com/honey/honey/service/LocalizationService.java b/src/main/java/com/honey/honey/service/LocalizationService.java index 0f45215..1bb05c9 100644 --- a/src/main/java/com/honey/honey/service/LocalizationService.java +++ b/src/main/java/com/honey/honey/service/LocalizationService.java @@ -42,7 +42,7 @@ public class LocalizationService { /** * Gets a localized message for the current user. * - * @param code Message code (e.g., "game.error.roomNotFound") + * @param code Message code (e.g., "error.code") * @param args Optional arguments for message formatting * @return Localized message string */ diff --git a/src/main/java/com/honey/honey/service/TelegramService.java b/src/main/java/com/honey/honey/service/TelegramService.java index 6c7a364..4c2667e 100644 --- a/src/main/java/com/honey/honey/service/TelegramService.java +++ b/src/main/java/com/honey/honey/service/TelegramService.java @@ -28,7 +28,7 @@ public class TelegramService { * Requires channelCheckerBotToken to be configured. * * @param telegramUserId Telegram user ID - * @param chatId Chat ID (can be channel username like "@lottery_2026_test_channel" or numeric ID) + * @param chatId Chat ID (can be channel username like "@honey_channel" or numeric ID) * @return true if user is a member (member, administrator, or creator), false otherwise * @throws IllegalStateException if channelCheckerBotToken is not configured */ diff --git a/src/main/resources/db/migration/V29__set_initial_balance_a.sql b/src/main/resources/db/migration/V29__set_initial_balance_a.sql deleted file mode 100644 index 4deefc4..0000000 --- a/src/main/resources/db/migration/V29__set_initial_balance_a.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Set initial balance_a default value to 3,000,000 (3.00 tickets) --- This represents 3 tickets in bigint format (1 ticket = 1,000,000) -ALTER TABLE `db_users_b` -MODIFY COLUMN `balance_a` BIGINT UNSIGNED NOT NULL DEFAULT 3000000; - diff --git a/src/main/resources/db/migration/V50__set_initial_balance_a_5_tickets.sql b/src/main/resources/db/migration/V50__set_initial_balance_a_5_tickets.sql deleted file mode 100644 index 8094123..0000000 --- a/src/main/resources/db/migration/V50__set_initial_balance_a_5_tickets.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Set initial balance_a default value to 5,000,000 (5.00 tickets) --- New users get 5 tickets on registration (1 ticket = 1,000,000 in bigint) -ALTER TABLE `db_users_b` -MODIFY COLUMN `balance_a` BIGINT UNSIGNED NOT NULL DEFAULT 5000000; diff --git a/src/main/resources/db/migration/V51__feature_switches_referral_tasks_50_100.sql b/src/main/resources/db/migration/V51__feature_switches_referral_tasks_50_100.sql deleted file mode 100644 index ced6038..0000000 --- a/src/main/resources/db/migration/V51__feature_switches_referral_tasks_50_100.sql +++ /dev/null @@ -1 +0,0 @@ --- Feature switches: no seeds (kept empty). diff --git a/src/main/resources/db/migration/V57__seed_first_net_win_promotion.sql b/src/main/resources/db/migration/V57__seed_first_net_win_promotion.sql deleted file mode 100644 index 0642fab..0000000 --- a/src/main/resources/db/migration/V57__seed_first_net_win_promotion.sql +++ /dev/null @@ -1 +0,0 @@ --- Promotions: no seeds (tables created in V56). diff --git a/src/main/resources/db/migration/V65__feature_switch_manual_pay_for_all_payouts.sql b/src/main/resources/db/migration/V65__feature_switch_manual_pay_for_all_payouts.sql deleted file mode 100644 index ced6038..0000000 --- a/src/main/resources/db/migration/V65__feature_switch_manual_pay_for_all_payouts.sql +++ /dev/null @@ -1 +0,0 @@ --- Feature switches: no seeds (kept empty). diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 4c6dc7b..7c104be 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -10,7 +10,7 @@ - +