init: init refactor
This commit is contained in:
@@ -0,0 +1,285 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
ai "sundynix-micro-go/app/plant/api/internal/handler/ai"
|
||||
callback "sundynix-micro-go/app/plant/api/internal/handler/callback"
|
||||
config "sundynix-micro-go/app/plant/api/internal/handler/config"
|
||||
exchange "sundynix-micro-go/app/plant/api/internal/handler/exchange"
|
||||
myPlant "sundynix-micro-go/app/plant/api/internal/handler/myPlant"
|
||||
ocr "sundynix-micro-go/app/plant/api/internal/handler/ocr"
|
||||
post "sundynix-micro-go/app/plant/api/internal/handler/post"
|
||||
topic "sundynix-micro-go/app/plant/api/internal/handler/topic"
|
||||
userProfile "sundynix-micro-go/app/plant/api/internal/handler/userProfile"
|
||||
wiki "sundynix-micro-go/app/plant/api/internal/handler/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// AI问答
|
||||
Method: http.MethodPost,
|
||||
Path: "/ai/chat",
|
||||
Handler: ai.AiChatHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 聊天历史
|
||||
Method: http.MethodGet,
|
||||
Path: "/ai/history",
|
||||
Handler: ai.GetAiChatHistoryHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 微信支付回调
|
||||
Method: http.MethodPost,
|
||||
Path: "/callback/wechatpay",
|
||||
Handler: callback.WechatPayCallbackHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 徽章配置列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/config/badge/list",
|
||||
Handler: config.GetBadgeConfigListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 等级配置列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/config/level/list",
|
||||
Handler: config.GetLevelConfigListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 兑换商品列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/exchange/list",
|
||||
Handler: exchange.GetExchangeItemListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 兑换商品
|
||||
Method: http.MethodPost,
|
||||
Path: "/exchange/order",
|
||||
Handler: exchange.CreateExchangeOrderHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 植物详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/my/:id",
|
||||
Handler: myPlant.GetPlantDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加养护计划
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/carePlan",
|
||||
Handler: myPlant.AddCarePlanHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加养护记录
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/careRecord",
|
||||
Handler: myPlant.AddCareRecordHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建植物
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/create",
|
||||
Handler: myPlant.CreatePlantHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除植物
|
||||
Method: http.MethodDelete,
|
||||
Path: "/my/delete",
|
||||
Handler: myPlant.DeletePlantHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加成长记录
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/growthRecord",
|
||||
Handler: myPlant.AddGrowthRecordHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 我的植物列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/list",
|
||||
Handler: myPlant.GetMyPlantListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新植物
|
||||
Method: http.MethodPut,
|
||||
Path: "/my/update",
|
||||
Handler: myPlant.UpdatePlantHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// OCR植物识别
|
||||
Method: http.MethodPost,
|
||||
Path: "/ocr/classify",
|
||||
Handler: ocr.OcrClassifyHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 帖子详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/post/:id",
|
||||
Handler: post.GetPostDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 评论帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/comment",
|
||||
Handler: post.CommentPostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 发布帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/create",
|
||||
Handler: post.CreatePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除帖子
|
||||
Method: http.MethodDelete,
|
||||
Path: "/post/delete",
|
||||
Handler: post.DeletePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 点赞帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/like",
|
||||
Handler: post.LikePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 帖子列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/list",
|
||||
Handler: post.GetPostListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建话题
|
||||
Method: http.MethodPost,
|
||||
Path: "/topic/create",
|
||||
Handler: topic.CreateTopicHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除话题
|
||||
Method: http.MethodDelete,
|
||||
Path: "/topic/delete",
|
||||
Handler: topic.DeleteTopicHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 话题列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/topic/list",
|
||||
Handler: topic.GetTopicListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取用户资料
|
||||
Method: http.MethodGet,
|
||||
Path: "/profile/info",
|
||||
Handler: userProfile.GetUserProfileHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新用户资料
|
||||
Method: http.MethodPut,
|
||||
Path: "/profile/update",
|
||||
Handler: userProfile.UpdateUserProfileHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 百科详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/wiki/:id",
|
||||
Handler: wiki.GetWikiDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建百科分类
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/class/create",
|
||||
Handler: wiki.CreateWikiClassHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 百科分类列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/wiki/class/list",
|
||||
Handler: wiki.GetWikiClassListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 百科列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/list",
|
||||
Handler: wiki.GetWikiListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 收藏/取消收藏百科
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/star",
|
||||
Handler: wiki.ToggleWikiStarHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user