From 100b0f872304e0e3a97a91982a04c5146618433e Mon Sep 17 00:00:00 2001 From: MangoGovo <1749100231@qq.com> Date: Tue, 17 Dec 2024 22:03:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(library):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=9B=BE=E4=B9=A6=E9=A6=86=E8=B4=A6=E5=8F=B7=E7=99=BB=E9=99=86?= =?UTF-8?q?,=20=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=BB=9F=E4=B8=80=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/userController/auth.go | 12 +++++------ app/controllers/userController/bind.go | 20 ------------------- app/controllers/userController/info.go | 1 - app/services/funnelServices/libraryService.go | 8 ++++---- app/services/userServices/setUser.go | 11 ---------- config/router/userRouter.go | 1 - 6 files changed, 10 insertions(+), 43 deletions(-) diff --git a/app/controllers/userController/auth.go b/app/controllers/userController/auth.go index ac077f6..e66ade8 100644 --- a/app/controllers/userController/auth.go +++ b/app/controllers/userController/auth.go @@ -59,8 +59,8 @@ func AuthByPassword(c *gin.Context) { "username": user.Username, "studentID": user.StudentID, "bind": gin.H{ - "zf": user.ZFPassword != "", - "lib": user.LibPassword != "", + "zf": user.ZFPassword != "", + //"lib": user.LibPassword != "", "yxy": user.YxyUid != "", "oauth": user.OauthPassword != "", }, @@ -83,8 +83,8 @@ func AuthBySession(c *gin.Context) { "username": user.Username, "studentID": user.StudentID, "bind": gin.H{ - "zf": user.ZFPassword != "", - "lib": user.LibPassword != "", + "zf": user.ZFPassword != "", + //"lib": user.LibPassword != "" //已废弃 "yxy": user.YxyUid != "", }, "userType": user.Type, @@ -125,8 +125,8 @@ func WeChatLogin(c *gin.Context) { "username": user.Username, "studentID": user.StudentID, "bind": gin.H{ - "zf": user.ZFPassword != "", - "lib": user.LibPassword != "", + "zf": user.ZFPassword != "", + //"lib": user.LibPassword != "", "yxy": user.YxyUid != "", "oauth": user.OauthPassword != "", }, diff --git a/app/controllers/userController/bind.go b/app/controllers/userController/bind.go index 09ea111..910a509 100644 --- a/app/controllers/userController/bind.go +++ b/app/controllers/userController/bind.go @@ -44,26 +44,6 @@ func BindZFPassword(c *gin.Context) { utils.JsonSuccessResponse(c, nil) } -func BindLibraryPassword(c *gin.Context) { - var postForm bindForm - err := c.ShouldBindJSON(&postForm) - if err != nil { - _ = c.AbortWithError(200, apiException.ParamError) - return - } - user, err := sessionServices.GetUserSession(c) - if err != nil { - _ = c.AbortWithError(200, apiException.NotLogin) - return - } - err = userServices.SetLibraryPassword(user, postForm.PassWord) - if err != nil { - _ = c.AbortWithError(200, err) - return - } - utils.JsonSuccessResponse(c, nil) -} - func BindOauthPassword(c *gin.Context) { var postForm bindForm err := c.ShouldBindJSON(&postForm) diff --git a/app/controllers/userController/info.go b/app/controllers/userController/info.go index 5f26d39..f038124 100644 --- a/app/controllers/userController/info.go +++ b/app/controllers/userController/info.go @@ -21,7 +21,6 @@ func GetUserInfo(c *gin.Context) { "bind": gin.H{ "zf": user.ZFPassword != "", //"lib": user.LibPassword != "", - "lib": false, "yxy": user.YxyUid != "", "oauth": user.OauthPassword != "", }, diff --git a/app/services/funnelServices/libraryService.go b/app/services/funnelServices/libraryService.go index d625e76..4fc6203 100644 --- a/app/services/funnelServices/libraryService.go +++ b/app/services/funnelServices/libraryService.go @@ -8,22 +8,22 @@ import ( ) func GetCurrentBorrow(u *models.User) (interface{}, error) { - if u.LibPassword == "" { + if u.OauthPassword == "" { return nil, apiException.NoThatPasswordOrWrong } form := url.Values{} form.Add("username", u.StudentID) - form.Add("password", u.LibPassword) + form.Add("password", u.OauthPassword) return FetchHandleOfPost(form, funnelApi.LibraryCurrent) } func GetHistoryBorrow(u *models.User) (interface{}, error) { - if u.LibPassword == "" { + if u.OauthPassword == "" { return nil, apiException.NoThatPasswordOrWrong } form := url.Values{} form.Add("username", u.StudentID) - form.Add("password", u.LibPassword) + form.Add("password", u.OauthPassword) return FetchHandleOfPost(form, funnelApi.LibraryHistory) } diff --git a/app/services/userServices/setUser.go b/app/services/userServices/setUser.go index 4950538..d55ed28 100644 --- a/app/services/userServices/setUser.go +++ b/app/services/userServices/setUser.go @@ -29,17 +29,6 @@ func SetOauthPassword(user *models.User, password string) error { return nil } -func SetLibraryPassword(user *models.User, password string) error { - user.LibPassword = password - _, err := funnelServices.GetCurrentBorrow(user) - if err != nil { - return err - } - EncryptUserKeyInfo(user) - database.DB.Save(user) - return nil -} - func SetPhoneNum(user *models.User, phoneNum string) { user.PhoneNum = phoneNum EncryptUserKeyInfo(user) diff --git a/config/router/userRouter.go b/config/router/userRouter.go index bfddc48..8ed3a14 100644 --- a/config/router/userRouter.go +++ b/config/router/userRouter.go @@ -25,7 +25,6 @@ func userRouterInit(r *gin.RouterGroup) { bind := user.Group("/bind", midwares.CheckLogin) { bind.POST("/zf", userController.BindZFPassword) - bind.POST("/library", userController.BindLibraryPassword) bind.POST("/yxy/get/captcha", userController.GetCaptcha) // 待废弃 bind.POST("/yxy/send/captcha", userController.SendVerificationCode) // 兼容用,待删除 bind.POST("/yxy/send/code", userController.SendVerificationCode)