58 lines
945 B
Go
58 lines
945 B
Go
package member
|
|
|
|
const (
|
|
Digimon Platform = 1 + iota
|
|
Google
|
|
Line
|
|
Apple
|
|
)
|
|
|
|
const (
|
|
PlatformNone Platform = -1
|
|
)
|
|
|
|
const (
|
|
DigimonString = "platform"
|
|
GoogleString = "google"
|
|
LineString = "line"
|
|
AppleString = "apple"
|
|
)
|
|
|
|
type Platform int8
|
|
|
|
func (p Platform) ToInt64() int64 {
|
|
return int64(p)
|
|
}
|
|
|
|
// ToString - 將 Platform 轉為文字
|
|
func (p Platform) ToString() string {
|
|
if result, ok := platformToString[p]; ok {
|
|
return result
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
var platformToString = map[Platform]string{
|
|
Digimon: DigimonString,
|
|
Google: GoogleString,
|
|
Line: LineString,
|
|
Apple: AppleString,
|
|
}
|
|
|
|
var stringToPlatform = map[string]Platform{
|
|
DigimonString: Digimon,
|
|
GoogleString: Google,
|
|
LineString: Line,
|
|
AppleString: Apple,
|
|
}
|
|
|
|
// GetPlatformByPlatformCode - 從文字轉為 Platform
|
|
func GetPlatformByPlatformCode(code string) Platform {
|
|
if result, ok := stringToPlatform[code]; ok {
|
|
return result
|
|
}
|
|
|
|
return PlatformNone
|
|
}
|