From 5f00d720ea52ababeb10954da4d33ab6c46e93b7 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 14 七月 2023 17:47:13 +0800
Subject: [PATCH] add

---
 api/v1/user.go |   70 +++++++++++++++++++----------------
 1 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/api/v1/user.go b/api/v1/user.go
index 99534cf..baf9e7e 100644
--- a/api/v1/user.go
+++ b/api/v1/user.go
@@ -6,9 +6,7 @@
 	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
-	_ "aps_crm/model/response"
 	"aps_crm/pkg/contextx"
-	"aps_crm/pkg/convertx"
 	"aps_crm/pkg/ecode"
 	"aps_crm/pkg/encrypt"
 	"aps_crm/pkg/logx"
@@ -18,7 +16,6 @@
 	"github.com/gin-gonic/gin"
 	"github.com/go-redis/redis/v8"
 	"github.com/mojocn/base64Captcha"
-	"time"
 )
 
 // 褰撳紑鍚鏈嶅姟鍣ㄩ儴缃叉椂锛屾浛鎹笅闈㈢殑閰嶇疆锛屼娇鐢╮edis鍏变韩瀛樺偍楠岃瘉鐮�
@@ -26,6 +23,7 @@
 var store = base64Captcha.DefaultMemStore
 
 // Login
+//
 //	@Tags		Base
 //	@Summary	鐢ㄦ埛鐧诲綍
 //	@Produce	application/json
@@ -41,41 +39,41 @@
 
 	// 鍒ゆ柇楠岃瘉鐮佹槸鍚﹀紑鍚�
 	key := c.ClientIP()
-	openCaptcha := conf.Conf.Captcha.OpenCaptcha               // 鏄惁寮�鍚槻鐖嗘鏁�
-	openCaptchaTimeOut := conf.Conf.Captcha.OpenCaptchaTimeOut // 缂撳瓨瓒呮椂鏃堕棿
-	v, ok := constvar.BlackCache.Get(key)
-	if !ok {
-		constvar.BlackCache.Set(key, 1, time.Second*time.Duration(openCaptchaTimeOut))
-	}
+	//openCaptcha := conf.Conf.Captcha.OpenCaptcha               // 鏄惁寮�鍚槻鏆存鏁�
+	//openCaptchaTimeOut := conf.Conf.Captcha.OpenCaptchaTimeOut // 缂撳瓨瓒呮椂鏃堕棿
+	//v, ok := constvar.BlackCache.Get(key)
+	//if !ok {
+	//	constvar.BlackCache.Set(key, 1, time.Second*time.Duration(openCaptchaTimeOut))
+	//}
 
-	var oc bool = openCaptcha == 0 || convertx.InterfaceToInt(v) > openCaptcha // 0 琛ㄧず姣忔鐧诲綍閮介渶瑕侀獙璇佺爜 鎴栬�呭綋鍓嶆鏁板凡瓒呰繃闃茬垎娆℃暟
+	//var oc = openCaptcha == 0 || convertx.InterfaceToInt(v) > openCaptcha // 0 琛ㄧず姣忔鐧诲綍閮介渶瑕侀獙璇佺爜 鎴栬�呭綋鍓嶆鏁板凡瓒呰繃闃叉毚娆℃暟
 
-	if !oc || store.Verify(params.CaptchaId, params.Captcha, true) {
-		u := &model.User{Username: params.Username, Password: params.Password}
-		user, errCode := userService.Login(u)
-		if errCode != ecode.OK {
-			logx.Errorf("鐧婚檰澶辫触! 鐢ㄦ埛鍚嶄笉瀛樺湪鎴栬�呭瘑鐮侀敊璇�! errCode:%v", errCode)
-			// 楠岃瘉鐮佹鏁�+1
-			_ = constvar.BlackCache.Increment(key, 1)
-			ctx.Fail(errCode)
-			return
-		}
-		if !user.Enable {
-			logx.Errorf("鐧婚檰澶辫触! 鐢ㄦ埛琚姝㈢櫥褰�!")
-			// 楠岃瘉鐮佹鏁�+1
-			_ = constvar.BlackCache.Increment(key, 1)
-			ctx.Fail(ecode.UserForbidden)
-			return
-		}
-		// 璧嬪�艰彍鍗旾D鍒楄〃
-		//user.MenuIds, _ = menuService.GetUserMenuIds(user.ID, user.UserType)
-		slf.TokenNext(ctx, *user)
+	//if !oc || store.Verify(params.CaptchaId, params.Captcha, true) {
+	u := &model.User{Username: params.Username, Password: params.Password}
+	user, errCode := userService.Login(u)
+	if errCode != ecode.OK {
+		logx.Errorf("鐧婚檰澶辫触! 鐢ㄦ埛鍚嶄笉瀛樺湪鎴栬�呭瘑鐮侀敊璇�! errCode:%v", errCode)
+		// 楠岃瘉鐮佹鏁�+1
+		_ = constvar.BlackCache.Increment(key, 1)
+		ctx.Fail(errCode)
 		return
 	}
+	if !user.Enable {
+		logx.Errorf("鐧婚檰澶辫触! 鐢ㄦ埛琚姝㈢櫥褰�!")
+		// 楠岃瘉鐮佹鏁�+1
+		_ = constvar.BlackCache.Increment(key, 1)
+		ctx.Fail(ecode.UserForbidden)
+		return
+	}
+	// 璧嬪�艰彍鍗旾D鍒楄〃
+	//user.MenuIds, _ = menuService.GetUserMenuIds(user.ID, user.UserType)
+	slf.TokenNext(ctx, *user)
+	return
+	//}
 
 	// 楠岃瘉鐮佹鏁�+1
-	_ = constvar.BlackCache.Increment(key, 1)
-	ctx.Fail(ecode.CaptchaErr)
+	//_ = constvar.BlackCache.Increment(key, 1)
+	//ctx.Fail(ecode.CaptchaErr)
 }
 
 // TokenNext 鐧诲綍浠ュ悗绛惧彂jwt
@@ -137,6 +135,7 @@
 }
 
 // Register
+//
 //	@Tags		User
 //	@Summary	娉ㄥ唽璐﹀彿
 //	@Produce	application/json
@@ -204,6 +203,7 @@
 }
 
 // ChangePassword
+//
 //	@Tags		User
 //	@Summary	鐢ㄦ埛淇敼瀵嗙爜
 //	@Produce	application/json
@@ -227,6 +227,7 @@
 }
 
 // GetUserList
+//
 //	@Tags		User
 //	@Summary	鍒嗛〉鑾峰彇鐢ㄦ埛鍒楄〃(涓嶄紶鍒嗛〉鍙傛暟锛岃幏鍙栧叏閮�)
 //	@Produce	application/json
@@ -253,6 +254,7 @@
 }
 
 // DeleteUser
+//
 //	@Tags		User
 //	@Summary	鍒犻櫎鐢ㄦ埛
 //	@Produce	application/json
@@ -287,6 +289,7 @@
 }
 
 // SetUserInfo
+//
 //	@Tags		User
 //	@Summary	璁剧疆鐢ㄦ埛淇℃伅
 //	@Produce	application/json
@@ -317,6 +320,7 @@
 }
 
 // SetSelfInfo
+//
 //	@Tags		User
 //	@Summary	璁剧疆鐢ㄦ埛淇℃伅
 //	@Produce	application/json
@@ -348,6 +352,7 @@
 }
 
 // GetUserInfo
+//
 //	@Tags		User
 //	@Summary	鑾峰彇鑷韩淇℃伅
 //	@Produce	application/json
@@ -372,6 +377,7 @@
 }
 
 // ResetPassword
+//
 //	@Tags		User
 //	@Summary	閲嶇疆鐢ㄦ埛瀵嗙爜
 //	@Produce	application/json

--
Gitblit v1.8.0