浏览代码

Merge branch 'master' of http://192.168.3.207:10080/group3/SwordFish_Interface_Service

wanghuidong 4 年之前
父节点
当前提交
f30f3df638
共有 3 个文件被更改,包括 9 次插入6 次删除
  1. 4 3
      api/v1/projects.go
  2. 4 2
      service/projectDetail.go
  3. 1 1
      test/project/project_test.go

+ 4 - 3
api/v1/projects.go

@@ -1,6 +1,7 @@
 package v1
 
 import (
+	"net/http"
 	"sfbase/global"
 	"sfis/service"
 
@@ -30,13 +31,13 @@ func getProjectsList(c *gin.Context) {
 		global.Logger.Info("666")
 		data = service.ProjectListData(projectName, winner, time)
 	}
-	c.JSON(200, data)
+	c.JSON(http.StatusOK, data)
 }
 
 //获取项目详情
 func getProjectDetail(c *gin.Context) {
-	id := c.PostForm("id")
-	global.Logger.Info("id "+ id)
+	id := c.PostForm("projectid")
+	global.Logger.Info("projectid "+ id)
 	data := map[string]interface{}{}
 	if id != "" {
 		data = service.ProjectDetailData(id)

+ 4 - 2
service/projectDetail.go

@@ -10,8 +10,10 @@ import (
 func ProjectDetailData(id string) map[string]interface{} {
 	global.Logger.Info("id " + id)
 	data := map[string]interface{}{}
-	_query := `{"query":{"bool":{"must":[{"term":{"id":"%s"}}],"must_not":[],"should":[]}}}`
-	query := fmt.Sprintf(_query, id)
+	_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","list"`
+	query := fmt.Sprintf(_query, id, fields)
+	global.Logger.Info("query " + query)
 	INDEX := core.GetStringConf("es.project.index")
 	TYPE := core.GetStringConf("es.project.itype")
 	infos := db.Es.Get(INDEX, TYPE, query)

+ 1 - 1
test/project/project_test.go

@@ -29,7 +29,7 @@ func getData() {
 //获取项目详情测试用例
 func Test_ProjectDetails(t *testing.T) {
 	data := post("http://127.0.0.1:8080/sfis/api/v1/projectDetail", map[string]string{
-		"id": "5f6b4e12499cb0822d39c68f",
+		"projectid": "5f6b4e12499cb0822d39c68f",
 	})
 	res := map[string]interface{}{}
 	s, _ := json.Marshal(data)