zhangqian
2023-12-08 84fb8e390b83dc9482524c12d7af6c93405c3fc1
debug
2个文件已修改
20 ■■■■■ 已修改文件
crontask/cron_task.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/model.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
crontask/cron_task.go
@@ -81,7 +81,7 @@
    if isMaster {
        s.Every(20).Seconds().Do(SyncProductionProgress) //同步生产数据
        s.Every(30).Seconds().Do(SyncTaskStatus)         //同步任务状态
        //s.Every(30).Seconds().Do(SyncTaskStatus)         //同步任务状态
        s.Every(10).Seconds().Do(CheckNsqConn)           //查询nsq连接
        s.Every(30).Seconds().Do(ReportData)             //上报数据
    }
model/model.go
@@ -2,12 +2,15 @@
import (
    "apsClient/pkg/snowflake"
    "encoding/json"
    "github.com/jinzhu/gorm"
    "strconv"
    "time"
)
type CommonModel struct {
    ID        uint `gorm:"primary_key;autoIncrement:false"`
    ID        uint   `gorm:"primary_key;autoIncrement:false" json:"-"`
    IDStr     string `json:"ID" gorm:"-"`
    CreatedAt time.Time
    UpdatedAt time.Time
    DeletedAt *time.Time `sql:"index"`
@@ -22,3 +25,16 @@
        c.ID = uint(id)
    }
}
func (c CommonModel) UnmarshalJSON(b []byte) (err error) {
    id, err := strconv.ParseUint(c.IDStr, 10, 64)
    if err != nil {
        return err
    }
    c.ID = uint(id)
    return
}
func (c CommonModel) MarshalJSON() ([]byte, error) {
    c.IDStr = strconv.FormatUint(uint64(c.ID), 10)
    return json.Marshal(c)
}