forked from free-lancers/electricity_bill_calc_service
refactor(types):将日期时间类型提取到公共的类型定义包中。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"electricity_bill_calc/model"
|
||||
"electricity_bill_calc/types"
|
||||
"os"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
@@ -137,6 +137,17 @@ func DecimalField(key string, val *decimal.Decimal) zap.Field {
|
||||
return zap.String(key, val.String())
|
||||
}
|
||||
|
||||
func DateField(key string, val *model.Date) zap.Field {
|
||||
return zap.String(key, val.Format("2006-01-02"))
|
||||
func NullDecimalField(key string, val *decimal.NullDecimal) zap.Field {
|
||||
if val.Valid {
|
||||
return DecimalField(key, &val.Decimal)
|
||||
}
|
||||
return zap.String(key, "null")
|
||||
}
|
||||
|
||||
func DateField(key string, val *types.Date) zap.Field {
|
||||
return val.Log(key)
|
||||
}
|
||||
|
||||
func DateTimeField(key string, val *types.DateTime) zap.Field {
|
||||
return val.Log(key)
|
||||
}
|
||||
|
Reference in New Issue
Block a user