|
@@ -3,19 +3,26 @@ package service
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
"sfbase/core"
|
|
"sfbase/core"
|
|
|
|
+ "sfbase/utils"
|
|
"sfis/db"
|
|
"sfis/db"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+var SE = utils.SimpleEncrypt{Key: "topJYBX2019"}
|
|
|
|
+
|
|
func ProjectDetailData(id string) (data []map[string]interface{}, httpStatus int, err error) {
|
|
func ProjectDetailData(id string) (data []map[string]interface{}, httpStatus int, err error) {
|
|
httpStatus = 200
|
|
httpStatus = 200
|
|
_query := `{"query":{"bool":{"must":[{"term":{"id":"%s"}}],"must_not":[],"should":[]}},"_source":[%s]}`
|
|
_query := `{"query":{"bool":{"must":[{"term":{"id":"%s"}}],"must_not":[],"should":[]}},"_source":[%s]}`
|
|
- fields := `"s_winner","projectname","projectcode","buyer","buyertel","buyerperson","jgtime","zbtime","bidamount","budget","buyerclass","area","city","sourceinfourl"`
|
|
|
|
|
|
+ fields := `"_id","s_winner","projectname","projectcode","buyer","buyertel","buyerperson","jgtime","zbtime","bidamount","budget","buyerclass","area","city","sourceinfourl"`
|
|
query := fmt.Sprintf(_query, id, fields)
|
|
query := fmt.Sprintf(_query, id, fields)
|
|
INDEX := core.GetStringConf("es.project.index")
|
|
INDEX := core.GetStringConf("es.project.index")
|
|
TYPE := core.GetStringConf("es.project.itype")
|
|
TYPE := core.GetStringConf("es.project.itype")
|
|
infos := db.Es.Get(INDEX, TYPE, query)
|
|
infos := db.Es.Get(INDEX, TYPE, query)
|
|
if infos != nil && len(*infos) > 0 {
|
|
if infos != nil && len(*infos) > 0 {
|
|
data = *infos
|
|
data = *infos
|
|
|
|
+ for _, val := range data {
|
|
|
|
+ val["project_id"] = SE.EncodeString(utils.ObjToString(val["_id"]))
|
|
|
|
+ delete(val, "_id")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return data, httpStatus, nil
|
|
return data, httpStatus, nil
|
|
}
|
|
}
|