Prechádzať zdrojové kódy

fix:修改我的邀请接口

xuemingyang 3 rokov pred
rodič
commit
bcd16d297a
1 zmenil súbory, kde vykonal 11 pridanie a 9 odobranie
  1. 11 9
      services/activity/share/service.go

+ 11 - 9
services/activity/share/service.go

@@ -95,17 +95,18 @@ func (c *ShareRouter) Receive(r *ghttp.Request) {
 }
 
 func (c *ShareRouter) List(r *ghttp.Request) {
-	userid := r.Header.Get("userId")
-	pNum := r.Get("pageNum").Int()
-	pSize := r.Get("pagesize").Int()
-	if pSize == 0 {
-		pSize = 5
-	}
 	rdata := map[string]interface{}{
 		"count":        0,
 		"haveNextPage": false,
 		"res":          []map[string]interface{}{},
 	}
+	userid := r.Header.Get("userId")
+	pNum := r.Get("pageNum").Int()
+	pSize := r.Get("pageSize").Int()
+	if pSize == 0 && pNum == 0 {
+		pSize = -1
+		pNum = 1
+	}
 	query := map[string]interface{}{
 		"share_uid": userid,
 	}
@@ -119,10 +120,11 @@ func (c *ShareRouter) List(r *ghttp.Request) {
 		return
 	}
 	result, _ := db.Mgo.Find("user_share", query, `{"createtime":-1}`, `{"shared_uid":1}`, false, pNum*pSize, pSize)
-	haveNextPage := (pNum+1)*pSize < count
+	if pSize != -1 {
+		haveNextPage := (pNum+1)*pSize < count
+		rdata["haveNextPage"] = haveNextPage
+	}
 	rdata["count"] = count
-	rdata["haveNextPage"] = haveNextPage
-	rdata["pageSize"] = pSize
 	rdata["res"] = Info(result)
 	r.Response.WriteJson(g.Map{
 		"error_code": 0,