后台完成修复,初始化项目
This commit is contained in:
164
src/main/java/com/org/flashsalesystem/dto/FlashSaleDTO.java
Normal file
164
src/main/java/com/org/flashsalesystem/dto/FlashSaleDTO.java
Normal file
@@ -0,0 +1,164 @@
|
||||
package com.org.flashsalesystem.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 秒杀活动数据传输对象
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FlashSaleDTO {
|
||||
|
||||
private Long id;
|
||||
private Long productId;
|
||||
private String productName;
|
||||
private String productImageUrl;
|
||||
private BigDecimal originalPrice;
|
||||
private BigDecimal flashPrice;
|
||||
private Integer flashStock;
|
||||
private Integer remainingStock;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
// 活动状态描述
|
||||
private String statusDescription;
|
||||
// 是否可以参与秒杀
|
||||
private Boolean canParticipate;
|
||||
// 距离开始时间(毫秒)
|
||||
private Long timeToStart;
|
||||
// 距离结束时间(毫秒)
|
||||
private Long timeToEnd;
|
||||
|
||||
/**
|
||||
* 创建秒杀活动DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CreateDTO {
|
||||
@NotNull(message = "商品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
@NotNull(message = "秒杀价格不能为空")
|
||||
@DecimalMin(value = "0.01", message = "秒杀价格必须大于0")
|
||||
private BigDecimal flashPrice;
|
||||
|
||||
@Min(value = 1, message = "秒杀库存必须大于0")
|
||||
private Integer flashStock;
|
||||
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新秒杀活动DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class UpdateDTO {
|
||||
@DecimalMin(value = "0.01", message = "秒杀价格必须大于0")
|
||||
private BigDecimal flashPrice;
|
||||
|
||||
@Min(value = 1, message = "秒杀库存必须大于0")
|
||||
private Integer flashStock;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Min(value = 1, message = "状态值无效")
|
||||
@Max(value = 3, message = "状态值无效")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀参与DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ParticipateDTO {
|
||||
@NotNull(message = "秒杀活动ID不能为空")
|
||||
private Long flashSaleId;
|
||||
|
||||
@Min(value = 1, message = "购买数量必须大于0")
|
||||
private Integer quantity = 1;
|
||||
|
||||
// 用户地址信息(可选)
|
||||
private String address;
|
||||
private String phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀查询DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class QueryDTO {
|
||||
private Integer status; // 活动状态
|
||||
private Long productId; // 商品ID
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
private Integer page = 0;
|
||||
private Integer size = 10;
|
||||
private String sortBy = "startTime";
|
||||
private String sortDirection = "asc";
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀结果DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ResultDTO {
|
||||
private Boolean success;
|
||||
private String message;
|
||||
private Long orderId;
|
||||
private Long flashSaleId;
|
||||
private Long productId;
|
||||
private String productName;
|
||||
private Integer quantity;
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime orderTime;
|
||||
|
||||
// 排队信息(如果需要排队)
|
||||
private Integer queuePosition;
|
||||
private Long estimatedWaitTime;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user