package enum

var (
	notAuthCheck = NewEnum(0, "不需要认证")     //0 -> 00000000
	needUserAuth = NewEnum(1, "需要用户认证")    //1 -> 00000001
	needEntAuth  = NewEnum(1<<1, "需要企业认证") //2 -> 00000010
)

type AuthCheck struct {
	*Enum
}

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

// NeedCheck 是否需要账户认证校验
func (ac *AuthCheck) NeedCheck() bool {
	return ac.GetCode() != notAuthCheck.code
}

// CheckUserAuth 校验是否需要用户认证
func (ac *AuthCheck) CheckUserAuth() bool {
	return needUserAuth.code == (ac.GetCode() & needUserAuth.code)
}

// CheckEntAuth 校验是否需要企业认证
func (ac *AuthCheck) CheckEntAuth() bool {
	return needEntAuth.code == (ac.GetCode() & needEntAuth.code)
}
