| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | "log" |
| | | "strconv" |
| | | "time" |
| | | "webserver/discovery" |
| | | "webserver/extend/logger" |
| | | |
| | | "github.com/gin-gonic/gin" |
| | |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | esApi "basic.com/pubsub/esutil.git" |
| | | ) |
| | | |
| | | type DbPersonController struct { |
| | |
| | | params := string(personbytes) |
| | | logger.Debug("请求url:%s;\n 请求参数params:%s", url, params) |
| | | data, _ := esutil.PutEsDataReq(url, params) |
| | | if data["_id"] !=""{ |
| | | //通知比对进程缓存更新 |
| | | discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | PersonId: personId, |
| | | TableId: []string{ dbperson.TableId }, |
| | | Feature: dbperson.FaceFeature, |
| | | Action: protomsg.DbAction_Insert, |
| | | }) |
| | | } |
| | | //if data["_id"] !=""{ |
| | | // //通知比对进程缓存更新 |
| | | // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | // Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | // PersonId: personId, |
| | | // TableId: []string{ dbperson.TableId }, |
| | | // Feature: dbperson.FaceFeature, |
| | | // Action: protomsg.DbAction_Insert, |
| | | // }) |
| | | //} |
| | | |
| | | //c.JSON(200, changeEsRespData(data, "添加人员成功")) |
| | | result = changeEsRespData(data, "添加成功") |
| | |
| | | result := changeEsRespData(data, "修改成功") |
| | | if result["success"].(bool) { |
| | | //code.Success.Message = "修改底库人员成功" |
| | | if dbperson.Enable == 1 { |
| | | discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | PersonId: dbperson.Id, |
| | | TableId: []string{ dbperson.TableId }, |
| | | Feature: "", |
| | | Action: protomsg.DbAction_Insert, |
| | | }) |
| | | } else { |
| | | discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | PersonId: dbperson.Id, |
| | | TableId: []string{ dbperson.TableId }, |
| | | Feature: "", |
| | | Action: protomsg.DbAction_Delete, |
| | | }) |
| | | } |
| | | //if dbperson.Enable == 1 { |
| | | // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | // Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | // PersonId: dbperson.Id, |
| | | // TableId: []string{ dbperson.TableId }, |
| | | // Feature: "", |
| | | // Action: protomsg.DbAction_Insert, |
| | | // }) |
| | | //} else { |
| | | // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | // Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | // PersonId: dbperson.Id, |
| | | // TableId: []string{ dbperson.TableId }, |
| | | // Feature: "", |
| | | // Action: protomsg.DbAction_Delete, |
| | | // }) |
| | | //} |
| | | util.ResponseFormat(c, code.Success, result["data"]) |
| | | } else { |
| | | //code.ServiceInsideError.Message += result["msg"].(string) |
| | |
| | | if result["success"].(bool) { |
| | | //code.Success.Message = "删除底库人员成功" |
| | | //通知比对进程,此人已删除 |
| | | dbperArr, e := esApi.Dbpersoninfosbyid([]string{uuid}, config.EsInfo.EsIndex.Dbtablepersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | if e ==nil && len(dbperArr) > 0{ |
| | | if dbperArr[0].TableId !=""{ |
| | | discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | PersonId: uuid, |
| | | TableId: []string{ dbperArr[0].TableId }, |
| | | Feature: "", |
| | | Action: protomsg.DbAction_Delete, |
| | | }) |
| | | } |
| | | } |
| | | //dbperArr, e := esApi.Dbpersoninfosbyid([]string{uuid}, config.EsInfo.EsIndex.Dbtablepersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | //if e ==nil && len(dbperArr) > 0{ |
| | | // if dbperArr[0].TableId !=""{ |
| | | // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | // Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | // PersonId: uuid, |
| | | // TableId: []string{ dbperArr[0].TableId }, |
| | | // Feature: "", |
| | | // Action: protomsg.DbAction_Delete, |
| | | // }) |
| | | // } |
| | | //} |
| | | |
| | | util.ResponseFormat(c, code.Success, result["data"]) |
| | | } else { |
| | |
| | | //result := changeEsRespData(data, "删除成功") |
| | | if data["error"] == nil { |
| | | //code.Success.Message = "删除底库人员成功" |
| | | dbperArr, e := esApi.Dbpersoninfosbyid(uuids, config.EsInfo.EsIndex.Dbtablepersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | if e ==nil && len(dbperArr) > 0{ |
| | | for _,esPer :=range dbperArr { |
| | | if esPer.TableId !=""{ |
| | | discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | PersonId: esPer.Id, |
| | | TableId: []string{ esPer.TableId }, |
| | | Feature: "", |
| | | Action: protomsg.DbAction_Delete, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | //dbperArr, e := esApi.Dbpersoninfosbyid(uuids, config.EsInfo.EsIndex.Dbtablepersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | //if e ==nil && len(dbperArr) > 0{ |
| | | // for _,esPer :=range dbperArr { |
| | | // if esPer.TableId !=""{ |
| | | // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ |
| | | // Type: protomsg.EsCacheChanged_T_DbTablePerson, |
| | | // PersonId: esPer.Id, |
| | | // TableId: []string{ esPer.TableId }, |
| | | // Feature: "", |
| | | // Action: protomsg.DbAction_Delete, |
| | | // }) |
| | | // } |
| | | // } |
| | | //} |
| | | util.ResponseFormat(c, code.Success, "删除底库人员成功") |
| | | } else { |
| | | //code.ServiceInsideError.Message += result["msg"].(string) |