alarm_contact.go 932 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package model
  4. import (
  5. "encoding/json"
  6. "github.com/jaryhe/gopkgs/logger"
  7. "go.uber.org/zap"
  8. "github.com/jinzhu/gorm"
  9. )
  10. type TAlarmContact struct {
  11. Id uint64 `gorm:"primary_key"`
  12. ProjectId int64 `gorm:"column:project_id"`
  13. Phone string `gorm:"column:phone"`
  14. Email string `gorm:"column:email"`
  15. CreatedAt string `gorm:"column:created_at"`
  16. UpdatedAt string `json:"updated_at"`
  17. }
  18. func (TAlarmContact) TableName() string {
  19. return "t_alarm_contact"
  20. }
  21. func (p *TAlarmContact) Delete(db *gorm.DB, filter map[string]interface{}) error {
  22. err := db.Where(filter).Delete(p).Error
  23. if err != nil {
  24. fields, _ := json.Marshal(filter)
  25. logger.Error("mysql",
  26. zap.String("sql", "delete from t_alarm_contact"),
  27. zap.String("fields", string(fields)),
  28. zap.String("error", err.Error()))
  29. }
  30. return err
  31. }