// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package model import ( "encoding/json" "time" "github.com/jaryhe/gopkgs/logger" "github.com/jinzhu/gorm" "go.uber.org/zap" ) type TAlarm struct { Id int64 `gorm:"primary_key"` ProjectId int64 `gorm:"column:project_id"` Sn string `gorm:"column:sn"` AlarmCode string `gorm:"column:alarm_code"` AlarmReason string `gorm:"column:alarm_reason"` IsHandle bool `gorm:"column:is_handle"` Time time.Time `gorm:"column:time"` CreatedAt string `gorm:"column:created_at"` UpdatedAt string `json:"updated_at"` } func (TAlarm) TableName() string { return "t_alarm" } func (p *TAlarm) Delete(db *gorm.DB, filter map[string]interface{}) error { err := db.Where(filter).Delete(p).Error if err != nil { fields, _ := json.Marshal(filter) logger.Error("mysql", zap.String("sql", "delete from t_alarm"), zap.String("fields", string(fields)), zap.String("error", err.Error())) return err } return nil }