package com.pangu.base.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.pangu.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 区域实体类
 * @author pangu
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pg_region")
public class Region extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 区域ID */
    @TableId(type = IdType.AUTO)
    @JsonProperty("id")
    private Long regionId;

    /** 父区域ID */
    private Long parentId;

    /** 区域名称 */
    @NotBlank(message = "区域名称不能为空")
    @Size(max = 100, message = "区域名称长度不能超过100个字符")
    @JsonProperty("name")
    private String regionName;

    /** 区域编码 */
    @JsonProperty("code")
    private String regionCode;

    /** 层级（1省 2市 3区）*/
    private Integer level;

    /** 祖级列表 */
    private String ancestors;

    /** 显示顺序 */
    @JsonProperty("sort")
    private Integer orderNum;

    /** 状态（0正常 1停用）*/
    private String status;

    /** 子区域 */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Region> children = new ArrayList<>();
}
