unknown 7 роки тому
батько
коміт
5c95cf71dd

+ 10 - 2
src/apiservice/oamanager/content.go

@@ -5,6 +5,7 @@ import (
 	"net/http"
 	"qfw/util"
 	elastic "qfw/util/elastic"
+	"qfw/util/redis"
 	"regexp"
 	"strings"
 	"sync"
@@ -15,7 +16,7 @@ import (
 
 type Content struct {
 	*xweb.Action
-	article xweb.Mapper `xweb:"/article/(.*).html"`
+	article xweb.Mapper `xweb:"/open/article/(.*).html"`
 }
 
 var regex = regexp.MustCompile("(Android|Mobile)")
@@ -30,11 +31,18 @@ func (c *Content) Article(id string) {
 	defer util.Catch()
 	client := c.Header("User-Agent")
 	c.Request.Proto = GetIp(c.Request) //ip
+	var data map[string]interface{}
 	addLog(c.Request)
 	bm := false //访问日志
 	bm = regex.MatchString(client)
 	sid_openid := util.DecodeArticleId2ByCheck(id)[0] //解密id
-	data := *elastic.GetByIdField("bidding", "bidding", sid_openid, `"detail","title","projectname","publishtime"`)
+	res := redis.Get(REDISDB, "jyoadetail_"+sid_openid)
+	if res == nil || res == "" {
+		data = *elastic.GetByIdField("bidding", "bidding", sid_openid, `"detail","title","projectname","publishtime"`)
+		redis.Put(REDISDB, "jyoadetail_"+sid_openid, data, 0)
+	} else {
+		data = *util.ObjToMap(res)
+	}
 	timeF := data["publishtime"].(float64)
 	time := time.Unix(int64(timeF), 0).Format("2006-01-02 15:04")
 	detail := strings.Replace(util.ObjToString(data["detail"]), " ", "", -1)

+ 2 - 2
src/apiservice/oamanager/createuser.go

@@ -13,8 +13,8 @@ import (
 
 type Createuser struct {
 	*xweb.Action
-	createUser xweb.Mapper `xweb:"/createUser"`
-	updateUser xweb.Mapper `xweb:"/updateUser"`
+	createUser xweb.Mapper `xweb:"/open/createUser"`
+	updateUser xweb.Mapper `xweb:"/open/updateUser"`
 }
 
 func init() {

+ 1 - 0
src/config.json

@@ -5,6 +5,7 @@
     "elasticsearch": "http://192.168.3.18:9800",
     "elasticPoolSize": 30,
     "redisaddrs": "jyOpenAPI=192.168.3.18:3380",
+	"redispool":50,
     "webport": "8081",
 	"jyaddress":"https://www.jianyu360.com"
 }

+ 1 - 1
src/main.go

@@ -13,7 +13,7 @@ import (
 
 func init() {
 	initXweb()
-	redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), 100, 30, 300)
+	redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), util.IntAllDef(Sysconfig["redispool"], 10), 20, 240)
 	elastic.InitElasticSize(Sysconfig["elasticsearch"].(string), util.IntAllDef(Sysconfig["elasticPoolSize"], 30))
 }
 

+ 3 - 3
src/web/templates/pc/article.html

@@ -19,9 +19,9 @@ $(function(){
 	$("#div").click(function(){
 		$.ajax({
 		type: "POST",
-		url: "/open",
-		data:{	appid:"jyoaACJUW1BJXwECCA1fDwUj",
-				pagenum:2,
+		url: "https://api.jianyu360.com/open",
+		data:{	appid:"jyoaPx1UW1BJUAoGBw9ePDYJ",
+				pagenum:1,
 				keyword:"万达信息股份有限公司",
 				timestamp:1519869324,
 				action:"getdata",