package com.sqx.modules.activity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
import java.util.List;

/**
 * 活动信息
 *
 * @author : codingliang
 * @date : 2024-06-17 16:08
 */
@Data
@ApiModel(value = "活动信息")
public class ActivityDTO {

    @ApiModelProperty(value = "活动id，修改时不能为空")
    private Long id;

    @ApiModelProperty(value = "活动标题", required = true)
    @NotBlank(message = "活动标题不能为空")
    private String title;

    @ApiModelProperty(value = "活动描述", required = true)
    @NotBlank(message = "活动描述不能为空")
    private String content;

    @ApiModelProperty(value = "活动图片", required = true)
    @NotBlank(message = "活动图片不能为空")
    private String image;

    @ApiModelProperty(value = "是否启用;0否 1是", required = true)
    @NotBlank(message = "是否启用不能为空")
    @Pattern(regexp = "(0|1)", message = "是否启用只能为0或1")
    private String enableFlag;

    @ApiModelProperty(value = "是否允许商户主动加入;0否 1是", required = true)
    @NotBlank(message = "是否允许商户主动加入不能为空")
    @Pattern(regexp = "(0|1)", message = "是否允许商户主动加入只能为0或1")
    private String allowShop;

    @ApiModelProperty(value = "活动类型;1普通活动、2时段优惠、3满额优惠、4全场优惠", required = true)
    @NotBlank(message = "活动类型不能为空")
    @Pattern(regexp = "[1-4]", message = "活动类型只能为1-4")
    private String type;

    @ApiModelProperty(value = "活动开始时间 yyyy-MM-dd HH:mm:ss", required = true)
    @NotNull(message = "活动开始时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "活动结束时间 yyy-MM-dd HH:mm:ss", required = true)
    @NotNull(message = "活动结束时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    @Valid
    @ApiModelProperty(value = "优惠时段信息列表;type为2时该字段不能为空")
    private List<ActivityOfTimeIntervalDTO> timeIntervalInfos;

    @Valid
    @ApiModelProperty(value = "满减字段优惠;type为3时该字段不能为空")
    private ActivityOfFullReductionDTO fullReductionInfo;

    @Valid
    @ApiModelProperty(value = "全场优惠;type为4时该字段不能为空")
    private ActivityOfGlobalDiscountDTO globalDiscountsInfo;
}
