package com.izouma.dingdong.domain.backstage;

import com.izouma.dingdong.domain.BaseEntity;
import com.izouma.dingdong.domain.merchant.Merchant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Builder
@Where(clause = "enabled = 1")
@ApiModel(value = "首页推荐位")
public class Promote extends BaseEntity {

    @ApiModelProperty(value = "商家ID", name = "merchantId")
    private Long merchantId;

    /**
     * 推广位:1主推广 2副推广
     */
    @ApiModelProperty(value = "位置", name = "action")
    private Integer action;

    @ApiModelProperty(value = "推广开始时间", name = "startDateTime")
    private LocalDateTime startDateTime;

    @ApiModelProperty(value = "推广结束时间", name = "startEndTime")
    private LocalDateTime endDateTime;

    @Column(nullable = false)
    private Boolean enabled = true;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "merchantId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private Merchant merchant;

}
