package vo

import "errors"

type AvailableType uint8

const (
	AvailableTypeFixed AvailableType = iota + 1
	AvailableTypeDynamic
)

var AvailableTypeMap = map[AvailableType]string{
	AvailableTypeFixed:   "固定有效期",
	AvailableTypeDynamic: "动态有效期",
}

func (s AvailableType) GetText() string {
	if t, ok := AvailableTypeMap[s]; ok {
		return t
	}
	return "未知券领取类型"
}

func (s AvailableType) GetValue() uint8 {
	return uint8(s)
}

func (s AvailableType) IsFixed() bool {
	return s == AvailableTypeFixed
}

func (s AvailableType) IsDynamic() bool {
	return s == AvailableTypeDynamic
}

var AvailableCmbTypeMap = map[AvailableType]CmbAvailableType{
	AvailableTypeFixed:   CmbAvailableTypeFixed,
	AvailableTypeDynamic: CmbAvailableTypeDynamic,
}

func (s AvailableType) GetCmbAvailableType() (CmbAvailableType, error) {
	if t, ok := AvailableCmbTypeMap[s]; ok {
		return t, nil
	}
	return "", errors.New("未知券领取类型")
}
