// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package v1 import ( "github.com/jaryhe/gopkgs/database" "github.com/jinzhu/gorm" "time" "lift-monitor/model" ) func LiftFrameBaseInfoWrite(record *model.LiftBaseInfo) error { p := &model.LiftBaseInfo{} where := map[string]interface{}{ "SN": record.SN, "LiftNo": record.LiftNo, "LiftDirect":record.LiftDirect, "ProjectID": record.ProjectID, } err := p.Find(database.DB(), where) if err != nil && err != gorm.ErrRecordNotFound { return err } if p.ID == 0 { record.CreatedAt = time.Now() record.UpdatedAt = record.CreatedAt return record.Insert(database.DB()) } values := map[string]interface{}{ "EmptyWeightAD":record.EmptyWeightAD, "EmptyWeight":record.EmptyWeight, "LoadWeightAD":record.LoadWeightAD, "LoadWeight":record.LoadWeight, "LowHighAD":record.LowHighAD, "LowHigh":record.LowHigh, "TopHighAD":record.TopHighAD, "TopHigh":record.TopHigh, "CreatedAt": time.Now(), } where = map[string]interface{}{ "ID": p.ID, } return p.Update(database.DB(), where, values) } // 暂时保留 func LiftFrameBaseInfoRequestHandle(sn string, liftNo byte, version byte, data []byte) (res []byte, err error) { return nil, nil }