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.util.List;

/**
 * @Description : 部门
 * @Reference   :
 * @Author      : wei.peng
 * @Date        : 2018-10-22 16:58:42.539
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_DEPARTMENT")
@Api(value="部门",description = "部门")
public class SysDepartment extends BaseBean {

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

    @Column(name="DEPARTMENT_CODE")
    @ApiParam(value ="部门代码")
    private String departmentCode;

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

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

    @Column(name="ORGANIZE_NAME_RDD")
    @ApiParam(value ="所属组织名称" , access ="所属组织名称")
    private String organizeNameRdd;

    @Column(name="ORGANIZE_ID")
    @ApiParam(value ="所属组织" , example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long organizeId;

    @Column(name="DEPARTMENT_SORT")
    @ApiParam(value ="排序" , example ="1" , access ="排序")
    private Integer departmentSort;

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

    public SysDepartment() {
    }

    public SysDepartment(String departmentCode, Long parentId, Long organizeId) {
        this.departmentCode = departmentCode;
        this.parentId = parentId;
        this.organizeId = organizeId;
    }
}
