package com.bonus.canteen.core.android.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.time.LocalTime;
import java.util.List;

/**
 * @author 19814
 */
@Data
@ToString
@ApiModel("下发菜谱详情")
public class CookRecipeIntervalCompressVO implements Serializable {
   @ApiModelProperty("餐次id")
   private Long intervalId;
   @ApiModelProperty("餐次名称")
   private String intervalName;
   @ApiModelProperty("餐次开始时间")
   @JsonFormat(
      pattern = "HH:mm:ss"
   )
   @JsonSerialize(
      using = LocalTimeSerializer.class
   )
   @JsonDeserialize(
      using = LocalTimeDeserializer.class
   )
   private LocalTime startTime;
   @ApiModelProperty("餐次结束时间")
   @JsonFormat(
      pattern = "HH:mm:ss"
   )
   @JsonSerialize(
      using = LocalTimeSerializer.class
   )
   @JsonDeserialize(
      using = LocalTimeDeserializer.class
   )
   private LocalTime endTime;
   @ApiModelProperty("餐品列表")
   private List<CookRecipeDetailCompressVO> productList;

   public String getIntervalName() {
      return CookMealtimeTypeEnum.getDescByKey(this.intervalId.intValue());
   }

   @JsonFormat(
      pattern = "HH:mm:ss"
   )
   @JsonDeserialize(
      using = LocalTimeDeserializer.class
   )
   public void setStartTime(final LocalTime startTime) {
      this.startTime = startTime;
   }

   @JsonFormat(
      pattern = "HH:mm:ss"
   )
   @JsonDeserialize(
      using = LocalTimeDeserializer.class
   )
   public void setEndTime(final LocalTime endTime) {
      this.endTime = endTime;
   }
}
