package com.sysu.admin.controller.city;

import com.alibaba.fastjson.annotation.JSONField;
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.MultiPolygon;

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

/**
 * 省
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@FieldNameConstants(innerTypeName = "FIELDS")
@Table(name = "p_province")
@Entity
@DynamicInsert
@DynamicUpdate
public class Province{
    public Province(){}

    public Province(String name, String code) {
        this.name = name;
        this.code = code;
    }

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

    @JSONField(serialize = false)
    @Column(columnDefinition = "geom")
    private MultiPolygon geom;

    @Transient
    private String wkt;

    @Column()
    private String name;

    @Column()
    private String code;

    @Transient
    private List<City> cityList;

}
