package com.sysu.admin.controller.crop.clazz;

import com.alibaba.fastjson.annotation.JSONField;
import com.sysu.admin.controller.crop.class_item.CropClassItem;
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 javax.persistence.*;
import java.util.List;

/**
 * 作物大类
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@FieldNameConstants(innerTypeName = "FIELDS")
@Table(name = "p_crop_class")
@Entity
@DynamicInsert
@DynamicUpdate
public class CropClass {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JSONField(ordinal = 0)
    private Integer id;

    @Column()
    @JSONField(ordinal = 1)
    private String name;

    @JSONField(ordinal = 2)
    @Transient
    private List<CropClassItem> items;

}
