// routes/api_web.go // Web端API路由 package routes import ( "simple-memo/api/app" "simple-memo/middleware" "github.com/gin-gonic/gin" ) // registerAPIWebRoutes 注册Web端API路由 func registerAPIWebRoutes(r *gin.Engine) { api := r.Group("/api") // 网页端接口(不需要加密,直接接收JSON) web := api.Group("/web") web.Use(middleware.Limiter()) // 限流(不加加密中间件) { // 网页端登录相关(无需登录) web.POST("/login", app.NewUserHandler().EmailLogin) // 邮箱登录 web.POST("/register", app.NewUserHandler().EmailRegister) // 注册 web.POST("/send-code", app.NewUserHandler().SendEmailCode) // 发送邮箱验证码 web.POST("/reset-password", app.NewUserHandler().ResetPassword) // 重置密码 // 验证码接口(无需登录) web.POST("/captcha/digit", app.NewCaptchaHandler().GenerateDigitCaptcha) // 生成数字验证码 web.POST("/captcha/digit/verify", app.NewCaptchaHandler().VerifyDigitCaptcha) // 验证数字验证码 // 成长规则(无需登录,公开页面使用) web.GET("/growth/rules", app.NewGrowthHandler().GetGrowthRules) // 常量接口 web.POST("/constants/all", app.NewConstantsHandler().GetAllConstants) web.POST("/constants/bill-categories", app.NewConstantsHandler().GetBillCategories) web.POST("/constants/todo-categories", app.NewConstantsHandler().GetTodoCategories) web.POST("/constants/mood-list", app.NewConstantsHandler().GetMoodList) web.POST("/constants/pay-channels", app.NewConstantsHandler().GetPayChannels) // 需要登录鉴权的网页端接口 webAuth := web.Group("/") webAuth.Use(middleware.JWTAuth()) { // 用户信息(GET获取,POST修改) webAuth.GET("/user/info", app.NewUserHandler().UserInfo) webAuth.POST("/user/edit", app.NewUserHandler().EditUser) webAuth.POST("/user/logout", app.NewUserHandler().Logout) webAuth.POST("/user/change-password", app.NewUserHandler().ChangePassword) // 修改密码(已登录) webAuth.POST("/user/bind-wechat", app.NewUserHandler().BindWechat) // 绑定微信(已登录) // 日历聚合数据 webAuth.POST("/calendar/data", app.NewCalendarHandler().GetCalendarData) // 待办 webAuth.POST("/todo/add", app.NewTodoHandler().AddTodo) webAuth.POST("/todo/list", app.NewTodoHandler().TodoList) webAuth.POST("/todo/delete", app.NewTodoHandler().DeleteTodo) webAuth.POST("/todo/done", app.NewTodoHandler().DoneTodo) webAuth.POST("/todo/edit", app.NewTodoHandler().EditTodo) // 账单 webAuth.POST("/bill/add", app.NewBillHandler().AddBill) webAuth.POST("/bill/list", app.NewBillHandler().BillList) webAuth.POST("/bill/edit", app.NewBillHandler().EditBill) webAuth.POST("/bill/delete", app.NewBillHandler().DeleteBill) // 心情 webAuth.POST("/mood/get", app.NewMoodHandler().GetMoodByDate) webAuth.POST("/mood/save", app.NewMoodHandler().SaveMood) webAuth.POST("/mood/list", app.NewMoodHandler().GetMoodList) webAuth.POST("/mood/delete", app.NewMoodHandler().DeleteMood) // 复盘 webAuth.POST("/review/save", app.NewReviewHandler().SaveReview) webAuth.POST("/review/get", app.NewReviewHandler().GetReview) webAuth.POST("/review/list", app.NewReviewHandler().ReviewList) webAuth.POST("/review/delete", app.NewReviewHandler().DeleteReview) // 成长(GET获取) webAuth.GET("/growth/info", app.NewGrowthHandler().GetGrowthInfo) webAuth.GET("/growth/achievements", app.NewGrowthHandler().GetAchievements) } } }