Files
zetaloop 62442a324a fix: 密码重置链路断裂与店铺模板类型不兼容
删除 users-api 的 forgot-password 空壳路由,email-api 的
forgotPasswordLogic 复用 sendVerificationCode 实现。shop 的
UpdateTemplateReq.Sections 从 interface{} 改为 string 以兼容
go-zero 反序列化。ResetPasswordReq.Phone 加 optional tag。
2026-04-05 17:59:56 +08:00

160 lines
3.7 KiB
Go

// Code generated by goctl. DO NOT EDIT.
// goctl 1.10.1
package handler
import (
"net/http"
auth "juwan-backend/app/users/api/internal/handler/auth"
user "juwan-backend/app/users/api/internal/handler/user"
verification_admin "juwan-backend/app/users/api/internal/handler/verification_admin"
verification_user "juwan-backend/app/users/api/internal/handler/verification_user"
"juwan-backend/app/users/api/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
// 用户登录
Method: http.MethodPost,
Path: "/login",
Handler: auth.LoginHandler(serverCtx),
},
{
// 用户注册
Method: http.MethodPost,
Path: "/register",
Handler: auth.RegisterHandler(serverCtx),
},
{
// 重置密码
Method: http.MethodPost,
Path: "/reset-password",
Handler: auth.ResetPasswordHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/auth"),
)
server.AddRoutes(
[]rest.Route{
{
// 退出登录
Method: http.MethodPost,
Path: "/logout",
Handler: auth.LogoutHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/auth"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.Logger},
[]rest.Route{
{
// 关注用户
Method: http.MethodPost,
Path: "/:id/follow",
Handler: user.FollowUserHandler(serverCtx),
},
{
// 取消关注用户
Method: http.MethodDelete,
Path: "/:id/follow",
Handler: user.UnfollowUserHandler(serverCtx),
},
{
// 获取当前登录用户信息
Method: http.MethodGet,
Path: "/me",
Handler: user.GetMeHandler(serverCtx),
},
{
// 更新个人资料
Method: http.MethodPut,
Path: "/me",
Handler: user.UpdateMeHandler(serverCtx),
},
{
// 更新通知偏好
Method: http.MethodPut,
Path: "/me/preferences/notifications",
Handler: user.UpdateNotificationSettingsHandler(serverCtx),
},
{
// 更新主题偏好
Method: http.MethodPut,
Path: "/me/preferences/theme",
Handler: user.UpdateThemeSettingsHandler(serverCtx),
},
{
// 切换当前激活角色
Method: http.MethodPost,
Path: "/me/switch-role",
Handler: user.SwitchRoleHandler(serverCtx),
},
}...,
),
rest.WithPrefix("/api/v1/users"),
)
server.AddRoutes(
[]rest.Route{
{
// 获取指定用户信息
Method: http.MethodGet,
Path: "/:id",
Handler: user.GetUserInfoHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/users"),
)
server.AddRoutes(
[]rest.Route{
{
// 管理员获取认证申请列表 (分页)
Method: http.MethodGet,
Path: "/verifications",
Handler: verification_admin.GetVerificationsHandler(serverCtx),
},
{
// 管理员通过申请
Method: http.MethodPost,
Path: "/verifications/:id/approve",
Handler: verification_admin.ApproveVerificationHandler(serverCtx),
},
{
// 管理员驳回申请
Method: http.MethodPost,
Path: "/verifications/:id/reject",
Handler: verification_admin.RejectVerificationHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/admin"),
)
server.AddRoutes(
[]rest.Route{
{
// 提交或修改角色认证申请 (支持幂等更新)
Method: http.MethodPost,
Path: "/me/verification",
Handler: verification_user.ApplyVerificationHandler(serverCtx),
},
{
// 获取我的所有认证状态
Method: http.MethodGet,
Path: "/me/verification",
Handler: verification_user.GetMyVerificationsHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/users"),
)
}