root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 1 | package entity; |
| 2 | |
| 3 | public class config { |
rhj | e18c3f7 | 2025-06-08 00:27:01 +0800 | [diff] [blame] | 4 | // 可配置的参数 - 使用静态变量而非final,以便动态修改 |
| 5 | private static int farmNumber = 3; |
| 6 | private static int fakeTime = 3; |
| 7 | private static int begVote = 3; |
| 8 | private static int cheatTime = 5; |
| 9 | |
| 10 | // 数据库相关配置 - 保持final,因为运行时不应修改 |
TRM-coding | dc575b8 | 2025-06-06 00:27:13 +0800 | [diff] [blame] | 11 | public static final String SqlURL = "10.126.59.25:3306"; |
Raver | f79fdb6 | 2025-06-03 06:02:49 +0000 | [diff] [blame] | 12 | public static final String Database = "pt_database_test"; |
root | d4959a8 | 2025-05-27 07:07:37 +0000 | [diff] [blame] | 13 | public static final String TestDatabase = "pt_database_test"; |
| 14 | public static final String SqlPassword = "123456"; |
| 15 | public static final String SqlUsername = "root"; |
| 16 | public static final String TORRENT_STORAGE_DIR = "torrents"; |
rhj | e18c3f7 | 2025-06-08 00:27:01 +0800 | [diff] [blame] | 17 | public static final String APPEAL_STORAGE_DIR = "appeals"; |
| 18 | public static final String MIGRATION_STORAGE_DIR = "migrations"; |
| 19 | public static final String trackerHost = "0.0.0.0"; |
| 20 | public static final int trackerPort = 6969; |
| 21 | public static final int capturePort = 6970; |
| 22 | |
| 23 | // FarmNumber 的 getter 和 setter |
| 24 | public static int getFarmNumber() { |
| 25 | return farmNumber; |
| 26 | } |
| 27 | |
| 28 | public static void setFarmNumber(int farmNumber) { |
| 29 | if (farmNumber > 0) { |
| 30 | config.farmNumber = farmNumber; |
| 31 | } else { |
| 32 | throw new IllegalArgumentException("FarmNumber must be positive"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // FakeTime 的 getter 和 setter |
| 37 | public static int getFakeTime() { |
| 38 | return fakeTime; |
| 39 | } |
| 40 | |
| 41 | public static void setFakeTime(int fakeTime) { |
| 42 | if (fakeTime > 0) { |
| 43 | config.fakeTime = fakeTime; |
| 44 | } else { |
| 45 | throw new IllegalArgumentException("FakeTime must be positive"); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // BegVote 的 getter 和 setter |
| 50 | public static int getBegVote() { |
| 51 | return begVote; |
| 52 | } |
| 53 | |
| 54 | public static void setBegVote(int begVote) { |
| 55 | if (begVote > 0) { |
| 56 | config.begVote = begVote; |
| 57 | } else { |
| 58 | throw new IllegalArgumentException("BegVote must be positive"); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // CheatTime 的 getter 和 setter |
| 63 | public static int getCheatTime() { |
| 64 | return cheatTime; |
| 65 | } |
| 66 | |
| 67 | public static void setCheatTime(int cheatTime) { |
| 68 | if (cheatTime > 0) { |
| 69 | config.cheatTime = cheatTime; |
| 70 | } else { |
| 71 | throw new IllegalArgumentException("CheatTime must be positive"); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // 获取所有配置参数的方法 |
| 76 | public static String getAllConfigs() { |
| 77 | return String.format("Config: FarmNumber=%d, FakeTime=%d, BegVote=%d, CheatTime=%d", |
| 78 | farmNumber, fakeTime, begVote, cheatTime); |
| 79 | } |
| 80 | |
| 81 | // 重置所有参数为默认值 |
| 82 | public static void resetToDefaults() { |
| 83 | farmNumber = 3; |
| 84 | fakeTime = 3; |
| 85 | begVote = 3; |
| 86 | cheatTime = 5; |
| 87 | } |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 88 | } |