package enum

var (
	notSession      = NewEnum(0, "不需要session")     //0 -> 00000000
	needUserSession = NewEnum(1, "需要用户session")    //1 -> 00000001
	needEntSession  = NewEnum(1<<1, "需要企业session") //2 -> 00000010
)

type SessCheck struct {
	*Enum
}

// NewSessCheck 初始化权限校验对象
func NewSessCheck(code int64, desc ...string) *SessCheck {
	return &SessCheck{
		NewEnum(code, desc...),
	}
}

// NeedCheck 是否需要登录状态校验
func (sc *SessCheck) NeedCheck() bool {
	return sc.GetCode() != notSession.code
}

// CheckUserSession 校验是否需要用户Session
func (sc *SessCheck) CheckUserSession() bool {
	return needUserSession.code == (sc.GetCode() & needUserSession.code)
}

// CheckEntSession 校验是否需要企业Session
func (sc *SessCheck) CheckEntSession() bool {
	return needEntSession.code == (sc.GetCode() & needEntSession.code)
}
