Skip to content

Commit

Permalink
refactor(library): 移除图书馆账号登陆, 修改为统一账号登陆
Browse files Browse the repository at this point in the history
  • Loading branch information
MangoGovo committed Dec 16, 2024
1 parent 58fcc5b commit e10d9e6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
20 changes: 0 additions & 20 deletions app/controllers/userController/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions app/services/funnelServices/libraryService.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 0 additions & 11 deletions app/services/userServices/setUser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion config/router/userRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e10d9e6

Please sign in to comment.