package cn.estsh.i3plus.pojo.platform.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.text.DecimalFormat;
import java.util.List;

/**
 * @Description : 组织 1.0
 * @Reference   :
 * @Author      : wei.peng
 * @Date        : 2018-10-22 16:58:42.923
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_ORGANIZE")
@Api(value="组织",description = "组织")
public class SysOrganize extends BaseBean {

    private static final long serialVersionUID = 5932340027033720434L;
    @Column(name="NAME")
    @ApiParam(value ="名称")
    private String name;

    @Column(name="ORGANIZE_CODE")
    @ApiParam(value ="组织代码")
    private String organizeCode;

    @Column(name="ORGANIZE_TYPE")
    @ApiParam(value ="组织类型ID（枚举：1.集团，2.公司，3.工厂）" , example ="1")
    private Integer organizeType;

    // 默认值 -1
    @Column(name="PARENT_ID")
    @ApiParam(value ="父节点" , access ="父节点" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    @Column(name="PARENT_NAME_RDD")
    @ApiParam(value ="父节点")
    private String parentNameRdd;

    @Column(name="ORGANIZE_DESCRIPTION")
    @ApiParam(value ="组织描述")
    private String organizeDescription;

    @Column(name="ORGANIZE_ADDRESS")
    @ApiParam(value ="组织地址")
    private String organizeAddress;

    @Column(name="ORGANIZE_SORT")
    @ApiParam(value ="排序" , example ="1")
    private Integer organizeSort;

    @Column(name="ORGANIZE_STATUS")
    @ApiParam(value ="组织状态（枚举：1.正常，2.禁用）" , example ="1")
    private Integer organizeStatus;

    @Transient
    @ApiParam(value ="子集列表")
    private List<SysOrganize> childList;

    @Transient
    @ApiParam(value ="子集ID列表")
    private List<Long> childIdList;

    public SysOrganize() {
    }

    public SysOrganize(String organizeCode, Integer organizeType, Long parentId, Integer organizeStatus) {
        this.organizeCode = organizeCode;
        this.organizeType = organizeType;
        this.parentId = parentId;
        this.organizeStatus = organizeStatus;
    }
}
