blob: c77f73d7bfa0a53583083df92d186ebbcfb13aee [file] [log] [blame]
rootff0769a2025-05-18 17:24:41 +00001package entity;
2
3public class config {
rhje18c3f72025-06-08 00:27:01 +08004 // 可配置的参数 - 使用静态变量而非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-codingdc575b82025-06-06 00:27:13 +080011 public static final String SqlURL = "10.126.59.25:3306";
Raverf79fdb62025-06-03 06:02:49 +000012 public static final String Database = "pt_database_test";
rootd4959a82025-05-27 07:07:37 +000013 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";
rhje18c3f72025-06-08 00:27:01 +080017 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 }
TRM-coding508b31f2025-06-09 02:07:14 +080088 // public static final String trackerHost="0.0.0.0";
89 // public static final int trackerPort=6969;
90 // public static final int capturePort=6670;
rootff0769a2025-05-18 17:24:41 +000091}