package com.ssj.bean.kmt.kmt.domain;

import com.ssj.bean.common.framework.core.domain.BaseEntity;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name="kmt_exampaper_detail")
public class KmtExampaperDetail extends BaseEntity {

	private static final long serialVersionUID = 1L;
	
	private String areaId;
	
	private String questionId;

	private String pId;
	
	private String code;
	
	private String name;
	
	private Integer sortNo;
	
	private int subCount;
	
	private Integer orgLevel;
	
	private Integer status;
	
	private Date createTime;
	
	private boolean isParent;//是否存在父节点,不持久化
	
	private KmtQuestion kmtQuestion;
	
	@OneToOne(cascade = { CascadeType.PERSIST}, fetch=FetchType.EAGER)
	@JoinColumn(name="questionId",updatable =false,insertable =false)
	@Fetch(FetchMode.SELECT)
	public KmtQuestion getKmtQuestion() {
		return kmtQuestion;
	}

	public void setKmtQuestion(KmtQuestion kmtQuestion) {
		this.kmtQuestion = kmtQuestion;
	}

	public String getAreaId() {
		return areaId;
	}

	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	public String getQuestionId() {
		return questionId;
	}

	public void setQuestionId(String questionId) {
		this.questionId = questionId;
	}

	public String getpId() {
		return pId;
	}

	public void setpId(String pId) {
		this.pId = pId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getSortNo() {
		return sortNo;
	}

	public void setSortNo(Integer sortNo) {
		this.sortNo = sortNo;
	}

	public int getSubCount() {
		return subCount;
	}

	public void setSubCount(int subCount) {
		this.subCount = subCount;
	}

	public Integer getOrgLevel() {
		return orgLevel;
	}

	public void setOrgLevel(Integer orgLevel) {
		this.orgLevel = orgLevel;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	 @Transient
	 public boolean getIsParent() {
        if (isParent == true) {
            return true;
        } else {
            return subCount > 0;
        }
    }
    public void setIsParent(boolean isParent) {
        this.isParent = isParent;
    }

}
