From a9fdd955d57f6940d170a2f4c36a9bb8f0fcf871 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 08 十二月 2023 19:04:32 +0800 Subject: [PATCH] json输出字符串 --- model/model.go | 40 +--------------------------------------- main.go | 1 - crontask/cron_task.go | 6 +++--- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/crontask/cron_task.go b/crontask/cron_task.go index 2ee7286..0199a20 100644 --- a/crontask/cron_task.go +++ b/crontask/cron_task.go @@ -81,9 +81,9 @@ if isMaster { s.Every(20).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁 - //s.Every(30).Seconds().Do(SyncTaskStatus) //鍚屾浠诲姟鐘舵�� - s.Every(10).Seconds().Do(CheckNsqConn) //鏌ヨnsq杩炴帴 - s.Every(30).Seconds().Do(ReportData) //涓婃姤鏁版嵁 + s.Every(30).Seconds().Do(SyncTaskStatus) //鍚屾浠诲姟鐘舵�� + s.Every(10).Seconds().Do(CheckNsqConn) //鏌ヨnsq杩炴帴 + s.Every(30).Seconds().Do(ReportData) //涓婃姤鏁版嵁 } s.Every(20).Seconds().Do(QueryClusterStatus) //鏌ヨ闆嗙兢鑺傜偣鏁伴噺 diff --git a/main.go b/main.go index 39420ab..c79c874 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,6 @@ var syncTables = []string{ "procedures", "process_model", - "production_progress", "work_order", "task_status_sync", "device", diff --git a/model/model.go b/model/model.go index 3bea624..b873d13 100644 --- a/model/model.go +++ b/model/model.go @@ -1,50 +1,12 @@ package model import ( - "apsClient/pkg/snowflake" - "encoding/json" - "github.com/jinzhu/gorm" - "strconv" "time" ) -type BigID uint - type CommonModel struct { - ID uint `gorm:"primary_key" json:"-"` - Id BigID `json:"ID"` + ID uint `gorm:"primary_key" json:"ID,string"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` -} - -func (c *CommonModel) BeforeCreate(db *gorm.DB) { - if c.ID == 0 { - id := snowflake.GenerateID() - if id < 0 { - // 澶勭悊 ID 涓鸿礋鏁扮殑鎯呭喌锛堝彲閫夛級 - id = snowflake.GenerateID() - } - c.ID = uint(id) - } -} - -func (id *BigID) UnmarshalJSON(b []byte) error { - var idString string - if err := json.Unmarshal(b, &idString); err != nil { - return err - } - - idValue, err := strconv.ParseUint(idString, 10, 64) - if err != nil { - return err - } - - *id = BigID(idValue) - return nil -} - -func (id *BigID) MarshalJSON() ([]byte, error) { - idString := strconv.FormatUint(uint64(*id), 10) - return []byte(idString), nil } -- Gitblit v1.8.0