package com.xunmei.common.core.utils;

import com.xunmei.common.core.utils.snowId.DateHelper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.Date;

/**
 * 年月日
 */
@ApiModel(description = "年月日")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Ymd {

    public static Ymd of() {
        return of(new Date());
    }

    /**
     * @param date
     * @return
     */
    public static Ymd of(final Date date) {
        final DateHelper dateHelper = new DateHelper(date);
        return Ymd.builder()
                  .date(dateHelper.getDateTime())
                  .year(dateHelper.getYear())
                  .month(dateHelper.getMonth())
                  .day(dateHelper.getDate())
                  .week(dateHelper.getWeek())
                  .quarter(dateHelper.getQuarter())
                  .halfyear(dateHelper.getHalfyear())
                  .hour(dateHelper.getHour())
                  .minute(dateHelper.getMin())
                  .build();
    }

    @ApiModelProperty("年月日")
    private Date date;

    @ApiModelProperty("年")
    private Integer year;

    @ApiModelProperty("月")
    private Integer month;

    @ApiModelProperty("日")
    private Integer day;

    @ApiModelProperty("周")
    private Integer week;

    @ApiModelProperty("季")
    private Integer quarter;

    @ApiModelProperty("半年")
    private Integer halfyear;

    @ApiModelProperty("小时")
    private Integer hour;

    @ApiModelProperty("分钟")
    private Integer minute;

    Long orgId;
    boolean isEnable;
    public boolean isAfter(final Date date) {
        return this.date.after(date);
    }
}
