فهرست منبع

fix:修改接口返回信息

xuemingyang 3 سال پیش
والد
کامیت
2399a13952
4فایلهای تغییر یافته به همراه10 افزوده شده و 5 حذف شده
  1. 4 2
      handler/award/record.go
  2. 3 0
      services/activity/award/service.go
  3. 2 2
      services/activity/share/service.go
  4. 1 1
      test/shareToaward_test.go

+ 4 - 2
handler/award/record.go

@@ -48,8 +48,10 @@ func GetActivityAwardList(userId, activityCode, award string, pageSize, pageNum
 	q := map[string]interface{}{}
 	q["userid"] = userId
 	q["activity_code"] = activityCode
-	q["award"] = award
-	data, _ := db.Mgo.Find("activity_award", q, "", `{"activity_code":1,"award":1,"date":1,"getway":1,"num":1,}`, false, pageNum*pageSize, pageSize)
+	if award != "" {
+		q["award"] = award
+	}
+	data, _ := db.Mgo.Find("activity_award", q, `{"date":-1}`, `{"activity_code":1,"award":1,"date":1,"getway":1,"num":1}`, false, pageNum*pageSize, pageSize)
 	total = db.Mgo.Count("activity_award", q)
 	hasNext = (pageNum+1)*pageSize < total
 	return *data, total, hasNext

+ 3 - 0
services/activity/award/service.go

@@ -15,6 +15,9 @@ func (a AwardRouter) Awardlist(r *ghttp.Request) {
 	aw := r.Get("award").String()
 	pSize := r.Get("pageSize").Int()
 	pNum := r.Get("pageNum").Int()
+	if pSize == 0 {
+		pSize = 5
+	}
 	data, total, hasNext := award.GetActivityAwardList(userid, code, aw, pSize, pNum)
 	rdata["list"] = data
 	rdata["total"] = total

+ 2 - 2
services/activity/share/service.go

@@ -96,7 +96,7 @@ func (c *ShareRouter) Receive(r *ghttp.Request) {
 }
 
 func (c *ShareRouter) List(r *ghttp.Request) {
-	userid := r.Get("userId").String()
+	userid := r.Header.Get("userId")
 	pNum := r.Get("pageNum").Int()
 	pSize := r.Get("pagesize").Int()
 	rdata := map[string]interface{}{
@@ -193,7 +193,7 @@ func (c *ShareRouter) Followgift(r *ghttp.Request) {
 				} else {
 					if CheckWxBrowser(r.Request) {
 						//所有参数都不再使用,跳到微信验证用户
-						idata["data"] = fmt.Sprintf(Wxoauth, url.QueryEscape(r.Host+r.URL.String()), "wx")
+						idata["wxUrl"] = fmt.Sprintf(Wxoauth, url.QueryEscape(r.Host+r.URL.String()), "wx")
 						fdata["data"] = idata
 						r.Response.WriteJson(fdata)
 					}

+ 1 - 1
test/shareToaward_test.go

@@ -35,7 +35,7 @@ func Test_Award(t *testing.T) {
 		//	{"shared_uid": u},
 		//}
 		q["share_uid"] = u
-		data, _ := Mgo.Find("user_share", q, "createtime asc", `{"_id":1,"createtime":1}`, false, 0, 4)
+		data, _ := Mgo.Find("user_share", q, "", `{"_id":1,"createtime":1}`, false, 0, 4)
 		if len(*data) > 0 {
 			for i, vv := range *data {
 				if i <= 4 {