Procházet zdrojové kódy

通知公告系统消息查询增加增量ID字段

zhou.xiaoning před 4 roky
rodič
revize
3ad6c5ffc8
4 změnil soubory, kde provedl 27 přidání a 0 odebrání
  1. 11 0
      controllers/common/notice.go
  2. 6 0
      docs/docs.go
  3. 6 0
      docs/swagger.json
  4. 4 0
      docs/swagger.yaml

+ 11 - 0
controllers/common/notice.go

@@ -20,6 +20,7 @@ type QueryNoticeReq struct {
 	LoginID    int  `form:"loginID"`    // 登录账号
 	MsgType    int  `form:"msgType"`    // 消息类型 - 1:公告通知 2:系统消息
 	OnlyUnRead bool `form:"onlyUnRead"` // 是否未读信息
+	LastID     int  `form:"lastID"`     // 自增ID
 }
 
 // QueryNoticeRsp 通知公告系统消息查询返回模型
@@ -37,6 +38,7 @@ type QueryNoticeRsp struct {
 // @Param loginID query int true "登录账号"
 // @Param msgType query int false "消息类型 - 1:公告通知 2:系统消息"
 // @Param onlyUnRead query bool false "是否只获取未读信息"
+// @Param lastID query int false "自增ID,传入后会返回这个ID后面的记录"
 // @Success 200 {object} QueryNoticeRsp
 // @Failure 500 {object} app.Response
 // @Router /Common/QueryNotice [get]
@@ -75,6 +77,9 @@ func QueryNotice(c *gin.Context) {
 	if req.MsgType > 0 {
 		s = s.And("MSGTYPE = ?", req.MsgType)
 	}
+	if req.LastID != 0 {
+		s = s.And("AUTOID > ?", req.LastID)
+	}
 	if req.OnlyUnRead && len(msgReceivers) > 0 {
 		s = s.NotIn("AUTOID", msgReceivers)
 	}
@@ -93,6 +98,9 @@ func QueryNotice(c *gin.Context) {
 	if req.MsgType > 0 {
 		s = s.And("MSGTYPE = ?", req.MsgType)
 	}
+	if req.LastID != 0 {
+		s = s.And("AUTOID > ?", req.LastID)
+	}
 	if req.OnlyUnRead && len(msgReceivers) > 0 {
 		s = s.NotIn("AUTOID", msgReceivers)
 	}
@@ -111,6 +119,9 @@ func QueryNotice(c *gin.Context) {
 	if req.MsgType > 0 {
 		s = s.And("MSGTYPE = ?", req.MsgType)
 	}
+	if req.LastID != 0 {
+		s = s.And("AUTOID > ?", req.LastID)
+	}
 	if req.OnlyUnRead && len(msgReceivers) > 0 {
 		s = s.NotIn("AUTOID", msgReceivers)
 	}

+ 6 - 0
docs/docs.go

@@ -610,6 +610,12 @@ var doc = `{
                         "description": "是否只获取未读信息",
                         "name": "onlyUnRead",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "自增ID,传入后会返回这个ID后面的记录",
+                        "name": "lastID",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 6 - 0
docs/swagger.json

@@ -594,6 +594,12 @@
                         "description": "是否只获取未读信息",
                         "name": "onlyUnRead",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "自增ID,传入后会返回这个ID后面的记录",
+                        "name": "lastID",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 4 - 0
docs/swagger.yaml

@@ -9257,6 +9257,10 @@ paths:
         in: query
         name: onlyUnRead
         type: boolean
+      - description: 自增ID,传入后会返回这个ID后面的记录
+        in: query
+        name: lastID
+        type: integer
       produces:
       - application/json
       responses: