王传进 преди 8 години
родител
ревизия
ec4322dbf6
променени са 1 файла, в които са добавени 91 реда и са изтрити 8 реда
  1. 91 8
      src/jfw/front/entserach.go

+ 91 - 8
src/jfw/front/entserach.go

@@ -1,14 +1,20 @@
 package front
 
 import (
-	//"fmt"
-	//"jfw/config"
+	"fmt"
 	"log"
-	//"math/rand"
-	//"qfw/util"
-	//"time"
-
+	"qfw/util"
+	"qfw/util/redis"
 	"github.com/go-xweb/xweb"
+	"time"
+	"math/rand"
+	//"regexp"
+	//"strconv"
+	//"strings"
+	//"sync"
+
+	//. "github.com/thinxer/go-word2vec"
+	//"gopkg.in/mgo.v2/bson"
 )
 
 type Entsearch struct {
@@ -20,7 +26,84 @@ func init() {
 	xweb.AddAction(&Entsearch{})
 }
 
-func (p *Entsearch) Bidsearchforent() error {
+func (m *Entsearch) Bidsearchforent() error {
 	log.Println("-------中标企业搜索:")
-	return p.Render("/pc/biddingsearch_enterprise.html", &p.T)
+
+	//keywords := m.GetString("keywords")
+
+	searchvalue := m.GetString("searchvalue")
+	area := m.GetString("area")
+	publishtime := m.GetString("publishtime")
+	//toptype := m.GetString("toptype")
+	subtype := m.GetString("subtype")
+	//selectType := m.GetString("selectType")
+	//selectTypesess := m.GetSession("selectType")
+
+	var list *[]map[string]interface{}
+	pages := make([]interface{}, 0)
+	//var status = 2
+	//var count int64
+	intns := make([]int, 0)
+	for i := 0; i < 10; i++ {
+		if len(intns) == 0 {
+			intns = append(intns, rand.Intn(100))
+		} else {
+			for {
+				v := rand.Intn(intns[(i-1)] + 100)
+				if v-intns[(i-1)] >= 30 {
+					intns = append(intns, v)
+					break
+				}
+			}
+		}
+	}
+	for i := 0; i < 10; i++ {
+		_, list = getLastNewsData(searchvalue, area, publishtime, subtype, intns[i], true)
+		fmt.Println(list)
+		for k, v := range *list {
+			v["k"] = (k + 1) + i*50
+			t := time.Unix(util.Int64All(v["publishtime"]), 0)
+			v["timetemp"] = fmt.Sprint(util.Int64All(v["publishtime"]))
+			v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
+			v["time"] = util.TimeDiff(t)
+			var stp = ""
+			if v["subtype"] != nil {
+				stp, _ = v["subtype"].(string)
+			} else {
+				stp = ""
+			}
+			if stp == "" && v["toptype"] != nil {
+				stp, _ = v["toptype"].(string)
+			}
+			area, _ := v["area"].(string)
+			v["stypeadd"], v["areaadd"] = classify(stp, area)
+		}
+		pages = append(pages, list)
+	}
+	m.DisableHttpCache()
+	redis.Put("other", "index_list", pages, 60*60*2)
+
+	//if status == 2 && m.Method() == "GET" {
+	//	pages := redis.Get("other", "index_list").([]interface{})
+	//	p := util.IntAll(p)
+	//	if p <= 0 || p > 10 {
+	//		p = 1
+	//	}
+	//
+	//	if p-1 <= 0 {
+	//		m.T["prev"] = 1
+	//	} else {
+	//		m.T["prev"] = p - 1
+	//	}
+	//	if p+1 >= 11 {
+	//		m.T["next"] = 10
+	//	} else {
+	//		m.T["next"] = p + 1
+	//	}
+	//	m.T["cur"] = p
+	//	m.T["list"] = pages[p-1]
+	//
+	//	return m.Render("/pc/biddingsearch_enterprise.html", &m.T)
+	//}
+	return m.Render("/pc/biddingsearch_enterprise.html", &m.T)
 }