updated

This commit is contained in:
landaiqing
2024-11-14 01:58:20 +08:00
parent c95d5fc041
commit 3b8e3df27a
83 changed files with 172212 additions and 343 deletions

View File

@@ -0,0 +1,24 @@
package client
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/client"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
)
func GenerateClientIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
clientIP := utils.GetClientIP(r)
l := client.NewGenerateClientIdLogic(r.Context(), svcCtx)
resp, err := l.GenerateClientId(clientIP)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"time"
client "schisandra-album-cloud-microservices/app/core/api/internal/handler/client"
user "schisandra-album-cloud-microservices/app/core/api/internal/handler/user"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
@@ -14,6 +15,22 @@ import (
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware},
[]rest.Route{
{
Method: http.MethodGet,
Path: "/generate_client_id",
Handler: client.GenerateClientIdHandler(serverCtx),
},
}...,
),
rest.WithPrefix("/api/client"),
rest.WithTimeout(10000*time.Millisecond),
rest.WithMaxBytes(1048576),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware},

View File

@@ -19,8 +19,8 @@ func AccountLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := user.NewAccountLoginLogic(r.Context(), svcCtx)
resp, err := l.AccountLogin(&req)
if err != nil {
resp, err := l.AccountLogin(w, r, &req)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)

View File

@@ -20,7 +20,7 @@ func PhoneLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewPhoneLoginLogic(r.Context(), svcCtx)
resp, err := l.PhoneLogin(&req)
if err != nil {
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)

View File

@@ -20,7 +20,7 @@ func ResetPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewResetPasswordLogic(r.Context(), svcCtx)
resp, err := l.ResetPassword(&req)
if err != nil {
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)