package com.yungoushangcheng.yungou.model;

import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.context.annotation.Scope;

import javax.persistence.*;
import java.util.List;

/**
 * Created by bonismo@hotmail.com
 * 上午12:09 on 16/6/9.
 *
 * 云购期详情
 */
@Entity(name = "Issue")
@Scope("prototype")
public class Issue extends BaseModel {

    private int id;

    // 参与云购的商品
    private Goods goods;

    // 已云购次数
    private int done;

    // 云购是否结束 true/false 字段
    private String over;

    // 云购开始时间
    private String start;

    // 云购结束时间
    private String finish;

    // 云购号码计算详情
    @JSONField(serialize = false)
    private Calculator calculator;

    // 云购幸运中奖详情(云购获奖用户/云购商品)
    @JSONField(serialize = false)
    private Lucky lucky;

    // 云购记录详情(云购号码/云购本期号码/云购用户/云购商品)
    @JSONField(serialize = false)
    private List<Annal> annal;

    // 云购期号码
    @JSONField(serialize = false)
    private List<Number> numbers;

    // 云购商品详情(总价/云购次数/云购期是否完成/云购期号)
    @JSONField(serialize = false)
    private Cart cart;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return id;
    }

    @ManyToOne(targetEntity = Goods.class,cascade = CascadeType.REFRESH)
    public Goods getGoods() {
        return goods;
    }

    public int getDone() {
        return done;
    }

    public String getOver() {
        return over;
    }

    @Column(length = 30)
    public String getStart() {
        return start;
    }

    @Column(length = 10)
    public String getFinish() {
        return finish;
    }

    @OneToOne(targetEntity = Calculator.class,cascade = CascadeType.ALL,mappedBy = "issue")
    public Calculator getCalculator() {
        return calculator;
    }

    @OneToOne(targetEntity = Lucky.class,cascade = CascadeType.ALL,mappedBy = "issue")
    public Lucky getLucky() {
        return lucky;
    }

    @OneToMany(targetEntity = Annal.class,cascade = CascadeType.ALL,mappedBy = "issue")
    public List<Annal> getAnnal() {
        return annal;
    }

    @OneToMany(targetEntity = Number.class,cascade = CascadeType.ALL,mappedBy = "issue")
    public List<Number> getNumbers() {
        return numbers;
    }

    @OneToOne(targetEntity = Cart.class,cascade = CascadeType.ALL,mappedBy = "issue")
    public Cart getCart() {
        return cart;
    }

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

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public void setDone(int done) {
        this.done = done;
    }

    public void setOver(String over) {
        this.over = over;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public void setFinish(String finish) {
        this.finish = finish;
    }

    public void setCalculator(Calculator calculator) {
        this.calculator = calculator;
    }

    public void setLucky(Lucky lucky) {
        this.lucky = lucky;
    }

    public void setAnnal(List<Annal> annal) {
        this.annal = annal;
    }

    public void setNumbers(List<Number> numbers) {
        this.numbers = numbers;
    }

    public void setCart(Cart cart) {
        this.cart = cart;
    }

    @Override
    public String toString() {
        return "Issue{" +
                "id=" + id +
                ", goods=" + goods +
                ", done=" + done +
                ", over='" + over + '\'' +
                ", start='" + start + '\'' +
                ", finish='" + finish + '\'' +
                ", calculator=" + calculator +
                ", lucky=" + lucky +
                ", annal=" + annal +
                ", numbers=" + numbers +
                ", cart=" + cart +
                '}';
    }
}
