种子,促销
Change-Id: I0ce919ce4228dcefec26ef636bacd3298c0dc77a
diff --git a/src/main/java/com/example/myproject/dto/PromotionCreateDTO.java b/src/main/java/com/example/myproject/dto/PromotionCreateDTO.java
new file mode 100644
index 0000000..211979b
--- /dev/null
+++ b/src/main/java/com/example/myproject/dto/PromotionCreateDTO.java
@@ -0,0 +1,35 @@
+package com.example.myproject.dto;
+
+import lombok.Data;
+import javax.validation.constraints.*;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+public class PromotionCreateDTO {
+ @NotBlank(message = "促销名称不能为空")
+ @Size(max = 100, message = "促销名称长度不能超过100个字符")
+ private String name;
+
+ @Size(max = 500, message = "描述长度不能超过500个字符")
+ private String description;
+
+ @NotNull(message = "开始时间不能为空")
+ private LocalDateTime startTime;
+
+ @NotNull(message = "结束时间不能为空")
+ private LocalDateTime endTime;
+
+ @NotNull(message = "折扣比例不能为空")
+ @Min(value = 0, message = "折扣比例不能小于0")
+ @Max(value = 100, message = "折扣比例不能大于100")
+ private double discountPercentage;
+
+ @NotEmpty(message = "适用种子列表不能为空")
+ private List<Long> applicableTorrentIds;
+
+ @AssertTrue(message = "结束时间必须晚于开始时间")
+ public boolean isEndTimeAfterStartTime() {
+ return endTime != null && startTime != null && endTime.isAfter(startTime);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/dto/TorrentUpdateDTO.java b/src/main/java/com/example/myproject/dto/TorrentUpdateDTO.java
new file mode 100644
index 0000000..4b09321
--- /dev/null
+++ b/src/main/java/com/example/myproject/dto/TorrentUpdateDTO.java
@@ -0,0 +1,24 @@
+package com.example.myproject.dto;
+
+import lombok.Data;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+@Data
+public class TorrentUpdateDTO {
+ @NotBlank(message = "标题不能为空")
+ @Size(max = 30, message = "名称长度不能超过30个字符")
+ private String title;
+
+ @Size(max = 1000, message = "描述长度不能超过1000个字符")
+ private String description;
+
+ @NotBlank(message = "分类不能为空")
+ private String category;
+
+
+ private String tags;
+ @NotBlank(message = "封面不能为空")
+
+ private String imageUrl;
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/dto/param/TorrentParam.java b/src/main/java/com/example/myproject/dto/param/TorrentParam.java
new file mode 100644
index 0000000..1ef832b
--- /dev/null
+++ b/src/main/java/com/example/myproject/dto/param/TorrentParam.java
@@ -0,0 +1,43 @@
+package com.example.myproject.dto.param;
+
+import com.example.myproject.common.base.OrderPageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * 种子查询参数
+ */
+@Data
+@Schema(description = "种子查询参数")
+public class TorrentParam extends OrderPageParam {
+
+ @Schema(description = "关键字")
+ private String keyword;
+
+ @Schema(description = "分类")
+ private String category;
+
+ @Schema(description = "促销种子")
+ private String free;
+
+ private Set<String> likeExpressions;
+
+ public void buildLike() {
+ likeExpressions = new LinkedHashSet<>();
+ if (StringUtils.isEmpty(keyword)) {
+ return;
+ }
+ keyword = keyword.replace(".", " ");
+ String[] searchstrExploded = keyword.split(" ");
+ for (int i = 0; i < searchstrExploded.length && i < 10; i++) {
+ String searchstrElement = searchstrExploded[i].trim();
+ if (!searchstrElement.isEmpty()) {
+ likeExpressions.add(searchstrElement);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/dto/param/TorrentUploadParam.java b/src/main/java/com/example/myproject/dto/param/TorrentUploadParam.java
new file mode 100644
index 0000000..6ede468
--- /dev/null
+++ b/src/main/java/com/example/myproject/dto/param/TorrentUploadParam.java
@@ -0,0 +1,28 @@
+package com.example.myproject.dto.param;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@Schema(description = "种子上传参数")
+public class TorrentUploadParam {
+ @Schema(description = "上传者")
+ private String uploader;
+
+ @Schema(description = "种子标题")
+ private String title;
+
+ @Schema(description = "种子描述")
+ private String description;
+
+ @Schema(description = "种子标签")
+ private String tags;
+
+ @Schema(description = "种子分类")
+ private String category;
+
+ @Schema(description = "种子封面图 URL")
+ private String imageUrl;
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/dto/vo/TorrentVO.java b/src/main/java/com/example/myproject/dto/vo/TorrentVO.java
new file mode 100644
index 0000000..e723cb3
--- /dev/null
+++ b/src/main/java/com/example/myproject/dto/vo/TorrentVO.java
@@ -0,0 +1,105 @@
+package com.example.myproject.dto.vo;
+
+import java.time.LocalDateTime;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import lombok.Data;
+
+@Data
+public class TorrentVO {
+ /**
+ * 种子ID
+ */
+ @Schema(description = "种子ID")
+ private Long id;
+
+ /**
+ * 标题
+ */
+ @NotEmpty
+ @Schema(description = "标题")
+ private String title;
+
+
+ /**
+ * 封面
+ */
+ @Schema(description = "封面")
+ private String imageUrl;
+ /**
+ * 描述
+ */
+ @NotEmpty
+ @Schema(description = "描述")
+ private String description;
+
+ /**
+ * 类别
+ */
+ @NotNull
+ @Schema(description = "类别")
+ private String category;
+
+
+ /**
+ * 添加日期
+ */
+ @Schema(description = "添加日期")
+ private LocalDateTime createTime;
+
+ /**
+ * 修改日期
+ */
+ @Schema(description = "修改日期")
+ private LocalDateTime updateTime;
+
+ /**
+ * 上传者
+ */
+ @Schema(description = "上传者")
+ private String uploader;
+ /**
+ * 文件大小
+ */
+ @Schema(description = "文件大小")
+ private Long size;
+
+
+
+ /**
+ * 评论数
+ */
+ @Schema(description = "评论数")
+ private Integer comments;
+ /**
+ * 浏览次数
+ */
+ @Schema(description = "浏览次数")
+ private Integer views;
+ /**
+ * 点击次数
+ */
+ @Schema(description = "点击次数")
+ private Integer hits;
+
+
+ /**
+ * 下载数
+ */
+ @Schema(description = "下载数")
+ private Integer leechers;
+ /**
+ * 做种数
+ */
+ @Schema(description = "做种数")
+ private Integer seeders;
+
+ /**
+ * 完成次数
+ */
+ @Schema(description = "完成次数")
+ private Integer completions;
+
+}