package member

type GenerateCodeType int64

const (
	GenerateCodeTypeNone           GenerateCodeType = -1
	GenerateCodeTypeEmail          GenerateCodeType = 1 // email 驗證碼
	GenerateCodeTypePhone          GenerateCodeType = 2 // phone 驗證碼
	GenerateCodeTypeForgetPassword GenerateCodeType = 3 // 忘記密碼
)

var codeMap = map[GenerateCodeType]string{
	1: "email",
	2: "phone",
	3: "forget_email",
}

func GetCodeNameByCode(code GenerateCodeType) (string, bool) {
	res, ok := codeMap[code]
	if !ok {
		return "", false
	}

	return res, true
}

var generateCodeTypeMap = map[string]GenerateCodeType{
	"email":        GenerateCodeTypeEmail,
	"phone":        GenerateCodeTypePhone,
	"forget_email": GenerateCodeTypeForgetPassword,
}

func GetGetCodeNameByCode(code string) GenerateCodeType {
	result, ok := generateCodeTypeMap[code]
	if !ok {
		return GenerateCodeTypeNone
	}

	return result
}
