liuxiaolong
2019-11-13 000e51f17eba47c3502ee8f717f53f1fae3d0bbd
controllers/dbtableperson.go
@@ -24,9 +24,8 @@
// @Produce json
// @Tags dbperson 底库人员
// @Param obj body models.Dbtablepersons true "底库人员数据"
// @Success 200 {object} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Failure 400 {object} json code.RequestParamError
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/dbperson/addDbPerson [PUT]
func (dbc DbPersonController) AddDbPerson(c *gin.Context) {
   dbperson := new(models.Dbtablepersons)
@@ -48,20 +47,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
}
@@ -141,7 +147,6 @@
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/dbperson/deleteDbPersonById/{uuid} [POST]
func (dbc DbPersonController) DeleteDbPerson(c *gin.Context) {
   id := c.Params.ByName("uuid")
   if id == "" {
@@ -157,12 +162,14 @@
   }
}
// @Summary 删除底库人员
// @Description 删除库人员
type multiIds []string
// @Summary 批量删除底库人员
// @Description 批量删除库人员
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @Param uuids body []string true "底库人员ids "
// @Param uuids body controllers.multiIds true "底库人员ids"
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/dbperson/deleteMoreDbPerson [POST]
@@ -188,41 +195,41 @@
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @Param reqMap body map false "{"tableId":"","orderName":"uuid","orderType":"desc","contentValue":"","page":1,"size":8}"
// @Param reqMap body controllers.DbtSearch false "{"tableId":"","orderName":"id","orderType":"desc","contentValue":"","page":1,"size":8}"
// @Success 200 {string} json "{"code":200, "msg":"目录结构数据", "success":true,"data":{}}"
// @Failure 500 {string} json "{code:500,  msg:"返回错误信息", success:false,data:{}}"
// @Router /data/api-v/dbperson/queryDbPersonsByTbId [POST]
func (dbc DbPersonController) QueryDbPersonsByTbId(c *gin.Context) {
   reqBody := make(map[string]interface{}, 5)
   c.BindJSON(&reqBody)
   tableId := ""
   if reqBody["tableId"] != nil {
      tableId = reqBody["tableId"].(string)
   //reqBody := make(map[string]interface{}, 5)
   var reqBody DbtSearch
   err := c.BindJSON(&reqBody)
   if err !=nil || reqBody.Page <=0 || reqBody.Size <=0 {
      util.ResponseFormat(c,code.RequestParamError,"参数有误")
      return
   }
   if reqBody.TableId == "" {
      util.ResponseFormat(c,code.RequestParamError,"参数有误,底库id不能为空")
      return
   }
   orderName := "id"
   if reqBody["orderName"] != nil {
      orderName = reqBody["orderName"].(string)
   if reqBody.OrderName != "" {
      orderName = reqBody.OrderName
   } // 列名
   orderType := "desc"
   if reqBody["orderType"] != nil {
      orderType = reqBody["orderType"].(string)
   if reqBody.OrderType != "" {
      orderType = reqBody.OrderType
   } // 列类型
   contentValue := ""
   if reqBody["contentValue"] != nil {
      contentValue = reqBody["contentValue"].(string)
   } //输入框内容
   page := 1
   if reqBody["page"] != nil {
      page = int(reqBody["page"].(float64))
   if reqBody.Page >1 {
      page = reqBody.Page
   } // 页码
   size := 8
   if reqBody["size"] != nil {
      size = int(reqBody["size"].(float64))
   if reqBody.Size >8 {
      size = reqBody.Size
   } // 条数
   if tableId == "all" || tableId == "" {
      // / 所有人员
   }
   if orderType == "desc" {
      orderType = "desc"
@@ -231,7 +238,7 @@
   }
   var pApi dbapi.DbPersonApi
   paramBody := map[string]interface{}{
      "tableId":tableId,
      "tableId": reqBody.TableId,
      "orderName":orderName,
      "orderType":orderType,
      "contentValue":contentValue,
@@ -244,15 +251,24 @@
   } else {
      util.ResponseFormat(c,code.ComError,[]interface{}{})
   }
   util.ResponseFormat(c, code.Success, data)
}
type DbtSearch struct {
   TableId string `json:"tableId"`
   OrderName string `json:"orderName"`
   OrderType string `json:"orderType"`
   ContentValue string `json:"contentValue"`
   Page int `json:"page"`
   Size int `json:"size"`
}
/*
// @Summary 查询底库人员列表
// @Description 查询库人员列表
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @Param reqMap body map false "{"tableId":"","orderName":"uuid","orderType":"desc","contentValue":"","page":1,"size":8}"
// @Param reqMap body map false "{"tableId":"","orderName":"id","orderType":"desc","contentValue":"","page":1,"size":8}"
// @Success 200 {string} json "{"code":200, "msg":"目录结构数据", "success":true,"data":{}}"
// @Failure 500 {string} json "{code:500,  msg:"返回错误信息", success:false,data:{}}"
// @Router /data/api-v/dbperson/queryDbPersonsByCampare [POST]
@@ -313,14 +329,7 @@
   data := esutil.GetEsDataReq(url, params, true)
   featByte := make([]byte, 0, 1024)
   if len(faceUrl) > 3 { //   linux
      /*fileName := picUrl   // picIp 定义在 fileController weedfs 文件服务器 访问 路径 前缀
      detect := gorun.GetSimpleFaceDetect(fileName)
      if len(detect) != 1 {
         util.ResponseFormat(c,code.TooManyFeatureFindError,"图片特征值过多")
         return
      }else {
         featByte = detect[0]["feature"].([]byte)
      }*/ //   linux
   }
   to := page * size
   datalist := sourceCompare(data["datalist"].([]interface{}), false, featByte, threshold)
@@ -336,3 +345,4 @@
   //c.JSON(200, data)
   util.ResponseFormat(c, code.Success, data)
}
*/