促销接口实现
Change-Id: I140945a50a8ee32042aaf8018b336afd86f5fbac
diff --git a/src/main/java/api/ApiController.java b/src/main/java/api/ApiController.java
index 7566108..42bc7e3 100644
--- a/src/main/java/api/ApiController.java
+++ b/src/main/java/api/ApiController.java
@@ -8,6 +8,7 @@
import java.text.ParseException;
import javax.annotation.PostConstruct;
+import javax.persistence.criteria.CriteriaBuilder.In;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
@@ -41,6 +42,8 @@
import entity.BegInfoDetail;
import entity.UserStar;
import entity.SeedWithVotes;
+import entity.SeedPromotion;
+import entity.SeedWithPromotionDTO;
import java.util.UUID;
@@ -86,7 +89,6 @@
seed.seedsize = "1GB";
seed.seedtag = tag;
seed.url = "http://example.com/torrent"; // 示例URL
- System.out.println("seed is null? " + (seed == null));
int ret = db1.RegisterSeed(seed);
if (ret != 0) {
// 如果注册种子失败,返回错误状态
@@ -126,7 +128,7 @@
@RequestParam("tag") String tag
) {
try {
- Seed[] seeds = db1.GetSeedListByTag(tag);
+ SeedWithPromotionDTO[] seeds = db1.GetSeedListByTag(tag);
if (seeds == null) {
return new ResponseEntity<>("[]", errorHeaders, HttpStatus.INTERNAL_SERVER_ERROR); // 返回 404 表示未找到种子
}
@@ -408,7 +410,6 @@
@RequestBody String requestBody
) {
try {
- System.out.println("Register request body: " + requestBody);
// 解析 JSON 数据
com.fasterxml.jackson.databind.JsonNode jsonNode = mapper.readTree(requestBody);
@@ -453,7 +454,6 @@
// 调用数据库注册方法
int ret = db1.RegisterUser(user);
- System.out.println("Register result: " + ret);
// // 如果注册成功,还需要创建对应的 UserPT 记录
// if (ret == 0) {
@@ -993,19 +993,22 @@
// 解析 JSON 数据
com.fasterxml.jackson.databind.JsonNode jsonNode = mapper.readTree(requestBody);
com.fasterxml.jackson.databind.JsonNode migrationidNode = jsonNode.get("migration_id");
- if (migrationidNode == null) {
+ com.fasterxml.jackson.databind.JsonNode grantedUploadedNode = jsonNode.get("granted_uploaded");
+ if (migrationidNode == null || grantedUploadedNode == null) {
return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 参数不完整
}
String migrationid = migrationidNode.asText();
- System.out.println("Migration ID: " + migrationid);
+ Integer grantedUploaded = grantedUploadedNode != null ? grantedUploadedNode.asInt() : null;
+ if (grantedUploaded == null || grantedUploaded < 0) {
+ return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 上传量必须为非负整数
+ }
// 添加参数验证
if (migrationid == null || migrationid.trim().isEmpty()) {
return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST);
}
- boolean ret = db1.ExamTransmitProfile(migrationid, true);
- System.out.println("Migration approval result: " + ret);
+ boolean ret = db1.ExamTransmitProfile(migrationid, true, grantedUploaded);
if (ret) {
return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
} else {
@@ -1039,7 +1042,7 @@
return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST);
}
- boolean ret = db1.ExamTransmitProfile(migrationid, false);
+ boolean ret = db1.ExamTransmitProfile(migrationid, false, 0);
if (ret) {
return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
} else {
@@ -1100,7 +1103,6 @@
@RequestParam("file") MultipartFile file
) {
try {
- System.out.println("Submit appeal request: userid=" + userid + ", content=" + content);
// 先进行参数验证
if (userid == null || userid.trim().isEmpty() ||
content == null || content.trim().isEmpty() ||
@@ -1109,16 +1111,13 @@
}
if (file.getSize() > 100 * 1024 * 1024) {
- System.out.println("File size exceeds limit: " + file.getSize() + " bytes");
return new ResponseEntity<>(3, HttpStatus.PAYLOAD_TOO_LARGE); // 返回 3 表示文件过大
}
- System.out.println("Submit appeal request: userid=" + userid + ", content=" + content);
File tempFile = File.createTempFile(userid, file.getOriginalFilename());
file.transferTo(tempFile);
int ret = cheat.SubmitAppeal(userid, content, tempFile);
- System.out.println("Submit appeal result: " + ret);
if (ret == 0) {
return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
} else if (ret == 1) {
@@ -1127,7 +1126,6 @@
return new ResponseEntity<>(2, HttpStatus.INTERNAL_SERVER_ERROR); // 返回其他状态表示失败
}
} catch (org.springframework.web.multipart.MaxUploadSizeExceededException e) {
- System.out.println("File upload size exceeded: " + e.getMessage());
return new ResponseEntity<>(3, HttpStatus.PAYLOAD_TOO_LARGE); // 返回 3 表示文件过大
} catch (JsonProcessingException e) {
e.printStackTrace();
@@ -1190,7 +1188,6 @@
} else if( "vip_downloads".equals(exchangeType) ) {
ret = db1.ExchangeMagicToVip(userid, magic);
} else {
- System.out.println("Invalid exchange type: " + exchangeType);
return new ResponseEntity<>(2, HttpStatus.BAD_REQUEST); // 返回 2 表示交换类型错误
}
if (!ret) {
@@ -1311,12 +1308,14 @@
@CrossOrigin(origins = "*", allowedHeaders = "*")
public ResponseEntity<Integer> migrateAccount(
@RequestParam("userid") String userid,
- @RequestParam("file") MultipartFile file
+ @RequestParam("file") MultipartFile file,
+ @RequestParam("uploadtogive") String uploadtogive
) {
try {
// 先进行参数验证
if (userid == null || userid.trim().isEmpty() ||
- file == null || file.isEmpty()) {
+ file == null || file.isEmpty() ||
+ uploadtogive == null || uploadtogive.trim().isEmpty()) {
return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST);
}
@@ -1327,7 +1326,7 @@
File tempFile = File.createTempFile(userid, file.getOriginalFilename());
file.transferTo(tempFile);
- int ret = db1.UploadMigration(userid, tempFile);
+ int ret = db1.UploadMigration(userid, tempFile, uploadtogive);
if (ret == 0) {
return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
} else if (ret == 1) {
@@ -1364,7 +1363,6 @@
@RequestParam("begid") String begid
) {
try {
- System.out.println("getBegSeedDetail called with begid: " + begid);
if (begid == null || begid.trim().isEmpty()) {
return new ResponseEntity<>("", errorHeaders, HttpStatus.BAD_REQUEST); // 返回 400 表示参数不完整
}
@@ -1415,7 +1413,6 @@
@RequestBody String requestBody
) {
try {
- System.out.println("submitSeed called with requestBody: " + requestBody);
com.fasterxml.jackson.databind.JsonNode jsonNode = mapper.readTree(requestBody);
com.fasterxml.jackson.databind.JsonNode begidNode = jsonNode.get("begid");
com.fasterxml.jackson.databind.JsonNode useridNode = jsonNode.get("userid");
@@ -1436,7 +1433,6 @@
}
int ret = db1.SubmitBegSeed(begid, seedid, userid);
- System.out.println("submitSeed result: " + ret);
if (ret == 0) {
return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
} else if (ret == 1) {
@@ -1545,4 +1541,95 @@
return new ResponseEntity<>(1, HttpStatus.INTERNAL_SERVER_ERROR); // 返回 1 表示处理失败
}
}
+
+ @Override
+ public ResponseEntity<String> getAllSeeds(){
+ try {
+ Seed[] allSeeds = db1.getAllSeeds();
+ if (allSeeds == null) {
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.NOT_FOUND); // 返回 404 表示未找到种子列表
+ }
+ String json = mapper.writeValueAsString(allSeeds);
+ return new ResponseEntity<>(json, headers, HttpStatus.OK);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.INTERNAL_SERVER_ERROR); // 返回 500 表示处理失败
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ @Override
+ public ResponseEntity<String> getAllSeedPromotions() {
+ try {
+ SeedPromotion[] promotions = db1.getAllSeedPromotions();
+ if (promotions == null) {
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.NOT_FOUND); // 返回 404 表示未找到种子推广
+ }
+ String json = mapper.writeValueAsString(promotions);
+ return new ResponseEntity<>(json, headers, HttpStatus.OK);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.INTERNAL_SERVER_ERROR); // 返回 500 表示处理失败
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResponseEntity<>("[]", errorHeaders, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ @Override
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public ResponseEntity<Integer> createSeedPromotion(
+ @RequestBody String requestBody
+ ) {
+ try {
+ com.fasterxml.jackson.databind.JsonNode jsonNode = mapper.readTree(requestBody);
+ com.fasterxml.jackson.databind.JsonNode seedidNode = jsonNode.get("seed_id");
+ com.fasterxml.jackson.databind.JsonNode startTimeNode = jsonNode.get("start_time");
+ com.fasterxml.jackson.databind.JsonNode endTimeNode = jsonNode.get("end_time");
+ com.fasterxml.jackson.databind.JsonNode discountNode = jsonNode.get("discount");
+
+ if (seedidNode == null || startTimeNode == null || endTimeNode == null || discountNode == null) {
+ return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 参数不完整
+ }
+
+ String seedid = seedidNode.asText();
+ Date startTime;
+ Date endTime;
+ Integer discount = discountNode.asInt();
+ if (discount == null || discount < 0) {
+ return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 折扣参数错误
+ }
+ try {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
+ String startTimeStr = startTimeNode.asText();
+ startTime = dateFormat.parse(startTimeStr);
+ String endTimeStr = endTimeNode.asText();
+ endTime = dateFormat.parse(endTimeStr);
+ } catch (ParseException e) {
+ return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 日期格式错误
+ }
+
+ if (seedid == null || seedid.trim().isEmpty() ||
+ startTime == null || endTime == null) {
+ return new ResponseEntity<>(1, HttpStatus.BAD_REQUEST); // 参数不完整
+ }
+
+ int ret = db1.createSeedPromotion(seedid, startTime, endTime, discount);
+ if (ret == 0) {
+ return new ResponseEntity<>(0, HttpStatus.OK); // 返回 0 表示成功
+ } else if (ret == 1) {
+ return new ResponseEntity<>(2, HttpStatus.CONFLICT); // 返回 1 表示创建失败或其他错误
+ } else {
+ return new ResponseEntity<>(3, HttpStatus.INTERNAL_SERVER_ERROR); // 返回其他状态表示失败
+ }
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return new ResponseEntity<>(1, HttpStatus.INTERNAL_SERVER_ERROR); // 返回 1 表示处理失败
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResponseEntity<>(1, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/api/ApiInterface.java b/src/main/java/api/ApiInterface.java
index 475b5d2..b395f7b 100644
--- a/src/main/java/api/ApiInterface.java
+++ b/src/main/java/api/ApiInterface.java
@@ -193,7 +193,8 @@
@PostMapping("/migrate-account")
ResponseEntity<Integer> migrateAccount(
@RequestParam("userid") String userid,
- @RequestParam("file") MultipartFile file
+ @RequestParam("file") MultipartFile file,
+ @RequestParam("uploadtogive") String uploadtogive
);
@GetMapping("/begseed-list")
@@ -223,4 +224,15 @@
ResponseEntity<Integer> createBegSeed(
@RequestBody String requestBody
);
+
+ @GetMapping("/all-seeds")
+ ResponseEntity<String> getAllSeeds();
+
+ @GetMapping("/all-seed-promotions")
+ ResponseEntity<String> getAllSeedPromotions();
+
+ @PostMapping("/set-seed-promotion")
+ ResponseEntity<Integer> createSeedPromotion(
+ @RequestBody String requestBody
+ );
}
\ No newline at end of file
diff --git a/src/main/java/database/DataManagerInterface.java b/src/main/java/database/DataManagerInterface.java
index 0c4dc7d..cf98f46 100644
--- a/src/main/java/database/DataManagerInterface.java
+++ b/src/main/java/database/DataManagerInterface.java
@@ -6,12 +6,15 @@
import entity.Post;
import entity.Profile;
import entity.Seed;
+import entity.SeedPromotion;
+import entity.SeedWithPromotionDTO;
import entity.User;
import entity.UserPT;
import entity.UserStar;
import entity.PostReply;
import entity.SeedWithVotes;
import java.io.File;
+import java.util.Date;
public interface DataManagerInterface{
//DB1
@@ -30,7 +33,7 @@
public int DeleteSeed(String seedid);//删除一个种子,返回状态:0 success,1 不存在,2其他原因
public Seed[] SearchSeed(String userQ);//传入搜索的关键词或句子,返回搜索到的种子信息(按照公共字符数量排序)
- public Seed[] GetSeedListByTag(String tag);//获取某个标签下的种子列表
+ public SeedWithPromotionDTO[] GetSeedListByTag(String tag);//获取某个标签下的种子列表
public Seed[] GetSeedListByUser(String userid);//获取某个用户的种子列表
public int AddNotice(Notice notice);//返回状态:0 success,1 重复,2其他原因
@@ -81,9 +84,12 @@
public boolean UploadTransmitProfile(Profile profile);
public Profile GetTransmitProfile(String profileid);//获取迁移信息
- public boolean ExamTransmitProfile(String profileid,boolean result);//审核迁移信息,0成功,1失败
+ public boolean ExamTransmitProfile(String profileid, boolean result, Integer grantedUpload);//审核迁移信息,0成功,1失败
public Profile[] GetTransmitProfileList();//获取所有迁移信息
public int InviteNewUser(String inviterid, String invitedemail);//邀请新用户,返回状态:0 success,1 重复,2其他原因
- public int UploadMigration(String userid, File file);
+ public int UploadMigration(String userid, File file, String uploadtogive);
public int createBagSeed(BegInfo begInfo, String userid, String info);
+ public Seed[] getAllSeeds(); // 获取所有种子信息
+ public SeedPromotion[] getAllSeedPromotions(); // 获取所有种子推广信息
+ public int createSeedPromotion(String seedid, Date startTime, Date endTime, Integer discount); // 添加种子推广信息
}
\ No newline at end of file
diff --git a/src/main/java/database/Database1.java b/src/main/java/database/Database1.java
index 934a6c5..98effe1 100644
--- a/src/main/java/database/Database1.java
+++ b/src/main/java/database/Database1.java
@@ -43,6 +43,8 @@
import entity.QUserVotes;
import entity.QPost;
import entity.Seed;
+import entity.SeedPromotion;
+import entity.SeedWithPromotionDTO;
import entity.User;
import entity.UserPT;
import entity.UserStar;
@@ -55,6 +57,7 @@
import entity.QUserStar;
import entity.SubmitSeed;
import entity.SubmitSeedId;
+import entity.QSeedPromotion;
import org.slf4j.Logger;
@@ -306,17 +309,37 @@
}
@Override
- public Seed[] GetSeedListByTag(String tag){
+ public SeedWithPromotionDTO[] GetSeedListByTag(String tag){
EntityManager em = createEntityManager();
try {
JPAQuery<Seed> query = new JPAQuery<>(em);
QSeed s = QSeed.seed;
QUser u = QUser.user;
+ QSeedPromotion sp = QSeedPromotion.seedPromotion;
+
// 使用 fetch join 预先加载关联的 user 对象,避免懒加载导致的 ResultSet closed 错误
List<Seed> seeds = query.select(s).from(s)
.leftJoin(s.user, u).fetchJoin()
.where(s.seedtag.eq(tag)).fetch();
- return seeds.toArray(new Seed[0]);
+
+ // 创建结果列表
+ List<SeedWithPromotionDTO> result = new ArrayList<>();
+ Date currentDate = new Date();
+
+ for (Seed seed : seeds) {
+ // 查询当前有效的促销信息
+ JPAQuery<SeedPromotion> promotionQuery = new JPAQuery<>(em);
+ SeedPromotion promotion = promotionQuery.select(sp).from(sp)
+ .where(sp.seed.seedid.eq(seed.seedid)
+ .and(sp.startTime.loe(currentDate))
+ .and(sp.endTime.goe(currentDate)))
+ .fetchOne();
+
+ Integer discount = promotion != null ? promotion.discount : null;
+ result.add(new SeedWithPromotionDTO(seed, discount));
+ }
+
+ return result.toArray(new SeedWithPromotionDTO[0]);
} finally {
em.close();
}
@@ -1472,7 +1495,7 @@
//获取迁移信息
@Override
- public boolean ExamTransmitProfile(String profileid,boolean result){
+ public boolean ExamTransmitProfile(String profileid, boolean result, Integer grantedUpload){
if (profileid == null || profileid.isEmpty()) {
logger.warn("参数无效: profileid为空");
return false;
@@ -1506,9 +1529,9 @@
profile.magicgived = String.valueOf(magicToGive);
// 发放上传量
- long uploadToGive = Long.parseLong(profile.uploadtogive);
- userPT.upload += uploadToGive;
- profile.uploadgived = String.valueOf(uploadToGive);
+ // long uploadToGive = Long.parseLong(profile.uploadtogive);
+ userPT.upload += grantedUpload;
+ profile.uploadgived = String.valueOf(grantedUpload);
em.merge(userPT);
em.merge(profile);
@@ -1722,7 +1745,7 @@
}
@Override
- public int UploadMigration(String userid, File file) {
+ public int UploadMigration(String userid, File file, String uploadtogive) {
if (userid == null || userid.isEmpty() || file == null) {
return 2; // 参数无效
}
@@ -1740,7 +1763,7 @@
Profile migration = new Profile();
migration.profileurl = java.util.UUID.randomUUID().toString();
migration.userid = userid;
- migration.uploadtogive = "0"; // 初始上传量为0
+ migration.uploadtogive = uploadtogive; // 初始上传量为0
migration.magictogive = "0"; // 初始魔力值为0
migration.downloadgived = "0"; // 初始下载量为0
migration.uploadgived = "0"; // 初始上传量为0
@@ -2012,4 +2035,103 @@
}
}
}
+
+ @Override
+ public Seed[] getAllSeeds() {
+ EntityManager entitymanager = createEntityManager();
+ try {
+ JPAQuery<Seed> query = new JPAQuery<>(entitymanager);
+ QSeed s = QSeed.seed;
+ List<Seed> seeds = query.select(s).from(s).fetch();
+ return seeds.toArray(new Seed[0]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ return new Seed[0];
+ } finally {
+ if (entitymanager != null) {
+ entitymanager.close();
+ }
+ }
+ }
+
+ @Override
+ public SeedPromotion[] getAllSeedPromotions() {
+ EntityManager entitymanager = createEntityManager();
+ try {
+ JPAQuery<SeedPromotion> query = new JPAQuery<>(entitymanager);
+ QSeedPromotion sp = QSeedPromotion.seedPromotion;
+ List<SeedPromotion> promotions = query.select(sp).from(sp).fetch();
+ return promotions.toArray(new SeedPromotion[0]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ return new SeedPromotion[0];
+ } finally {
+ if (entitymanager != null) {
+ entitymanager.close();
+ }
+ }
+ }
+
+ @Override
+ public int createSeedPromotion(String seedid, Date startTime, Date endTime, Integer discount) {
+ if (seedid == null || seedid.isEmpty() || startTime == null || endTime == null || discount == null) {
+ return 2; // 参数无效
+ }
+
+ EntityManager entitymanager = createEntityManager();
+ EntityTransaction tx = entitymanager.getTransaction();
+
+ try {
+ tx.begin();
+
+ // 检查种子是否存在
+ Seed seed = entitymanager.find(Seed.class, seedid);
+ if (seed == null) {
+ return 1; // 种子不存在
+ }
+
+ // 检查是否已存在相同的促销活动
+ QSeedPromotion sp = QSeedPromotion.seedPromotion;
+ SeedPromotion existingPromotion = new JPAQuery<>(entitymanager)
+ .select(sp)
+ .from(sp)
+ .where(sp.seed.seedid.eq(seedid))
+ .fetchOne();
+
+ // 创建新的促销活动
+ SeedPromotion promotion = new SeedPromotion();
+ promotion.promotionId = java.util.UUID.randomUUID().toString();
+ promotion.seed = seed;
+ promotion.startTime = startTime;
+ promotion.endTime = endTime;
+ promotion.discount = discount;
+
+ if (existingPromotion != null) {
+ promotion.promotionId = existingPromotion.promotionId; // 如果已存在,则使用现有的ID
+ entitymanager.merge(promotion); // 更新现有的促销活动
+ } else {
+ entitymanager.persist(promotion); // 创建新的促销活动
+ }
+
+ tx.commit();
+ return 0; // 成功
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (tx.isActive()) {
+ tx.rollback();
+ }
+ return 4; // 其他错误
+ } finally {
+ if (entitymanager != null) {
+ entitymanager.close();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/database/Database2.java b/src/main/java/database/Database2.java
index 91dc8ff..3fe0c9c 100644
--- a/src/main/java/database/Database2.java
+++ b/src/main/java/database/Database2.java
@@ -22,6 +22,8 @@
import entity.QProfile;
import entity.QSeed;
import entity.Seed;
+import entity.SeedPromotion;
+import entity.SeedWithPromotionDTO;
import entity.User;
import entity.UserPT;
import entity.config;
@@ -139,8 +141,8 @@
}
@Override
- public Seed[] GetSeedListByTag(String tag) {
- return new Seed[0];
+ public SeedWithPromotionDTO[] GetSeedListByTag(String tag) {
+ return new SeedWithPromotionDTO[0];
}
@Override
@@ -1020,7 +1022,7 @@
}
@Override
- public boolean ExamTransmitProfile(String profileid, boolean result) {
+ public boolean ExamTransmitProfile(String profileid, boolean result, Integer grantedUpload) {
if (profileid == null || profileid.isEmpty()) {
logger.warn("参数无效: profileid为空");
return false;
@@ -1144,7 +1146,7 @@
}
@Override
- public int UploadMigration(String userid, File file){
+ public int UploadMigration(String userid, File file, String uploadtogive){
return 0;
}
@@ -1231,4 +1233,19 @@
public int createBagSeed(BegInfo begInfo, String userid, String info) {
return 0;
}
+
+ @Override
+ public Seed[] getAllSeeds() {
+ return null;
+ }
+
+ @Override
+ public SeedPromotion[] getAllSeedPromotions() {
+ return null;
+ }
+
+ @Override
+ public int createSeedPromotion(String seedid, Date startTime, Date endTime, Integer discount) {
+ return 0;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/entity/SeedWithPromotionDTO.java b/src/main/java/entity/SeedWithPromotionDTO.java
new file mode 100644
index 0000000..fe8087a
--- /dev/null
+++ b/src/main/java/entity/SeedWithPromotionDTO.java
@@ -0,0 +1,37 @@
+package entity;
+
+import java.util.Date;
+
+public class SeedWithPromotionDTO {
+ public String seedid;
+ public String seeduserid;
+ public String username; // 只包含用户名,而不是整个User对象
+ public int faketime;
+ public Date lastfakecheck;
+ public String outurl;
+ public String title;
+ public String subtitle;
+ public String seedsize;
+ public String seedtag;
+ public int downloadtimes;
+ public String url;
+ public Integer discount; // 促销折扣,可能为null如果没有促销
+
+ public SeedWithPromotionDTO() {}
+
+ public SeedWithPromotionDTO(Seed seed, Integer discount) {
+ this.seedid = seed.seedid;
+ this.seeduserid = seed.seeduserid;
+ this.username = seed.user != null ? seed.user.username : null;
+ this.faketime = seed.faketime;
+ this.lastfakecheck = seed.lastfakecheck;
+ this.outurl = seed.outurl;
+ this.title = seed.title;
+ this.subtitle = seed.subtitle;
+ this.seedsize = seed.seedsize;
+ this.seedtag = seed.seedtag;
+ this.downloadtimes = seed.downloadtimes;
+ this.url = seed.url;
+ this.discount = discount;
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 3c8a9f3..f0b6c8a 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-server.port=8082
+server.port=9999
# 文件上传配置
spring.servlet.multipart.max-file-size=100MB