package com.xinyilu.system.domain.systemarea;

import com.xinyilu.common.core.domain.BaseEntity;
import com.xinyilu.common.custominterface.Insert;
import com.xinyilu.common.custominterface.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 区域管理对象 sys_area
 *
 * @author jihan
 * @date 2022-07-27
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysArea extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 5512999904657699833L;
    /**
     * 主键id
     */
    @NotNull(message = "主键id不能为空", groups = {Update.class})
    private Long id;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "父级id")
    @NotNull(message = "上级区域不能为空", groups = {Insert.class, Update.class})
    private Long parentId;

    /**
     * 区域等级
     */
    @ApiModelProperty(value = "区域等级")
    private Integer level;

    /**
     * 区域名称
     */
    @ApiModelProperty(value = "区域名称")
    @NotBlank(message = "区域名称不能为空", groups = {Insert.class, Update.class})
    private String name;

    /**
     * 区域编码
     */
    @ApiModelProperty(value = "区域编码")
    @NotBlank(message = "区域编码不能为空", groups = {Insert.class, Update.class})
    private String code;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @NotNull(message = "排序不能为空", groups = {Insert.class, Update.class})
    @Size(min = 0, message = "排序最小值位0")
    private Long sort;

    /**
     * 是否删除，0：否，1：是
     */
    private Integer delFlag;

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("parentId", getParentId())
                .append("name", getName())
                .append("code", getCode())
                .append("sort", getSort())
                .append("delFlag", getDelFlag())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
