|
@@ -216,7 +216,7 @@ func GetInfoTitle(info map[string]interface{}) string {
|
|
}
|
|
}
|
|
|
|
|
|
//加载数据到内存中
|
|
//加载数据到内存中
|
|
-func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCache bool, query map[string]interface{}) (*[]map[string]interface{}, int64) {
|
|
|
|
|
|
+func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCache bool, query map[string]interface{}, fields map[string]interface{}) (*[]map[string]interface{}, int64) {
|
|
defer util.Catch()
|
|
defer util.Catch()
|
|
endTime := time.Now().Unix()
|
|
endTime := time.Now().Unix()
|
|
if query == nil || len(query) == 0 {
|
|
if query == nil || len(query) == 0 {
|
|
@@ -228,10 +228,7 @@ func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCac
|
|
}
|
|
}
|
|
}
|
|
}
|
|
logger.Info("开始加载", coll, "数据", query)
|
|
logger.Info("开始加载", coll, "数据", query)
|
|
- var res []map[string]interface{}
|
|
|
|
- sess := mgo.GetMgoConn()
|
|
|
|
- defer mgo.DestoryMongoConn(sess)
|
|
|
|
- it := sess.DB(dbName).C(coll).Find(query).Select(map[string]interface{}{
|
|
|
|
|
|
+ queryField := map[string]interface{}{
|
|
"title": 1,
|
|
"title": 1,
|
|
"detail": 1,
|
|
"detail": 1,
|
|
"projectname": 1,
|
|
"projectname": 1,
|
|
@@ -264,7 +261,16 @@ func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCac
|
|
"bidendtime": 1,
|
|
"bidendtime": 1,
|
|
"entidlist": 1,
|
|
"entidlist": 1,
|
|
"autoid": 1,
|
|
"autoid": 1,
|
|
- }).Iter()
|
|
|
|
|
|
+ }
|
|
|
|
+ if fields == nil {
|
|
|
|
+ for k, v := range fields {
|
|
|
|
+ queryField[k] = v
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var res []map[string]interface{}
|
|
|
|
+ sess := mgo.GetMgoConn()
|
|
|
|
+ defer mgo.DestoryMongoConn(sess)
|
|
|
|
+ it := sess.DB(dbName).C(coll).Find(query).Select(queryField).Iter()
|
|
index := 0
|
|
index := 0
|
|
for temp := make(map[string]interface{}); it.Next(&temp); {
|
|
for temp := make(map[string]interface{}); it.Next(&temp); {
|
|
_id := BsonIdToSId(temp["_id"])
|
|
_id := BsonIdToSId(temp["_id"])
|
|
@@ -280,7 +286,6 @@ func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCac
|
|
temp["area"] = "全国"
|
|
temp["area"] = "全国"
|
|
}
|
|
}
|
|
temp["attachment_count"] = GetAttachmentCount(temp)
|
|
temp["attachment_count"] = GetAttachmentCount(temp)
|
|
- delete(temp, "projectinfo")
|
|
|
|
res = append(res, temp)
|
|
res = append(res, temp)
|
|
if redisCache {
|
|
if redisCache {
|
|
//信息缓存3天
|
|
//信息缓存3天
|