package com.izouma.wenlvju.domain;

import com.izouma.wenlvju.annotations.Searchable;
import com.izouma.wenlvju.enums.DistrictLevel;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("行政区域")
@Where(clause = "del = 0")
public class District extends AuditedEntity {
    @Id
    private Long id;

    @Column(length = 10)
    private String cityCode;

    @Searchable
    private String name;

    private double lat;

    private double lng;

    @Column(length = 20)
    @Enumerated(EnumType.STRING)
    private DistrictLevel level;

    private Long parent;

    private int childCount;

    private int cityCount;

    private int districtCount;

    private int streetCount;

    @Transient
    private Boolean leaf;
}
