zhangqian
2023-10-07 3ca8f1290232818ca2720fa3a9a736ca1d52a1a8
model/procedures.go
@@ -6,14 +6,12 @@
   "apsClient/pkg/sqlitex"
   "encoding/json"
   "fmt"
   "gorm.io/gorm"
   "gorm.io/gorm/clause"
   "github.com/jinzhu/gorm"
)
type (
   Procedures struct {
      gorm.Model     `json:"-"`
      ID             int    `gorm:"primarykey"`
      gorm.Model
      WorkOrderID    string `gorm:"index;type:varchar(191);not null;comment:工单ID" json:"-"`
      OrderID        string `gorm:"index;type:varchar(191);not null;comment:订单ID" json:"-"`
      DeviceID       string `gorm:"index;type:varchar(191);comment:设备ID" json:"deviceId"`
@@ -105,7 +103,7 @@
   return slf
}
func (slf *ProceduresSearch) SetId(id int) *ProceduresSearch {
func (slf *ProceduresSearch) SetId(id uint) *ProceduresSearch {
   slf.ID = id
   return slf
}
@@ -221,10 +219,11 @@
   old, err := slf.First()
   if err != gorm.ErrRecordNotFound && old.ID != 0 {
      record.ID = old.ID
      err = db.Save(&record).Error
   } else {
      err = db.Create(&record).Error
   }
   if err := db.Clauses(clause.OnConflict{
      UpdateAll: true,
   }).Create(&record).Error; err != nil {
   if err != nil {
      return fmt.Errorf("save err: %v, record: %+v", err, record)
   }