mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 22:14:53 +00:00
refactor: re-implement logic of notify
This commit is contained in:
@@ -9,7 +9,7 @@ import "strconv"
|
||||
// - key: 键。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是字符串,则返回空字符串。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是字符串,则返回空字符串。
|
||||
func GetValueAsString(dict map[string]any, key string) string {
|
||||
return GetValueOrDefaultAsString(dict, key, "")
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func GetValueAsString(dict map[string]any, key string) string {
|
||||
// - defaultValue: 默认值。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是字符串,则返回默认值。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是字符串,则返回默认值。
|
||||
func GetValueOrDefaultAsString(dict map[string]any, key string, defaultValue string) string {
|
||||
if dict == nil {
|
||||
return defaultValue
|
||||
@@ -44,7 +44,7 @@ func GetValueOrDefaultAsString(dict map[string]any, key string, defaultValue str
|
||||
// - key: 键。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是 32 位整数,则返回 0。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是 32 位整数,则返回 0。
|
||||
func GetValueAsInt32(dict map[string]any, key string) int32 {
|
||||
return GetValueOrDefaultAsInt32(dict, key, 0)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func GetValueAsInt32(dict map[string]any, key string) int32 {
|
||||
// - defaultValue: 默认值。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是 32 位整数,则返回默认值。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是 32 位整数,则返回默认值。
|
||||
func GetValueOrDefaultAsInt32(dict map[string]any, key string, defaultValue int32) int32 {
|
||||
if dict == nil {
|
||||
return defaultValue
|
||||
@@ -69,8 +69,8 @@ func GetValueOrDefaultAsInt32(dict map[string]any, key string, defaultValue int3
|
||||
}
|
||||
|
||||
// 兼容字符串类型的值
|
||||
if s, ok := value.(string); ok {
|
||||
if result, err := strconv.ParseInt(s, 10, 32); err == nil {
|
||||
if str, ok := value.(string); ok {
|
||||
if result, err := strconv.ParseInt(str, 10, 32); err == nil {
|
||||
return int32(result)
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func GetValueOrDefaultAsInt32(dict map[string]any, key string, defaultValue int3
|
||||
// - key: 键。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是 64 位整数,则返回 0。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是 64 位整数,则返回 0。
|
||||
func GetValueAsInt64(dict map[string]any, key string) int64 {
|
||||
return GetValueOrDefaultAsInt64(dict, key, 0)
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func GetValueAsInt64(dict map[string]any, key string) int64 {
|
||||
// - defaultValue: 默认值。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是 64 位整数,则返回默认值。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是 64 位整数,则返回默认值。
|
||||
func GetValueOrDefaultAsInt64(dict map[string]any, key string, defaultValue int64) int64 {
|
||||
if dict == nil {
|
||||
return defaultValue
|
||||
@@ -111,8 +111,8 @@ func GetValueOrDefaultAsInt64(dict map[string]any, key string, defaultValue int6
|
||||
}
|
||||
|
||||
// 兼容字符串类型的值
|
||||
if s, ok := value.(string); ok {
|
||||
if result, err := strconv.ParseInt(s, 10, 64); err == nil {
|
||||
if str, ok := value.(string); ok {
|
||||
if result, err := strconv.ParseInt(str, 10, 64); err == nil {
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func GetValueOrDefaultAsInt64(dict map[string]any, key string, defaultValue int6
|
||||
// - key: 键。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是布尔,则返回 false。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是布尔,则返回 false。
|
||||
func GetValueAsBool(dict map[string]any, key string) bool {
|
||||
return GetValueOrDefaultAsBool(dict, key, false)
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func GetValueAsBool(dict map[string]any, key string) bool {
|
||||
// - defaultValue: 默认值。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的值。如果指定键不存在或者类型不是布尔,则返回默认值。
|
||||
// - 字典中键对应的值。如果指定键不存在或者值的类型不是布尔,则返回默认值。
|
||||
func GetValueOrDefaultAsBool(dict map[string]any, key string, defaultValue bool) bool {
|
||||
if dict == nil {
|
||||
return defaultValue
|
||||
|
Reference in New Issue
Block a user