|
@@ -1,6 +1,9 @@
|
|
|
package syncer
|
|
|
|
|
|
-import "time"
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "time"
|
|
|
+)
|
|
|
|
|
|
const (
|
|
|
SYNC_ACTION_INSERT = "Insert"
|
|
@@ -46,3 +49,30 @@ type ClientPriceUpdate struct {
|
|
|
RecCreatedAt time.Time `json:"rec_create_at"`
|
|
|
RecUpdatedAt time.Time `json:"rec_update_at"`
|
|
|
}
|
|
|
+
|
|
|
+// Custom unmarshal for date time of the record
|
|
|
+func (s *ClientPriceUpdate) UnmarshalJSON(data []byte) error {
|
|
|
+ type Alias ClientPriceUpdate
|
|
|
+ aux := &struct {
|
|
|
+ RecCreatedAt string `json:"rec_create_at"`
|
|
|
+ RecUpdatedAt string `json:"rec_update_at"`
|
|
|
+ *Alias
|
|
|
+ }{
|
|
|
+ Alias: (*Alias)(s),
|
|
|
+ }
|
|
|
+ if err := json.Unmarshal(data, &aux); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ createdAt, e := time.Parse("2006-01-02 15:04:05.999999999-07:00", aux.RecCreatedAt)
|
|
|
+ if e != nil {
|
|
|
+ return e
|
|
|
+ }
|
|
|
+ updatedAt, e := time.Parse("2006-01-02 15:04:05.999999999-07:00", aux.RecUpdatedAt)
|
|
|
+ if e != nil {
|
|
|
+ return e
|
|
|
+ }
|
|
|
+
|
|
|
+ s.RecCreatedAt = createdAt
|
|
|
+ s.RecUpdatedAt = updatedAt
|
|
|
+ return nil
|
|
|
+}
|