package com.sysu.admin.controller.lz.tree;

import com.alibaba.fastjson.annotation.JSONField;
import com.sysu.admin.controller.lz.area.LzArea;
import com.sysu.admin.controller.lz.clazz.LzClazz;
import com.sysu.admin.controller.lz.everyday.LzEveryday;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.locationtech.jts.geom.Point;
import javax.persistence.*;
import java.util.List;

@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@FieldNameConstants(innerTypeName = "FIELDS")
@Table(name = "lz_tree")
@Entity
@DynamicInsert
@DynamicUpdate
public class LzTree {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column
    private String code;

    @ManyToOne(cascade= CascadeType.REFRESH)
    @JoinColumn(name = "clazz")
    private LzClazz clazz;

    @Column
    private Integer age;

    @ManyToOne(cascade= CascadeType.REFRESH)
    @JoinColumn(name = "area_id")
    private LzArea lzArea;

    @Column
    private Integer userId;

    @Column()
    @JSONField(serialize = false)
    private Point point;

    @ManyToOne(cascade= CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "everyday_id")
    private LzEveryday lzEveryday;

    /**
     * 冠幅面积
     */
    @Column
    private Double canopyArea;

    /**
     * 胸径
     */
    @Column
    private Double dbh;

    /**
     * 是否预警
     */
    @Column
    private Integer show;

    @Transient
    private String wkt;
    @Transient
    private Integer clazzId;
    @Transient
    private List<LzEveryday> lzEverydays;

    @Transient
    private Integer warning ;
    @Transient
    private String partImgUrl;

}












