From c4c73a384c1a02c26c81b0a76bb1d10062e64cb4 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 14 十一月 2019 17:28:23 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/webserver
---
controllers/cluster.go | 1
controllers/user.go | 35 ++++++++++-
extend/code/code.go | 2
middlewares/auth/auth.go | 2
controllers/cameraTask.go | 3 +
controllers/cameraTimerule.go | 1
controllers/area.go | 7 +
controllers/esSearch.go | 63 ++++++++-------------
go.mod | 2
controllers/cameraTaskArgs.go | 1
controllers/dbtableperson.go | 2
controllers/dictionary.go | 1
controllers/task.go | 4 +
controllers/sdk.go | 1
router/router.go | 1
controllers/cameraPolygon.go | 2
controllers/fileController.go | 7 +-
controllers/syssetcont.go | 3
controllers/camera.go | 2
go.sum | 4
controllers/cameraPTZ.go | 1
controllers/pollConfig.go | 1
controllers/eventPush.go | 6 ++
controllers/sysMenu.go | 2
24 files changed, 94 insertions(+), 60 deletions(-)
diff --git a/controllers/area.go b/controllers/area.go
index 705c05c..59e7f97 100644
--- a/controllers/area.go
+++ b/controllers/area.go
@@ -59,9 +59,10 @@
util.ResponseFormat(c, code.Success, arr)
}
+// @Security ApiKeyAuth
+// @Accept x-www-form-urlencoded
// @Summary 鍒锋柊Gb28181骞冲彴鏍�
// @Description 鍒锋柊Gb28181骞冲彴鏍�
-// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param id formData string false "鍥芥爣骞冲彴id"
@@ -99,6 +100,7 @@
// @Security ApiKeyAuth
// @Summary 娣诲姞menu鐨勫尯鍩�
// @Description 娣诲姞鐩綍涓婂尯鍩�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param name formData string true "鍖哄煙鍚嶅瓧"
@@ -127,7 +129,7 @@
// @Security ApiKeyAuth
// @Summary 淇敼鍚嶅瓧
// @Description 淇敼鍖哄煙鍚嶅瓧
-// @Accept json
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param id formData string true "鍖哄煙id"
@@ -168,6 +170,7 @@
// @Security ApiKeyAuth
// @Summary 鍒犻櫎涓�涓尯鍩�
// @Description 鐐瑰嚮鍒犻櫎鎸夐挳鏃跺垹闄や竴涓尯鍩�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param id formData string true "褰撳墠id"
diff --git a/controllers/camera.go b/controllers/camera.go
index 83646ba..374accf 100644
--- a/controllers/camera.go
+++ b/controllers/camera.go
@@ -85,6 +85,7 @@
err := c.BindJSON(&cam)
if err != nil {
+ logger.Debug("err:",err)
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟閿欒")
return
}
@@ -293,6 +294,7 @@
// @Security ApiKeyAuth
// @Summary 鍒囨崲鎽勫儚鏈鸿繍琛屽疄鏃舵垨杞鐨勫紑鍏�
// @Description 鍒囨崲鎽勫儚鏈鸿繍琛屽疄鏃舵垨杞鐨勫紑鍏�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags camera
// @Param cameraId formData string true "鎽勫儚鏈篿d"
diff --git a/controllers/cameraPTZ.go b/controllers/cameraPTZ.go
index 2cb0af2..aeceb15 100644
--- a/controllers/cameraPTZ.go
+++ b/controllers/cameraPTZ.go
@@ -23,6 +23,7 @@
// @Summary 浜戝彴
// @Description 鎽勫儚鏈轰簯鍙版帶鍒�
// @Security ApiKeyAuth
+// @Accept json
// @Produce json
// @Tags camera
// @Param ptzBody body controllers.PTZInstruct true "鎺у埗绫诲瀷锛歶p,down,left,right,zoomin,zoomout,stop"
diff --git a/controllers/cameraPolygon.go b/controllers/cameraPolygon.go
index e71a471..7117b62 100644
--- a/controllers/cameraPolygon.go
+++ b/controllers/cameraPolygon.go
@@ -58,7 +58,6 @@
// @Security ApiKeyAuth
// @Summary 鍒犻櫎鎽勫儚鏈哄尯鍩�
// @Description 鍒犻櫎鎽勫儚鏈哄尯鍩�
-// @Accept json
// @Produce json
// @Tags 鎽勫儚鏈哄杈瑰舰
// @Param id query string true "id"
@@ -84,7 +83,6 @@
// @Security ApiKeyAuth
// @Summary 鏌ユ壘鎽勫儚鏈哄尯鍩�
// @Description 鏌ユ壘鎽勫儚鏈哄尯鍩�
-// @Accept json
// @Produce json
// @Tags 鎽勫儚鏈哄杈瑰舰
// @Param cameraId query string true "cameraId"
diff --git a/controllers/cameraTask.go b/controllers/cameraTask.go
index 9d49181..77fa907 100644
--- a/controllers/cameraTask.go
+++ b/controllers/cameraTask.go
@@ -99,6 +99,7 @@
// @Security ApiKeyAuth
// @Summary 鎽勫儚鏈烘坊鍔犱竴涓换鍔�
// @Description 鎽勫儚鏈烘坊鍔犱竴涓换鍔�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags CameraTask
// @Param cameraId formData string true "鎽勫儚鏈篿d"
@@ -245,6 +246,7 @@
// @Security ApiKeyAuth
// @Summary 淇濆瓨瑙勫垯缁勬姤璀︾瓑绾�
// @Description 淇濆瓨瑙勫垯缁勬姤璀︾瓑绾�
+// @Accept json
// @Produce json
// @Tags CameraTask
// @Param GroupLevel body controllers.GroupAlarmLevelVo true "alarmLevel"
@@ -276,6 +278,7 @@
// @Security ApiKeyAuth
// @Summary 鏇存柊浠诲姟鐘舵��
// @Description 鏇存柊浠诲姟鐘舵��
+// @Accept json
// @Produce json
// @Tags CameraTask
// @Param CameraTaskStatus body controllers.CameraTaskStatusVo true "鍙傛暟缁撴瀯浣�"
diff --git a/controllers/cameraTaskArgs.go b/controllers/cameraTaskArgs.go
index f7549ea..0b3d25f 100644
--- a/controllers/cameraTaskArgs.go
+++ b/controllers/cameraTaskArgs.go
@@ -71,6 +71,7 @@
// @Security ApiKeyAuth
// @Summary 鏍规嵁鍒嗙粍id鍒囨崲甯冮槻鎴栨挙闃�
// @Description 鏍规嵁鍒嗙粍id鍒囨崲甯冮槻鎴栨挙闃�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags CameraTaskArgs
// @Param groupId formData string true "浠诲姟绠楁硶鍙傛暟鍒嗙粍id"
diff --git a/controllers/cameraTimerule.go b/controllers/cameraTimerule.go
index e8c1d4d..3c8fcce 100644
--- a/controllers/cameraTimerule.go
+++ b/controllers/cameraTimerule.go
@@ -66,7 +66,6 @@
// @Security ApiKeyAuth
// @Summary 鍒犻櫎鏃堕棿瑙勫垯
// @Description 鍒犻櫎鏃堕棿瑙勫垯
-// @Accept json
// @Produce json
// @Tags CameraTimerule
// @Param id query string true "id"
diff --git a/controllers/cluster.go b/controllers/cluster.go
index bfbda95..3536041 100644
--- a/controllers/cluster.go
+++ b/controllers/cluster.go
@@ -219,6 +219,7 @@
// @Security ApiKeyAuth
// @Summary 淇濆瓨闆嗙兢鍚嶇О
// @Description 淇濆瓨闆嗙兢鍚嶇О
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags cluster
// @Param clusterName formData string true "闆嗙兢鍚嶇О"
diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go
index 91c3550..06ab88b 100644
--- a/controllers/dbtableperson.go
+++ b/controllers/dbtableperson.go
@@ -246,7 +246,7 @@
// @Security ApiKeyAuth
// @Summary 鏇存柊搴曞簱浜鸿劯鐓х墖
// @Description 鏇存柊搴曞簱浜鸿劯鐓х墖
-// @Accept json
+// @Accept multipart/form-data
// @Produce json
// @Tags dbperson 搴曞簱浜哄憳
// @Param id formData string true "浜哄憳id"
diff --git a/controllers/dictionary.go b/controllers/dictionary.go
index a71ecce..6654f22 100644
--- a/controllers/dictionary.go
+++ b/controllers/dictionary.go
@@ -32,6 +32,7 @@
// @Security ApiKeyAuth
// @Summary 鏍规嵁鐖禝D鏌ユ壘瀛楀吀
// @Description 鏍规嵁鐖禝D鏌ユ壘瀛楀吀
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 瀛楀吀
// @Param parentId query string false "parentId"
diff --git a/controllers/esSearch.go b/controllers/esSearch.go
index bd08e48..1d4dcdb 100644
--- a/controllers/esSearch.go
+++ b/controllers/esSearch.go
@@ -177,7 +177,7 @@
analyServerFilterStr +
"{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," +
"\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," +
- "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\",\"linkId\"]" +
+ "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"isAlarm\",\"analyServerIp\",\"cameraId\",\"linkTag\",\"linkTagInfo\"]" +
"}"
//logger.Debug("findEsData.param:",prama)
//鏁版嵁瑙f瀽
@@ -190,50 +190,35 @@
for _, masterInfoValues := range data.([]interface{}) {
masterInfo := masterInfoValues.(map[string]interface{})
sources := make(map[string]interface{}, 0)
- sources["activeObject"] = masterInfo
- source := make([]map[string]interface{}, 0)
- source = append(source, masterInfo)
- linkId := ""
- if masterInfo["linkId"] != nil {
- linkId = masterInfo["linkId"].(string)
- }
- id := masterInfo["id"].(string)
- if linkId != "" {
- linkInfo := GetLinkInfo(linkId, id)
- for _, slaveInfoValues := range linkInfo {
- slaveInfo := slaveInfoValues
- source = append(source, slaveInfo)
- }
+ if masterInfo["linkTagInfo"] != nil {
+ linkTagInfo := masterInfo["linkTagInfo"].([]interface{})
+ delete(masterInfo, "linkTagInfo")
+ if len(linkTagInfo) >0 {
+ slaveList := make([]interface{}, 0)
+ slaveList = append(slaveList, masterInfo)
+ slaveList = append(slaveList, linkTagInfo...)
+ sources["list"] = slaveList
+ } else {
+ sources["list"] = []interface{}{
+ masterInfo,
+ }
+ }
+ } else {
+ if _,ok := masterInfo["linkTagInfo"];ok {
+ delete(masterInfo, "linkTagInfo")
+ }
+ sources["list"] = []interface{}{
+ masterInfo,
+ }
}
- sources["list"] = source
+
+ sources["activeObject"] = masterInfo
+
tmpDate["datalist"] = append(tmpDate["datalist"], sources)
}
tmpAllDate["datalist"] = tmpDate["datalist"]
return tmpAllDate
-}
-
-func GetLinkInfo(linkId string, id string) []map[string]interface{} {
- localConf, err2 := cache.GetServerInfo()
- if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
- logger.Debug("localConfig is wrong!!!")
- return nil
- }
- url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
- "/" + config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + "/_search?search_type=dfs_query_then_fetch"
- jsonDSL := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"linkId\":\"" + linkId + "\"}}],\"must_not\":[{\"term\":{\"id\":\"" + id + "\"}}]}},\"size\":100}"
-
- buf, err := esutil.EsReq("POST", url, []byte(jsonDSL))
- if err != nil {
- logger.Debug(err)
- }
-
- sources, err := esutil.Sourcelist(buf)
- if err != nil {
- logger.Debug(err)
- }
- return sources
-
}
//sdkTYype瀛楀吀"\"_source\":[\"BaseName\",\"Gender\",\"Race\",\"content\",\"idcard\",\"picAddress\",\"picDate\",\"sdkType\",\"Age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"cameraId\",\"ageDescription\",\"likePer\"]" +
diff --git a/controllers/eventPush.go b/controllers/eventPush.go
index a203f40..4580206 100644
--- a/controllers/eventPush.go
+++ b/controllers/eventPush.go
@@ -50,6 +50,8 @@
// @Security ApiKeyAuth
// @Summary 浜嬩欢鎺ㄩ�佷繚瀛�
// @Description 浜嬩欢鎺ㄩ�佷繚瀛�
+// @Accept json
+// @Produce json
// @Tags 浜嬩欢鎺ㄩ��
// @Param SaveArgs body controllers.EventPushVo true "鏃堕棿鎺ㄩ�佷繚瀛樺弬鏁�"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
@@ -74,6 +76,7 @@
// @Security ApiKeyAuth
// @Summary 鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛�
// @Description 鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 浜嬩欢鎺ㄩ��
// @Param topic query string true "涓�绾т富棰橀�夐」,渚嬪锛歝amera(鎽勫儚鏈�)"
@@ -100,6 +103,7 @@
// @Security ApiKeyAuth
// @Summary 鏌ュ叏閮�
// @Description 鏌ュ叏閮�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 浜嬩欢鎺ㄩ��
// @Param name query string false "浜嬩欢鍚嶇О"
@@ -120,6 +124,7 @@
// @Security ApiKeyAuth
// @Summary 浜嬩欢鎺ㄩ�佺紪杈�
// @Description 浜嬩欢鎺ㄩ�佺紪杈�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 浜嬩欢鎺ㄩ��
// @Param id query string true "id"
@@ -149,6 +154,7 @@
// @Security ApiKeyAuth
// @Summary 鏀瑰彉enable鐘舵��
// @Description 鏀瑰彉enable鐘舵��
+// @Accept json
// @Produce json
// @Tags 浜嬩欢鎺ㄩ��
// @Param statusBody body controllers.ChangeStatusVo true "鍙傛暟缁撴瀯"
diff --git a/controllers/fileController.go b/controllers/fileController.go
index 2594c86..dc54ec3 100644
--- a/controllers/fileController.go
+++ b/controllers/fileController.go
@@ -53,7 +53,7 @@
// @Security ApiKeyAuth
// @Summary 渚濇嵁鍥剧墖娣诲姞搴曞簱浜哄憳
// @Description 渚濇嵁鍥剧墖娣诲姞搴曞簱杩斿洖鏁版嵁浜哄憳
-// @Accept mpfd
+// @Accept multipart/form-data
// @Produce json
// @Tags dbperson 搴曞簱浜哄憳
// @Param file formData file true "搴曞簱浜哄憳鍥剧墖"
@@ -114,6 +114,7 @@
// @Security ApiKeyAuth
// @Summary 浜鸿劯鎻愬彇
// @Description 浜鸿劯鎻愬彇
+// @Accept multipart/form-data
// @Produce json
// @Tags 浠ュ浘鎼滃浘
// @Param file formData file true "浜哄憳鍥剧墖"
@@ -807,7 +808,7 @@
// @Security ApiKeyAuth
// @Summary 鎵归噺娣诲姞搴曞簱浜哄憳
// @Description 渚濇嵁鍥剧墖鎵归噺娣诲姞搴曞簱浜哄憳
-// @Accept mpfd
+// @Accept multipart/form-data
// @Produce json
// @Tags dbperson 搴曞簱浜哄憳
// @Param files formData file[] true "澶氫釜搴曞簱浜哄憳鍥剧墖"
@@ -898,7 +899,7 @@
// @Security ApiKeyAuth
// @Summary 涓婁紶鍥剧墖 骞跺垏鍥�
// @Description 涓婁紶鍥剧墖 骞跺垏鍥�
-// @Accept mpfd
+// @Accept multipart/form-data
// @Produce json
// @Tags dbperson 搴曞簱浜哄憳
// @Param file formData file true "搴曞簱浜哄憳鍥剧墖"
diff --git a/controllers/pollConfig.go b/controllers/pollConfig.go
index 445168d..9362d88 100644
--- a/controllers/pollConfig.go
+++ b/controllers/pollConfig.go
@@ -93,6 +93,7 @@
// @Security ApiKeyAuth
// @Summary 鍒囨崲杞寮�鍏�
// @Description 鍒囨崲杞寮�鍏�
+// @Accept json
// @Produce json
// @Tags 杞閰嶇疆
// @Param argBody body controllers.PollEnableVo true "寮�鍏冲弬鏁�"
diff --git a/controllers/sdk.go b/controllers/sdk.go
index cc76c7b..f44cd0d 100644
--- a/controllers/sdk.go
+++ b/controllers/sdk.go
@@ -43,6 +43,7 @@
// @Security ApiKeyAuth
// @Summary 绠楁硶淇濆瓨
// @Description 绠楁硶淇濆瓨
+// @Accept json
// @Produce json
// @Tags sdk
// @Param reqMap body controllers.SdkVo true "浜鸿劯妫�娴�"
diff --git a/controllers/sysMenu.go b/controllers/sysMenu.go
index 7a6dad7..d0fc177 100644
--- a/controllers/sysMenu.go
+++ b/controllers/sysMenu.go
@@ -16,7 +16,6 @@
// @Security ApiKeyAuth
// @Summary 褰撳墠鐢ㄦ埛鐨勭郴缁熻彍鍗�
// @Description 褰撳墠鐢ㄦ埛鐨勭郴缁熻彍鍗�
-// @Accept json
// @Produce json
// @Tags 绯荤粺鑿滃崟
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
@@ -38,7 +37,6 @@
// @Security ApiKeyAuth
// @Summary 鏌ユ壘褰撳墠鐢ㄦ埛鍙鐨勭郴缁熻彍鍗�
// @Description 鏌ユ壘褰撳墠鐢ㄦ埛鍙鐨勭郴缁熻彍鍗�
-// @Accept json
// @Produce json
// @Tags 绯荤粺鑿滃崟
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go
index 96705e3..9275310 100644
--- a/controllers/syssetcont.go
+++ b/controllers/syssetcont.go
@@ -101,7 +101,6 @@
// @Security ApiKeyAuth
// @Summary 瀛樺偍淇℃伅淇敼
// @Description 瀛樺偍淇℃伅淇敼
-// @Accept json
// @Produce json
// @Tags sysset
// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
@@ -283,7 +282,6 @@
// @Security ApiKeyAuth
// @Summary 娴嬭瘯鍚屾鏃堕棿
// @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢�
-// @Accept json
// @Produce json
// @Tags sysset
// @Param server query string true "鏃堕棿鏈嶅姟鍣╥p"
@@ -404,6 +402,7 @@
// @Summary 璁剧疆瀹氭椂閲嶅惎
// @Description 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒�
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags sysset
// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
diff --git a/controllers/task.go b/controllers/task.go
index 57f9414..4f2dd14 100644
--- a/controllers/task.go
+++ b/controllers/task.go
@@ -167,6 +167,7 @@
// @Security ApiKeyAuth
// @Summary 缁欎换鍔℃坊鍔犵畻娉�
// @Description 浠诲姟娣诲姞绠楁硶
+// @Accept json
// @Produce json
// @Tags task
// @Param taskSdkAdd body controllers.TaskSdkAdd true "浠诲姟id"
@@ -219,6 +220,7 @@
// @Security ApiKeyAuth
// @Summary 鏇存柊浠诲姟鍚嶇О
// @Description 鏇存柊浠诲姟鍚嶇О
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags task
// @Param taskId formData string true "taskId"
@@ -250,6 +252,7 @@
// @Security ApiKeyAuth
// @Summary 鏇存柊浠诲姟鐘舵��
// @Description 锛堢畻娉曚笉鍙�,鍙洿鏂颁换鍔$姸鎬侊級
+// @Accept json
// @Produce json
// @Tags task
// @Param taskStatus body controllers.TaskStatusVo true "鍙傛暟"
@@ -341,6 +344,7 @@
// @Security ApiKeyAuth
// @Summary 鍒犻櫎绠楁硶瑙勫垯
// @Description 鍒犻櫎绠楁硶瑙勫垯
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 绠楁硶瑙勫垯
// @Param taskId formData string true "taskId"
diff --git a/controllers/user.go b/controllers/user.go
index 6f5fc2f..3dd1090 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -21,7 +21,7 @@
// @Summary 鐢ㄦ埛鐧诲綍
// @Description 鐢ㄦ埛鐧诲綍
-// @Accept json
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 鐢ㄦ埛
// @Param username formData string true "鐢ㄦ埛鍚�"
@@ -61,6 +61,35 @@
})
} else {
c.JSON(500,"鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒")
+ }
+}
+
+// @Security ApiKeyAuth
+// @Summary 淇敼褰撳墠鐧诲綍鐢ㄦ埛鐨勫瘑鐮�
+// @Description 淇敼褰撳墠鐧诲綍鐢ㄦ埛鐨勫瘑鐮�
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param oldPwd formData string true "鏃у瘑鐮�"
+// @Param newPwd formData string true "鏂板瘑鐮�"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/users/updatePwd [post]
+func (uc UserController) UpdatePwd(c *gin.Context) {
+ oldPwd := c.PostForm("oldPwd")
+ newPwd := c.PostForm("newPwd")
+ if oldPwd == "" || newPwd == "" {
+ util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ return
+ }
+ authDriver := auth.GenerateAuthDriver()
+ userM := (*authDriver).User(c)
+ userId := userM["id"].(string)
+ var userApi dbapi.UserApi
+ if b,_ :=userApi.UpdatePwd(userId, oldPwd, newPwd);b {
+ util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛")
+ } else {
+ util.ResponseFormat(c,code.AccountPassUnmatch,"瀵嗙爜鏈夎")
}
}
@@ -124,7 +153,7 @@
// @Security ApiKeyAuth
// @Summary 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
// @Description 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
-// @Accept json
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 鐢ㄦ埛
// @Param userId formData string true "鐢ㄦ埛id"
@@ -155,7 +184,7 @@
// @Param userVo body controllers.UserEditVo true "鐢ㄦ埛鍙婃潈闄愪俊鎭�"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/user/saveAuth [post]
+// @Router /data/api-v/users/saveAuth [post]
func (uc UserController) SaveAuth(c *gin.Context) {
var userEditVo UserEditVo
err := c.BindJSON(&userEditVo)
diff --git a/extend/code/code.go b/extend/code/code.go
index 44ec884..da54881 100644
--- a/extend/code/code.go
+++ b/extend/code/code.go
@@ -19,7 +19,7 @@
// RequestParamError 璇锋眰鍙傛暟閿欒
RequestParamError = &Code{http.StatusBadRequest, false, "璇锋眰鍙傛暟鏈夎"}
// AccountPassUnmatch 璇ヨ处鍙峰師瀵嗙爜涓嶅尮閰�
- AccountPassUnmatch = &Code{http.StatusBadRequest, false, "璇ヨ处鍙峰師瀵嗙爜涓嶅尮閰�"}
+ AccountPassUnmatch = &Code{http.StatusOK, false, "璇ヨ处鍙峰師瀵嗙爜涓嶅尮閰�"}
// SignupPassUnmatch 娉ㄥ唽涓ゆ杈撳叆瀵嗙爜涓嶅尮閰�
SignupPassUnmatch = &Code{http.StatusBadRequest, false, "娉ㄥ唽涓ゆ杈撳叆瀵嗙爜涓嶅尮閰�"}
// AccountNameExist 璐﹀彿鏄电О閲嶅锛岃鏇存崲涓哄叾浠栨樀绉�
diff --git a/go.mod b/go.mod
index 3e53878..dc01e2f 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@
go 1.12
require (
- basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 // indirect
+ basic.com/dbapi.git v0.0.0-20191114063413-a251b5d8b758 // indirect
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb // indirect
basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b // indirect
basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 // indirect
diff --git a/go.sum b/go.sum
index 551026b..a124cd1 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 h1:ZSRZQ031oGUT8zT9shvoX9hvFIVbLnNCpJ48SLZKVec=
-basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
+basic.com/dbapi.git v0.0.0-20191114063413-a251b5d8b758 h1:pVQV59Q26COk55JJGum+KSuOvvl2v5fF8ymkcdu0xp8=
+basic.com/dbapi.git v0.0.0-20191114063413-a251b5d8b758/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb h1:fM6DojeInFSCFO+wkba1jtyPiSDqw0jYKi4Tk+e+ka4=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb/go.mod h1:FTryK8BsVLfUplx8a3+l8hJWub6VbAWZCUH7sPRZaso=
basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b h1:Qh7x2PY3HA9B404Llq+olY5/YlGYrM58bpOHa2CGcro=
diff --git a/middlewares/auth/auth.go b/middlewares/auth/auth.go
index 6d80437..d897b00 100644
--- a/middlewares/auth/auth.go
+++ b/middlewares/auth/auth.go
@@ -56,7 +56,7 @@
return func(c *gin.Context) {
urlPath := c.Request.URL.Path
- if strings.Contains(urlPath,"/data/api-v") && !strings.Contains(urlPath,"login"){
+ if strings.Contains(urlPath,"/data/api-") && !strings.Contains(urlPath,"login"){
jwtDriver :=NewJwtAuthDriver()
if !jwtDriver.Check(c) {
util.ResponseFormat(c,code.TokenNotFound,"灏氭湭鐧诲綍锛岃鐧诲綍")
diff --git a/router/router.go b/router/router.go
index 71be55e..dced050 100644
--- a/router/router.go
+++ b/router/router.go
@@ -66,6 +66,7 @@
userApi.GET("/findAllUser", userController.FindAllUser)
userApi.POST("/findById", userController.FindById)
userApi.POST("/saveAuth", userController.SaveAuth)
+ userApi.POST("/updatePwd", userController.UpdatePwd)
}
urlPrefix := "/data/api-v" // wp 娣诲姞 璺緞 鍓嶇紑
--
Gitblit v1.8.0