diff --git a/hasaki-gen-crud/template.go b/hasaki-gen-crud/template.go index 70eadd7..1df1e0a 100644 --- a/hasaki-gen-crud/template.go +++ b/hasaki-gen-crud/template.go @@ -8,6 +8,7 @@ import ( "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" "git.ouxuan.net/hasaki-service/hasaki-sdk/hskgin" "git.ouxuan.net/hasaki-service/hasaki-sdk/hsklogger/L" + "git.ouxuan.net/hasaki-service/hasaki-sdk/hsktime" "git.ouxuan.net/hasaki-service/hasaki-sdk/hskutils" "github.com/spf13/cast" "github.com/tidwall/gjson" @@ -173,6 +174,10 @@ func (TempLowHead3A60 *Temp3A60) getFieldTypes() map[string]reflect.Kind { types := reflect.TypeOf(TempLowHead3A60) fieldType := map[string]reflect.Kind{} for i := 0; i < types.Elem().NumField(); i++ { + if types.Elem().Field(i).Type.String() == "hsktime.Time" { + fieldType[string(types.Elem().Field(i).Tag.Get("json"))] = reflect.Kind(100) + continue + } fieldType[string(types.Elem().Field(i).Tag.Get("json"))] = types.Elem().Field(i).Type.Kind() } return fieldType @@ -192,6 +197,13 @@ func (TempLowHead3A60 *Temp3A60) fixSqlRowMap(fieldType map[string]reflect.Kind, raw[i] = cast.ToString(raw[i]) case reflect.Slice, reflect.Array, reflect.Map, reflect.Struct, reflect.Ptr: raw[i] = gjson.Parse(cast.ToString(raw[i])).Value() //todo + case 100: + // 2023-09-04 09:53:19 +0000 UTC + _time, _ := time.Parse( + "2006-01-02 15:04:05 +0000 UTC", + cast.ToString(raw[i]), + ) + raw[i] = hsktime.Time(_time) default: raw[i] = cast.ToString(raw[i]) }