package cn.hmsoft.skill.school.control;

import cn.hmsoft.exception.web.LoginTimeoutException;
import cn.hmsoft.frame.control.FrameControl;
import cn.hmsoft.skill.data.model.school.SchoolReg;
import cn.hmsoft.skill.helper.SkillParamHelper;

public class SchoolAbstractControl extends FrameControl {
	/*******************
	 * 获取系统操作员，并进行判断
	 */
	protected SchoolReg getSchool() {
		return getSchool(true);
	}

	/*******************
	 * 获取系统操作员，并根据参数选择是否进行判断
	 */
	protected SchoolReg getSchool(boolean check) {
		SchoolReg agent = null;
		try {
			agent = (SchoolReg) this.getSession().getAttribute(SkillParamHelper.SessionName_SchoolReg);
		} catch (Exception e) {
		}
		if (check && agent == null)
			throw new LoginTimeoutException();
		return agent;
	}

	@Override
	public Object validRole() {
		if (this.getSchool(true) == null)
			throw new LoginTimeoutException();
		return this.getSchool(true);
	}
}
