mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-02-10 23:05:37 +08:00
fix: sqlite数据问题时间类型问题修复等
This commit is contained in:
19
server/pkg/utils/conv/string.go
Normal file
19
server/pkg/utils/conv/string.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package conv
|
||||
|
||||
import (
|
||||
"mayfly-go/pkg/logx"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 将字符串值转为int值, 若value为空或者转换失败,则返回默认值
|
||||
func Str2Int(value string, defaultValue int) int {
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
if intV, err := strconv.Atoi(value); err != nil {
|
||||
logx.ErrorTrace("str conv int error: ", err)
|
||||
return defaultValue
|
||||
} else {
|
||||
return intV
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user