From f4e8f206a6760bdc31734dfcb1c65916b5b76311 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 22 八月 2019 12:05:58 +0800 Subject: [PATCH] add cluster --- controllers/dbtableperson.go | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index 6e69685..9afabe9 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -48,20 +48,27 @@ func addDbPerson(dbperson *models.Dbtablepersons) (result map[string]interface{}) { - personId := uuid.NewV4().String() // 浠ュ悗鏇夸唬 渚濇嵁鐢熸垚瑙勫垯 + personId := uuid.NewV4().String() dbperson.Id = personId dbperson.PriInsert() - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + - "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + personId + "?refresh=wait_for" - personbytes, e := json.Marshal(dbperson) - if e != nil { - logger.Debug("Json marshaling failed锛�%s\n", e) - } - params := string(personbytes) - data, _ := esutil.PutEsDataReq(url, params) - //c.JSON(200, changeEsRespData(data, "娣诲姞浜哄憳鎴愬姛")) - result = changeEsRespData(data, "娣诲姞鎴愬姛") + var pApi dbapi.DbPersonApi + paramBody := util.Struct2Map(dbperson) + b, _ := pApi.AddDbPerson(paramBody) + result = map[string]interface{}{} + if b { + result["code"] = 200 + data := make(map[string]interface{}) + data["uuid"] = personId + result["data"] = data + result["success"] = true + result["msg"] = "娣诲姞鎴愬姛" + } else { + result["data"] = nil + result["success"] = false + result["msg"] = "鏈嶅姟鍣ㄥ紓甯�" + result["code"] = 500 + } return result } @@ -199,6 +206,10 @@ if reqBody["tableId"] != nil { tableId = reqBody["tableId"].(string) } + if tableId == "" { + util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎锛屽簳搴搃d涓嶈兘涓虹┖") + return + } orderName := "id" if reqBody["orderName"] != nil { orderName = reqBody["orderName"].(string) @@ -244,7 +255,6 @@ } else { util.ResponseFormat(c,code.ComError,[]interface{}{}) } - util.ResponseFormat(c, code.Success, data) } // @Summary 鏌ヨ搴曞簱浜哄憳鍒楄〃 -- Gitblit v1.8.0