From cb4766eb80edbb1f264b46a0da577d57f8d12a8f Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期五, 05 六月 2020 18:46:44 +0800
Subject: [PATCH] add log
---
controllers/user.go | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
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)
--
Gitblit v1.8.0