alarm_contact.go 964 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:"column:ID;primary_key"`
  12. ProjectId int64 `gorm:"column:ProjectId"`
  13. Phone string `gorm:"column:Phone"`
  14. Email string `gorm:"column:Email"`
  15. CreatedAt string `gorm:"column:CreatedAt"`
  16. UpdatedAt string `gorm:"column:UpdatedAt"`
  17. }
  18. func (TAlarmContact) TableName() string {
  19. return "AlarmContact"
  20. }
  21. func (p *TAlarmContact) Delete(db *gorm.DB, filter map[string]interface{}) error {
  22. err := db.Table(p.TableName()).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. }