From cef97441f455b3efc5e710fc52c1c5dbd5671fac Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期五, 17 五月 2024 13:00:16 +0800 Subject: [PATCH] 添加修改订阅功能 --- repository/subscribeRepo.go | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/repository/subscribeRepo.go b/repository/subscribeRepo.go index f6f505f..ec3bb73 100644 --- a/repository/subscribeRepo.go +++ b/repository/subscribeRepo.go @@ -53,6 +53,37 @@ return err } +func (s *SubscribeRepository) UpdateSubscribe(sid string, req *vo.Subscribe) error { + var subscribeMsg vo.RequestSubscribe + subscribeMsg.SubscribeListObject.SubscribeObject = []vo.Subscribe{*req} + + // 鏌ユ壘涓嬬骇 + var platform models.SubPlatform + err := platform.FindById(sid) + if err != nil { + return err + } + + uri := fmt.Sprintf("http://%s:%d/VIID/Subscribes", platform.RemoteIP, platform.RemotePort) + body, _ := json.Marshal(subscribeMsg) + if client.UpdateSubscribe(uri, body) != vo.StatusSuccess { + return errors.New("鍙戦�佽闃呮秷鎭け璐�") + } + + var sub = models.Subscribe{ + Id: req.SubscribeID, + Status: req.SubscribeStatus, + FromId: sid, + Ext: *req, + } + + err = sub.Save() + if err != nil { + return err + } + + return err +} func (s *SubscribeRepository) SaveReceiveSubscribe(fromId string, subscribe *vo.Subscribe) error { var sub = models.Subscribe{ -- Gitblit v1.8.0