From 9e8d8b630affc4a4be428c775264ef4b0e5104b3 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期五, 17 五月 2024 15:25:45 +0800 Subject: [PATCH] 添加取消订阅接口 --- controller/subscribeCtl.go | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/controller/subscribeCtl.go b/controller/subscribeCtl.go index 6f2995d..2cceebc 100644 --- a/controller/subscribeCtl.go +++ b/controller/subscribeCtl.go @@ -1,13 +1,14 @@ package controller import ( + "net/http" + "strings" + "time" + "gat1400Exchange/config" "gat1400Exchange/pkg/logger" "gat1400Exchange/repository" "gat1400Exchange/vo" - "net/http" - "strings" - "time" "github.com/gin-gonic/gin" ) @@ -172,3 +173,22 @@ c.JSON(http.StatusOK, gin.H{"msg": "ok"}) } + +func (s SubscribeController) CancelSubscribes(c *gin.Context) { + var req vo.Subscribe + if err := c.BindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"msg": err.Error()}) + return + } + + if c.Param("id") == "" { + c.JSON(http.StatusBadRequest, gin.H{"msg": "涓嬬骇id涓虹┖"}) + } + + if err := s.Repository.CancelSubscribe(c.Param("id"), &req); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"msg": err.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"msg": "ok"}) +} -- Gitblit v1.8.0