From e5be7a7ed63d4b4e4267057d84b77c4bd3c16781 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 16 五月 2024 13:09:28 +0800
Subject: [PATCH] 添加订阅修改接口

---
 controller/subscribeCtl.go |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/controller/subscribeCtl.go b/controller/subscribeCtl.go
index 9ef4d86..949c113 100644
--- a/controller/subscribeCtl.go
+++ b/controller/subscribeCtl.go
@@ -23,6 +23,13 @@
 	return controller
 }
 
+func (s SubscribeController) SubscribesList(c *gin.Context) {
+	subList, _ := s.Repository.List()
+
+	c.Header("Content-Type", "application/VIID+json;charset=UTF-8")
+	c.JSON(http.StatusOK, gin.H{"SubscribeList": subList})
+}
+
 func (s SubscribeController) Subscribes(c *gin.Context) {
 	var req vo.RequestSubscribe
 	if err := c.BindJSON(&req); err != nil {
@@ -49,6 +56,30 @@
 	c.JSON(http.StatusOK, gin.H{"ResponseStatusListObject": rsp})
 }
 
+func (s SubscribeController) UpdateSubscribes(c *gin.Context) {
+	var req vo.RequestSubscribe
+	if err := c.BindJSON(&req); err != nil {
+		c.AbortWithStatus(http.StatusBadRequest)
+		return
+	}
+
+	var rsp vo.ResponseStatusList
+	for idx, sub := range req.SubscribeListObject.SubscribeObject {
+		if err := s.Repository.UpdateSubscribe(&req.SubscribeListObject.SubscribeObject[idx]); err == nil {
+			rsp.ResponseStatusObject = append(rsp.ResponseStatusObject, vo.ResponseStatus{
+				RequestURL:   c.FullPath(),
+				StatusCode:   vo.StatusSuccess,
+				StatusString: vo.StatusString[vo.StatusSuccess],
+				Id:           sub.SubscribeID,
+				LocalTime:    time.Now().Format("20060102150405"),
+			})
+		}
+	}
+
+	c.Header("Content-Type", "application/VIID+json;charset=UTF-8")
+	c.JSON(http.StatusOK, gin.H{"ResponseStatusListObject": rsp})
+}
+
 func (s SubscribeController) DeleteSubscribe(c *gin.Context) {
 	idList := c.Query("IDList")
 	var rsp vo.ResponseStatusList

--
Gitblit v1.8.0