|
@@ -5,31 +5,22 @@ import (
|
|
|
"log"
|
|
|
"qfw/util"
|
|
|
"qfw/util/redis"
|
|
|
- _"strconv"
|
|
|
- //"time"
|
|
|
"tools"
|
|
|
- //"wx"
|
|
|
"github.com/go-xweb/xweb"
|
|
|
-
|
|
|
- //"gopkg.in/mgo.v2/bson"
|
|
|
- _"time"
|
|
|
"qfw/util/elastic"
|
|
|
-
|
|
|
-//"gopkg.in/mgo.v2/bson"
|
|
|
+ "config"
|
|
|
+ "strconv"
|
|
|
)
|
|
|
|
|
|
-var se = util.SE
|
|
|
var mongodb = tools.MQFW
|
|
|
|
|
|
type FollowEnt struct {
|
|
|
*xweb.Action
|
|
|
-
|
|
|
entList xweb.Mapper `xweb:"/jylab/followent/entList"` //获取关注企业列表
|
|
|
addEnt xweb.Mapper `xweb:"/jylab/followent/addEnt"` //添加关注企业页面
|
|
|
- newInfo xweb.Mapper `xweb:"/jylab/followent/newInfo"` //企业最新信息
|
|
|
+ newInfo xweb.Mapper `xweb:"/jylab/followent/newInfo/(.*)/(.*)"` //企业最新信息
|
|
|
recList xweb.Mapper `xweb:"/jylab/followent/recList"` //获取推荐企业列表
|
|
|
saveEnt xweb.Mapper `xweb:"/jylab/followent/saveEnt"` //保存关注企业
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
@@ -46,28 +37,20 @@ func (f *FollowEnt) EntList() error {
|
|
|
// entArr = append(entArr, entMap)
|
|
|
//}
|
|
|
//f.T["datas"] = entArr
|
|
|
- f.T["followLimit"] = "10"
|
|
|
-
|
|
|
- //{"s_userid":"`+f.GetSession("userId").(string)+`"}
|
|
|
- datas, ok := mongodb.Find("follow_project", ``, `{"l_lastpushtime":-1,"l_createtime":-1}`, `{"s_projectname":1,"s_projectcode":1,"i_remind":1,"l_lastpushtime":1,"l_createtime":1}`, false, 0, 10)
|
|
|
+ f.T["followLimit"] = config.Sysconfig["followentlimit"]
|
|
|
+ datas, ok := mongodb.Find("jylab_followent", `{"s_userid":"`+f.GetSession("userId").(string)+`"}`, `{"l_createtime":-1}`, `{"_id":1,"winner":1,"s_userid":1,"s_openid":1,"l_createtime":1,"s_id":1}`, false, 0, 10)
|
|
|
f.T["flag"] = false
|
|
|
if ok && datas != nil && len(*datas) > 0 {
|
|
|
for k, v := range *datas {
|
|
|
v["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["_id"]))
|
|
|
log.Println(k, ":", v["l_createtime"])
|
|
|
- if v["l_lastpushtime"] == "" || v["l_lastpushtime"] == nil {
|
|
|
- v["l_lastpushtime"] = v["l_createtime"]
|
|
|
- }
|
|
|
}
|
|
|
f.T["datas"] = datas
|
|
|
}
|
|
|
-
|
|
|
- f.T["name"] = "关注的企业---"
|
|
|
return f.Render("/weixin/list.html", &f.T)
|
|
|
}
|
|
|
|
|
|
func (f *FollowEnt) AddEnt() error {
|
|
|
- f.T["name"] = "to add page---"
|
|
|
return f.Render("/weixin/add.html", &f.T)
|
|
|
}
|
|
|
|
|
@@ -75,9 +58,13 @@ func (f *FollowEnt) RecList() {
|
|
|
fmt.Println("entName", f.GetString("entName"))
|
|
|
var entName = f.GetString("entName")
|
|
|
if entName!=""{
|
|
|
- r := elastic.GetPage("winner", "winner", `{"winner":"`+entName+`"}`, ``, `"_id","winner"`, 0, 10)
|
|
|
+ limit,_ := strconv.Atoi(config.Sysconfig["recommendEntLimit"].(string))
|
|
|
+ r := elastic.GetPage("winner", "winner", `{"winner":"`+entName+`"}`, ``, `"_id","winner"`, 0, limit)
|
|
|
if r!=nil && len(*r) != 0{
|
|
|
fmt.Println("RecList",r)
|
|
|
+ for _,v := range *r{
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
|
|
|
+ }
|
|
|
f.ServeJson(map[string]interface{}{
|
|
|
"recList": r,
|
|
|
})
|
|
@@ -94,15 +81,19 @@ func (f *FollowEnt) SaveEnt() {
|
|
|
}
|
|
|
|
|
|
//企业最新信息
|
|
|
-func (f *FollowEnt) NewInfo(id string) error {
|
|
|
- //defer util.Catch()
|
|
|
- //id = util.DecodeArticleId2ByCheck(id)
|
|
|
- //fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
- //data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
- // "_id": bson.ObjectIdHex(id),
|
|
|
- // //"s_userid": m.GetSession("userId").(string),
|
|
|
- //}, fields)
|
|
|
-
|
|
|
+func (f *FollowEnt) NewInfo(winner,id string) error {
|
|
|
+ defer util.Catch()
|
|
|
+ ////var winner = "天津超林时代科技发展有限公司"
|
|
|
+ fields := `{"projectname":1,"projectcode":1,"bidamount":1,"title":1,"publishtime":1,"subtype":1}`
|
|
|
+ data, ok := mongodb.Find("bidding", `{"winner":"`+winner+`"}`, nil, fields, false, -1, -1)
|
|
|
+ if !ok || data == nil || len(*data) == 0 {
|
|
|
+ return f.Render("_error.html")
|
|
|
+ }
|
|
|
+ if ok && data != nil && *data != nil && len(*data) != 0 {
|
|
|
+ f.T["data"] = data
|
|
|
+ fmt.Println(f.T["data"])
|
|
|
+ }
|
|
|
+ f.T["winner"] = winner
|
|
|
return f.Render("/weixin/set.html", &f.T)
|
|
|
}
|
|
|
|