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:43.026
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_POSITION")
@Api(value="岗位",description = "岗位")
public class SysPosition extends BaseBean {

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

    @Column(name="POSITION_CODE")
    @ApiParam(value ="岗位代码" , access ="岗位代码")
    private String positionCode;

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

    @Column(name="PARENT_NAME_RDD")
    @ApiParam(value ="上级岗位名称" , access ="上级岗位名称")
    private String parentNameRdd;

    @Column(name="POSITION_DESCRIPTION")
    @ApiParam(value ="描述" , access ="描述")
    private String positionDescription;

    @Transient
    @ApiParam(value ="子部门列表")
    private List<SysPosition> childList;

    public SysPosition() {
    }

    public SysPosition(String positionCode, Long parentId) {
        this.positionCode = positionCode;
        this.parentId = parentId;
    }
}
