12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package alarm
- import (
- "context"
- "smart-site-management/errors"
- "smart-site-management/model"
- "smart-site-management/pb/v1"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "github.com/jaryhe/gopkgs/database"
- )
- func AlarmContactDelete(ctx context.Context, req *v1.AlarmContactDeleteRequest) (reply *v1.AlarmContactDeleteReply, err error) {
- if req.Id == 0 {
- return nil, errors.ParamsError
- }
- p := model.TAlarmContact{}
- where := map[string]interface{}{
- "id": req.Id,
- }
- err = p.Query(database.DB(), where)
- if err != nil {
- logger.Error("AlarmContactDelete",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- //projectId := p.ProjectId
- p = model.TAlarmContact{}
- err = p.Delete(database.DB(), where)
- if err != nil {
- logger.Error("AlarmContactDelete",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- reply = &v1.AlarmContactDeleteReply{}
- // TODO 清除缓存中告警联系人数据
- //utils.DeleteAlarmContact(projectId)
- return reply, nil
- }
|