更新求种后端函数
Change-Id: I9e593e5eecfc6337120f75b3f6338f8279579dd1
diff --git a/src/main/java/entity/Admin.java b/src/main/java/entity/Admin.java
new file mode 100644
index 0000000..d943295
--- /dev/null
+++ b/src/main/java/entity/Admin.java
@@ -0,0 +1,25 @@
+package entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.querydsl.core.annotations.QueryEntity;
+
+@QueryEntity
+@Entity(name = "Admin")
+@Table(name = "admin")
+public class Admin {
+
+ @Id
+ @Column(name = "user_id", length = 36, nullable = false)
+ public String userId;
+
+ public Admin() {
+ }
+
+ public Admin(String userId) {
+ this.userId = userId;
+ }
+}
diff --git a/src/main/java/entity/BegInfoDetail.java b/src/main/java/entity/BegInfoDetail.java
new file mode 100644
index 0000000..75bd842
--- /dev/null
+++ b/src/main/java/entity/BegInfoDetail.java
@@ -0,0 +1,35 @@
+package entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "BegDetail")
+public class BegInfoDetail {
+ @Id
+ @Column(name = "beg_id", length = 64, nullable = false)
+ public String begId;
+
+ @Column(name = "user_id", length = 36, nullable = false)
+ public String userId;
+
+ @Column(name = "Info", nullable = false, columnDefinition = "TEXT")
+ public String info;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "user_id", insertable = false, updatable = false)
+ public User user;
+
+ public BegInfoDetail() {}
+
+ public BegInfoDetail(String begId, String userId, String info) {
+ this.begId = begId;
+ this.userId = userId;
+ this.info = info;
+ }
+}
diff --git a/src/main/java/entity/BegSeedDetail.java b/src/main/java/entity/BegSeedDetail.java
new file mode 100644
index 0000000..82dd9ec
--- /dev/null
+++ b/src/main/java/entity/BegSeedDetail.java
@@ -0,0 +1,45 @@
+package entity;
+
+import java.util.Date;
+
+/**
+ * 包含 BegSeed 表数据和对应 BegInfo 表 Info 字段的复合类
+ * 用于 getBegSeedDetail 方法返回完整的求种详情
+ */
+public class BegSeedDetail {
+ // BegSeed 表的字段
+ public String begid;
+ public int begnumbers;
+ public int magic;
+ public Date endtime;
+ public int hasseed;
+
+ // BegInfo 表的 Info 字段
+ public String info;
+
+ public BegSeedDetail() {}
+
+ public BegSeedDetail(String begid, int begnumbers, int magic, Date endtime, int hasseed, String info) {
+ this.begid = begid;
+ this.begnumbers = begnumbers;
+ this.magic = magic;
+ this.endtime = endtime;
+ this.hasseed = hasseed;
+ this.info = info;
+ }
+
+ // 从 BegInfo 和 BegInfoDetail 构造
+ public BegSeedDetail(BegInfo begInfo, BegInfoDetail begInfoDetail) {
+ if (begInfo != null) {
+ this.begid = begInfo.begid;
+ this.begnumbers = begInfo.begnumbers;
+ this.magic = begInfo.magic;
+ this.endtime = begInfo.endtime;
+ this.hasseed = begInfo.hasseed;
+ }
+
+ if (begInfoDetail != null) {
+ this.info = begInfoDetail.info;
+ }
+ }
+}
diff --git a/src/main/java/entity/SeedWithVotes.java b/src/main/java/entity/SeedWithVotes.java
new file mode 100644
index 0000000..96a2ba1
--- /dev/null
+++ b/src/main/java/entity/SeedWithVotes.java
@@ -0,0 +1,17 @@
+package entity;
+
+/**
+ * 包含种子信息和投票数的复合类
+ */
+public class SeedWithVotes {
+ public Seed seed;
+ public int votes;
+
+ public SeedWithVotes() {
+ }
+
+ public SeedWithVotes(Seed seed, int votes) {
+ this.seed = seed;
+ this.votes = votes;
+ }
+}
diff --git a/src/main/java/entity/config.java b/src/main/java/entity/config.java
index 3b9341b..0230066 100644
--- a/src/main/java/entity/config.java
+++ b/src/main/java/entity/config.java
@@ -1,19 +1,88 @@
package entity;
public class config {
- public static final String TrackerURL="";
- public static final int FarmNumber=3;
- public static final int FakeTime=3;
- public static final int BegVote=3;
- public static final int CheatTime=5;
- // 请根据实际环境修改为可达的地址
+ // 可配置的参数 - 使用静态变量而非final,以便动态修改
+ private static int farmNumber = 3;
+ private static int fakeTime = 3;
+ private static int begVote = 3;
+ private static int cheatTime = 5;
+
+ // 数据库相关配置 - 保持final,因为运行时不应修改
public static final String SqlURL = "10.126.59.25:3306";
public static final String Database = "pt_database_test";
public static final String TestDatabase = "pt_database_test";
public static final String SqlPassword = "123456";
public static final String SqlUsername = "root";
public static final String TORRENT_STORAGE_DIR = "torrents";
- public static final String trackerHost="0.0.0.0";
- public static final int trackerPort=6969;
- public static final int capturePort=6970;
+ public static final String APPEAL_STORAGE_DIR = "appeals";
+ public static final String MIGRATION_STORAGE_DIR = "migrations";
+ public static final String trackerHost = "0.0.0.0";
+ public static final int trackerPort = 6969;
+ public static final int capturePort = 6970;
+
+ // FarmNumber 的 getter 和 setter
+ public static int getFarmNumber() {
+ return farmNumber;
+ }
+
+ public static void setFarmNumber(int farmNumber) {
+ if (farmNumber > 0) {
+ config.farmNumber = farmNumber;
+ } else {
+ throw new IllegalArgumentException("FarmNumber must be positive");
+ }
+ }
+
+ // FakeTime 的 getter 和 setter
+ public static int getFakeTime() {
+ return fakeTime;
+ }
+
+ public static void setFakeTime(int fakeTime) {
+ if (fakeTime > 0) {
+ config.fakeTime = fakeTime;
+ } else {
+ throw new IllegalArgumentException("FakeTime must be positive");
+ }
+ }
+
+ // BegVote 的 getter 和 setter
+ public static int getBegVote() {
+ return begVote;
+ }
+
+ public static void setBegVote(int begVote) {
+ if (begVote > 0) {
+ config.begVote = begVote;
+ } else {
+ throw new IllegalArgumentException("BegVote must be positive");
+ }
+ }
+
+ // CheatTime 的 getter 和 setter
+ public static int getCheatTime() {
+ return cheatTime;
+ }
+
+ public static void setCheatTime(int cheatTime) {
+ if (cheatTime > 0) {
+ config.cheatTime = cheatTime;
+ } else {
+ throw new IllegalArgumentException("CheatTime must be positive");
+ }
+ }
+
+ // 获取所有配置参数的方法
+ public static String getAllConfigs() {
+ return String.format("Config: FarmNumber=%d, FakeTime=%d, BegVote=%d, CheatTime=%d",
+ farmNumber, fakeTime, begVote, cheatTime);
+ }
+
+ // 重置所有参数为默认值
+ public static void resetToDefaults() {
+ farmNumber = 3;
+ fakeTime = 3;
+ begVote = 3;
+ cheatTime = 5;
+ }
}