From e0f0035a7d02098f14e9d800a16d42d4c9380e9c Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 20 十二月 2019 16:22:25 +0800
Subject: [PATCH] test
---
controllers/user.go | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/controllers/user.go b/controllers/user.go
index aae3cbd..3dd1090 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -2,7 +2,6 @@
import (
"basic.com/dbapi.git"
- "basic.com/valib/logger.git"
"github.com/gin-gonic/gin"
"net/http"
"time"
@@ -22,7 +21,7 @@
// @Summary 鐢ㄦ埛鐧诲綍
// @Description 鐢ㄦ埛鐧诲綍
-// @Accept json
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 鐢ㄦ埛
// @Param username formData string true "鐢ㄦ埛鍚�"
@@ -47,6 +46,11 @@
tokenM["username"] = loginedM["username"]
tokenM["permissions"] = loginedM["permissions"]
tokenStr := (*authDriver).Login(c.Request, c.Writer, tokenM)
+
+
+ userId := loginedM["id"].(string)
+ auth.RemoveOutUser(userId)
+
c.JSON(200,map[string]interface{}{
"userInfo":loginedM,
"access_token":tokenStr,
@@ -60,6 +64,36 @@
}
}
+// @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,"瀵嗙爜鏈夎")
+ }
+}
+
+// @Security ApiKeyAuth
// @Summary 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
// @Description 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
// @Accept json
@@ -87,6 +121,7 @@
c.JSON(http.StatusOK,"閫�鍑烘垚鍔�")
}
+// @Security ApiKeyAuth
// @Summary 鏌ユ壘鎵�鏈夌敤鎴�
// @Description 鏌ユ壘鎵�鏈夌敤鎴�
// @Accept json
@@ -97,10 +132,8 @@
// @Router /data/api-u/users/findAllUser [get]
func (uc UserController) FindAllUser(c *gin.Context) {
authDriver := auth.GenerateAuthDriver()
- user := (*authDriver).User(c)
- logger.Debug("cur userInfo:",user)
- loginM := user.(map[string]interface{})
- userId := loginM["id"].(string)
+ userM := (*authDriver).User(c)
+ userId := userM["id"].(string)
var api dbapi.UserApi
b,d := api.FindAllUser(userId)
if b {
@@ -117,9 +150,10 @@
MenuIds []string `json:"menuIds"`
}
+// @Security ApiKeyAuth
// @Summary 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
// @Description 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
-// @Accept json
+// @Accept x-www-form-urlencoded
// @Produce json
// @Tags 鐢ㄦ埛
// @Param userId formData string true "鐢ㄦ埛id"
@@ -141,6 +175,7 @@
}
}
+// @Security ApiKeyAuth
// @Summary 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
// @Description 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
// @Accept json
@@ -149,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)
@@ -161,6 +196,7 @@
var api dbapi.UserApi
b, d := api.SaveAuth(paramBody)
if b {
+ auth.SetOutUser(userEditVo.Id)
util.ResponseFormat(c,code.UpdateSuccess,d)
} else {
util.ResponseFormat(c,code.UpdateFail,"淇濆瓨澶辫触")
--
Gitblit v1.8.0