| | |
| | | import com.ruoyi.system.api.domain.dto.MgtBaseDto; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Range; |
| | | |
| | | import javax.validation.constraints.AssertTrue; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | private Integer useScope; |
| | | |
| | | @ApiModelProperty(value = "有效期类型1.时间段2.领取之日起") |
| | | @Range(min = 1, max = 2, message = "有效期类型只能是1或2") |
| | | private Integer validTimeType; |
| | | |
| | | @ApiModelProperty(value = "有效开始时间") |
| | |
| | | |
| | | @ApiModelProperty("分享图片") |
| | | private String sharePic; |
| | | // 自定义校验逻辑 |
| | | @AssertTrue(message = "当有效期类型为时间段时,有效开始时间和有效截止时间不能为空") |
| | | public boolean isValidTimeRange() { |
| | | if (validTimeType == null) return true; // 由@NotNull校验 |
| | | if (validTimeType == 1) { |
| | | return validStartTime != null && validEndTime != null; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @AssertTrue(message = "当有效期类型为领取之日起时,有效期不能为空且必须大于0") |
| | | public boolean isValidDay() { |
| | | if (validTimeType == null) return true; |
| | | if (validTimeType == 2) { |
| | | return validDay != null && validDay > 0; |
| | | } |
| | | return true; |
| | | } |
| | | } |