🐛 fix session bug

This commit is contained in:
landaiqing
2024-11-17 20:02:59 +08:00
parent 34c4690f80
commit 78a162a19a
72 changed files with 1304 additions and 453 deletions

View File

@@ -3,6 +3,7 @@ package user
import (
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
@@ -20,8 +21,9 @@ func AccountLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewAccountLoginLogic(r.Context(), svcCtx)
resp, err := l.AccountLogin(w, r, &req)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -1,8 +1,10 @@
package user
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
@@ -14,7 +16,8 @@ func GetUserDeviceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewGetUserDeviceLogic(r.Context(), svcCtx)
err := l.GetUserDevice(r)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
logx.Error(err)
httpx.ErrorCtx(r.Context(), w, errors.New("server error"))
} else {
httpx.Ok(w)
}

View File

@@ -3,6 +3,7 @@ package user
import (
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
@@ -21,7 +22,8 @@ func PhoneLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewPhoneLoginLogic(r.Context(), svcCtx)
resp, err := l.PhoneLogin(r, w, &req)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -3,6 +3,7 @@ package user
import (
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
@@ -14,7 +15,8 @@ func RefreshTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewRefreshTokenLogic(r.Context(), svcCtx)
resp, err := l.RefreshToken(r)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}

View File

@@ -3,6 +3,7 @@ package user
import (
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
@@ -20,8 +21,9 @@ func ResetPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewResetPasswordLogic(r.Context(), svcCtx)
resp, err := l.ResetPassword(&req)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}