contact_delete.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package alarm
  4. import (
  5. "context"
  6. "smart-site-management/errors"
  7. "smart-site-management/model"
  8. "smart-site-management/pb/v1"
  9. "github.com/jaryhe/gopkgs/logger"
  10. "go.uber.org/zap"
  11. "github.com/jaryhe/gopkgs/database"
  12. )
  13. func AlarmContactDelete(ctx context.Context, req *v1.AlarmContactDeleteRequest) (reply *v1.AlarmContactDeleteReply, err error) {
  14. if req.Id == 0 {
  15. return nil, errors.ParamsError
  16. }
  17. p := model.TAlarmContact{}
  18. where := map[string]interface{}{
  19. "id": req.Id,
  20. }
  21. err = p.Query(database.DB(), where)
  22. if err != nil {
  23. logger.Error("AlarmContactDelete",
  24. zap.String("err", err.Error()))
  25. return nil, errors.DataBaseError
  26. }
  27. //projectId := p.ProjectId
  28. p = model.TAlarmContact{}
  29. err = p.Delete(database.DB(), where)
  30. if err != nil {
  31. logger.Error("AlarmContactDelete",
  32. zap.String("err", err.Error()))
  33. return nil, errors.DataBaseError
  34. }
  35. reply = &v1.AlarmContactDeleteReply{}
  36. // TODO 清除缓存中告警联系人数据
  37. //utils.DeleteAlarmContact(projectId)
  38. return reply, nil
  39. }