package com.bonus.core.device.manage.vo;

import cn.hutool.core.bean.BeanUtil;
import com.bonus.core.allocation.canteen.model.AllocCanteen;
import com.bonus.core.allocation.canteen.model.AllocStall;
import com.bonus.core.device.manage.model.DeviceRecipe;
import com.bonus.framework.config.deserializer.TimeDeserializer;
import com.bonus.framework.config.serializer.TimeSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalTime;

public class DeviceRecipeVO {
   @ApiModelProperty("主键id")
   private Long id;
   @ApiModelProperty("设备id")
   private Long deviceId;
   @ApiModelProperty("食堂id")
   private Long canteenId;
   @ApiModelProperty("店铺档口id")
   private Long stallId;
   @ApiModelProperty("菜谱id")
   private Long recipeId;
   @ApiModelProperty("食堂名称")
   private String canteenName;
   @ApiModelProperty("菜谱名称")
   private String recipeName;
   @ApiModelProperty("档口名称")
   private String stallName;
   @ApiModelProperty("档口图片地址")
   private String stallImgUrl;
   @ApiModelProperty("档口是否营业")
   private Integer stallIfOpen;
   @ApiModelProperty("档口营业时间  档口是否营业")
   @JsonSerialize(
      using = TimeSerializer.HH_MM_SS.class
   )
   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   private LocalTime stallStaTime;
   @ApiModelProperty("档口营业结束时间")
   @JsonSerialize(
      using = TimeSerializer.HH_MM_SS.class
   )
   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   private LocalTime stallEndTime;

   public static DeviceRecipeVO of(DeviceRecipe deviceRecipe, AllocStall stall, AllocCanteen canteen, String recipeName) {
      DeviceRecipeVO vo = (DeviceRecipeVO)BeanUtil.toBean(deviceRecipe, DeviceRecipeVO.class);
      BeanUtil.copyProperties(deviceRecipe, vo, new String[0]);
      vo.setStallName(stall != null ? stall.getStallName() : "");
      vo.setStallImgUrl(stall != null ? stall.getImgUrl() : "");
      vo.setStallIfOpen(stall != null ? stall.getBusinessState() : null);
      vo.setStallStaTime(stall != null ? stall.getStartBusinessTime() : null);
      vo.setStallEndTime(stall != null ? stall.getEndBusinessTime() : null);
      vo.setCanteenName(canteen != null ? canteen.getCanteenName() : "");
      vo.setRecipeName(recipeName);
      return vo;
   }

   public Long getId() {
      return this.id;
   }

   public Long getDeviceId() {
      return this.deviceId;
   }

   public Long getCanteenId() {
      return this.canteenId;
   }

   public Long getStallId() {
      return this.stallId;
   }

   public Long getRecipeId() {
      return this.recipeId;
   }

   public String getCanteenName() {
      return this.canteenName;
   }

   public String getRecipeName() {
      return this.recipeName;
   }

   public String getStallName() {
      return this.stallName;
   }

   public String getStallImgUrl() {
      return this.stallImgUrl;
   }

   public Integer getStallIfOpen() {
      return this.stallIfOpen;
   }

   public LocalTime getStallStaTime() {
      return this.stallStaTime;
   }

   public LocalTime getStallEndTime() {
      return this.stallEndTime;
   }

   public void setId(final Long id) {
      this.id = id;
   }

   public void setDeviceId(final Long deviceId) {
      this.deviceId = deviceId;
   }

   public void setCanteenId(final Long canteenId) {
      this.canteenId = canteenId;
   }

   public void setStallId(final Long stallId) {
      this.stallId = stallId;
   }

   public void setRecipeId(final Long recipeId) {
      this.recipeId = recipeId;
   }

   public void setCanteenName(final String canteenName) {
      this.canteenName = canteenName;
   }

   public void setRecipeName(final String recipeName) {
      this.recipeName = recipeName;
   }

   public void setStallName(final String stallName) {
      this.stallName = stallName;
   }

   public void setStallImgUrl(final String stallImgUrl) {
      this.stallImgUrl = stallImgUrl;
   }

   public void setStallIfOpen(final Integer stallIfOpen) {
      this.stallIfOpen = stallIfOpen;
   }

   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   public void setStallStaTime(final LocalTime stallStaTime) {
      this.stallStaTime = stallStaTime;
   }

   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   public void setStallEndTime(final LocalTime stallEndTime) {
      this.stallEndTime = stallEndTime;
   }

}
