abiao 4 роки тому
батько
коміт
ca499f6647

+ 1 - 1
go/gopath/src/fohow.com/apps/controllers/ad_controller/ad_controller.go

@@ -91,7 +91,7 @@ func (self *AdController) GetItems() {
 	default:
 		self.Data["json"] = ads
 	}
-	self.ServeJSON()
+	self.ServeResultJSON()
 }
 
 //根据广告位id,获取广告图

+ 37 - 14
go/gopath/src/fohow.com/apps/init.go

@@ -535,22 +535,22 @@ func (self *BaseController) Prepare() {
 		}
 	}
 	/*
-<<<<<<< HEAD
-		// FIXME : userId 与 wxUserId已统一,故不做userid登录check
-=======
-		// FIXME : userId 与 wxUserId已统一
->>>>>>> b24580bdd09b3e2b6278d2deb8d368bb9c21d652
-		if len(self.ExceptCheckUserLoginAction) > 0 {
-			for _, an := range self.ExceptCheckUserLoginAction {
-				if strings.ToLower(an) == "*" || strings.ToLower(an) == strings.ToLower(actionName) {
-					needChkUserLogin = false
-					break
+	<<<<<<< HEAD
+			// FIXME : userId 与 wxUserId已统一,故不做userid登录check
+	=======
+			// FIXME : userId 与 wxUserId已统一
+	>>>>>>> b24580bdd09b3e2b6278d2deb8d368bb9c21d652
+			if len(self.ExceptCheckUserLoginAction) > 0 {
+				for _, an := range self.ExceptCheckUserLoginAction {
+					if strings.ToLower(an) == "*" || strings.ToLower(an) == strings.ToLower(actionName) {
+						needChkUserLogin = false
+						break
+					}
 				}
 			}
-		}
-		if needChkUserLogin {
-			checkUserLogin(self.Ctx)
-		}
+			if needChkUserLogin {
+				checkUserLogin(self.Ctx)
+			}
 	*/
 
 	if needChkWxUserLogin {
@@ -655,3 +655,26 @@ func (self *BaseController) GetCdnFullImgUrl(img string) string {
 		return fmt.Sprintf("%s/%s", beego.AppConfig.String("AliCDNImgHost"), img)
 	}
 }
+
+// ServeJSON sends a json response with encoding charset.
+func (c *BaseController) ServeResultJSON(encoding ...bool) {
+	from := c.GetString("source")
+	beego.BeeLogger.Warn("from--%s", from)
+	type Result struct {
+		Result interface{} `json:"result"`
+	}
+	var (
+		hasIndent   = true
+		hasEncoding = false
+	)
+	if beego.AppConfig.String("RunMode") == "prod" {
+		hasIndent = false
+	}
+	if len(encoding) > 0 && encoding[0] == true {
+		hasEncoding = true
+	}
+	if from == beego.AppConfig.String("SourceList") {
+		c.Data["json"] = &Result{Result: c.Data["json"]}
+	}
+	c.Ctx.Output.JSON(c.Data["json"], hasIndent, hasEncoding)
+}

+ 5 - 0
go/gopath/src/fohow.com/conf/app.conf

@@ -135,6 +135,9 @@ OuBiaoMchKeyFile = "/opt/wxpay/oubiao/apiclient_key.pem"
 Tokenexp = "3600"
 TokenSecrets = "gt69m8b144lr5a6ifjdavheeln4qmmzhqhyy9tudcemazz3es7relb945zep54g4"
 
+#http source
+SourceList = "app"
+
 #######################################################################
 [prod]
 AllowOrigins = *
@@ -265,3 +268,5 @@ OuBiaoMchKeyFile = "/opt/wxpay/oubiao/apiclient_key.pem"
 Tokenexp = "3600"
 TokenSecrets = "gt69m8b144lr5a6ifjdavheeln4qmmzhqhyy9tudcemazz3es7relb945zep54g4"
 
+#http source
+SourceList = "app"