// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package model import ( "encoding/json" "github.com/jaryhe/gopkgs/logger" "go.uber.org/zap" "github.com/jinzhu/gorm" ) type TAlarmRule struct { Id int64 `gorm:"primary_key"` ProjectId int64 `gorm:"column:project_id"` Sn string `gorm:"sn"` ContinuePeriod int32 `gorm:"column:continue_period"` AlarmCount int32 `gorm:"column:alarm_count"` SilencePeriod int32 `gorm:"column:silence_period"` IsOn bool `gorm:"column:is_on"` CreatedAt string `gorm:"column:created_at"` UpdatedAt string `gorm:"column:updated_at"` } func (TAlarmRule) TableName() string { return "t_alarm_rule" } func (p *TAlarmRule) 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_rule"), zap.String("fields", string(fields)), zap.String("error", err.Error())) } return err }