From f9c3e6809dc080cd55cfdc7573380aee4cef0b8f Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期二, 29 十月 2019 16:41:58 +0800 Subject: [PATCH] fix swagger --- controllers/dbtableperson.go | 114 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 88 insertions(+), 26 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index ac89321..18d6ac9 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -21,6 +21,8 @@ "webserver/extend/esutil" "webserver/extend/util" "webserver/models" + + esApi "basic.com/pubsub/esutil.git" ) type DbPersonController struct { @@ -129,18 +131,19 @@ } else { faceB = face.FaceBytes } - var sysSetApi dbapi.SysSetApi + analyServerId := "" - flag, sysconf := sysSetApi.GetServerInfo() - if flag { - analyServerId = sysconf.ServerId + conf, e := cache.GetServerInfo() + if e ==nil && conf.ServerId != "" { + analyServerId = conf.ServerId } else { util.ResponseFormat(c, code.ComError, "analyServerId涓虹┖锛岄厤缃湁璇�") return } + arg := protomsg.CompareArgs{ FaceFeature: faceB, - CompareThreshold: 0.6, + CompareThreshold: searchBody.Threshold, } arg.TableIds = searchBody.DataBases arg.AnalyServerId = analyServerId @@ -182,9 +185,9 @@ } //濉厖鍚戝墠绔繑鍥炵殑鏁版嵁 -func FillDbPersonDataToCompareResult(compResult *protomsg.SdkCompareResult) []DbPersonVo { +func FillDbPersonDataToCompareResult(compResult *protomsg.SdkCompareResult) []models.DbPersonsCompVo { - var resultList = make([]DbPersonVo, len(compResult.CompareResult)) + var resultList = make([]models.DbPersonsCompVo, len(compResult.CompareResult)) dbPersonM := make(map[string]ScoreIndex, 0) personIds := make([]string,0) @@ -204,25 +207,32 @@ } if len(dbpersons) >0 { - var dtApi dbapi.DbTableApi + //var dtApi dbapi.DbTableApi for _,p :=range dbpersons { - var dbP = DbPersonVo { - PersonId: p.Id, - IdCard: p.IdCard, - CompareScore: util.ParseScore(dbPersonM[p.Id].CompareScore), - MonitorLevel: p.MonitorLevel, - PersonName: p.PersonName, - PersonPicUrl: p.PersonPicUrl, - PhoneNum: p.PhoneNum, - Sex: p.Sex, - TableId: p.TableId, - Enable: p.Enable, - } - dbTableInfos, _ := dtApi.DbtablesById([]string{ p.TableId }) - if dbTableInfos !=nil{ - dbP.BwType = dbTableInfos[0].BwType - dbP.TableName = dbTableInfos[0].TableName - } + var dbP models.DbPersonsCompVo + + dbP.Id = p.Id + dbP.TableId = p.TableId + dbP.FaceFeature = p.FaceFeature + dbP.PersonPicUrl = p.PersonPicUrl + dbP.PersonName = p.PersonName + dbP.Age = p.Age + dbP.Sex = p.Sex + dbP.IdCard = p.IdCard + dbP.PhoneNum = p.PhoneNum + dbP.MonitorLevel = p.MonitorLevel + dbP.Reserved = p.Reserved + dbP.IsDelete = int(p.IsDelete) + dbP.Enable = int(p.Enable) + dbP.CreateTime = p.CreateTime + dbP.UpdateTime = p.UpdateTime + dbP.CreateBy = p.CreateBy + dbP.CompareScore = util.ParseScore(dbPersonM[p.Id].CompareScore) + //dbTableInfos, _ := dtApi.DbtablesById([]string{ p.TableId }) + //if dbTableInfos !=nil{ + // dbP.BwType = dbTableInfos[0].BwType + // dbP.TableName = dbTableInfos[0].TableName + //} resultList[dbPersonM[p.Id].Index] = dbP } } @@ -313,7 +323,7 @@ func UpdateDbPersonsOfDbTable(id string) (message string) { localConf, err2 := cache.GetServerInfo() - if err2 !=nil || localConf.AlarmIp == "" { + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { logger.Debug("localConfig is wrong!!!") return "淇敼澶辫触" } @@ -476,6 +486,58 @@ } } +type JoinDbTVo struct { + CaptureId string `json:"captureId"` + TableIds []string `json:"tableIds"` +} + +// @Summary 鎶撴媿浜哄憳鍔犲叆搴曞簱 +// @Description 鎶撴媿浜哄憳鍔犲叆搴曞簱 +// @Accept json +// @Produce json +// @Tags 搴曞簱浜哄憳 +// @Param obj body controllers.JoinDbTVo true "搴曞簱鏁版嵁" +// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" +// @Router /data/api-v/dbperson/joinDbTable [POST] +func (sc *DbPersonController) JoinDbTable(c *gin.Context) { + var reqBody JoinDbTVo + c.BindJSON(&reqBody) + if reqBody.CaptureId == "" || len(reqBody.TableIds) ==0 { + util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎") + return + } + localConf, err := cache.GetServerInfo() + if err !=nil || localConf.AlarmIp == "" || localConf.AlarmPort <=0 { + util.ResponseFormat(c,code.ComError,"鎶ヨ璁剧疆鏈夎") + return + } + videopersons, e := esApi.Videopersonsinfosbyid([]string{reqBody.CaptureId}, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) + if e ==nil && videopersons !=nil && len(videopersons) == 1{ + var personPicUrl = ""//浜鸿劯鍥剧墖 + var feature = ""//鐗瑰緛 + if videopersons[0].PicSmUrl !=nil && len(videopersons[0].PicSmUrl) >0 { + personPicUrl = videopersons[0].PicSmUrl[0] + } + fea, e2 := esApi.GetVideoPersonFaceFeatureById(reqBody.CaptureId, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) + if e2 == nil && fea !="" { + feature = fea + } + if personPicUrl != "" && feature != "" { + var dbpApi dbapi.DbPersonApi + b,d := dbpApi.JoinDbTable(reqBody.TableIds, feature, personPicUrl) + if b { + util.ResponseFormat(c,code.Success,d) + return + } else { + util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触") + return + } + } + } + util.ResponseFormat(c,code.ComError,"鍔犲叆澶辫触") +} + type DbtSearch struct { TableId string `json:"tableId"` OrderName string `json:"orderName"` -- Gitblit v1.8.0