first commit
This commit is contained in:
71
go_backend/router/router.go
Normal file
71
go_backend/router/router.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"ai_xhs/controller"
|
||||
"ai_xhs/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SetupRouter(r *gin.Engine) {
|
||||
// 跨域中间件
|
||||
r.Use(middleware.CORS())
|
||||
|
||||
// 健康检查
|
||||
r.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"status": "ok",
|
||||
})
|
||||
})
|
||||
|
||||
// API路由组
|
||||
api := r.Group("/api")
|
||||
{
|
||||
// 公开接口(不需要认证)
|
||||
authCtrl := controller.NewAuthController()
|
||||
api.POST("/login/wechat", authCtrl.WechatLogin) // 微信登录
|
||||
api.POST("/login/phone", authCtrl.PhoneLogin) // 手机号登录(测试用)
|
||||
|
||||
// 小红书相关公开接口
|
||||
employeeCtrlPublic := controller.NewEmployeeController()
|
||||
api.POST("/xhs/send-code", employeeCtrlPublic.SendXHSCode) // 发送小红书验证码
|
||||
api.GET("/products", employeeCtrlPublic.GetProducts) // 获取产品列表(公开)
|
||||
|
||||
// 员工路由(需要认证)
|
||||
employee := api.Group("/employee")
|
||||
employee.Use(middleware.AuthMiddleware())
|
||||
{
|
||||
employeeCtrl := controller.NewEmployeeController()
|
||||
|
||||
// 10.1 获取员工个人信息
|
||||
employee.GET("/profile", employeeCtrl.GetProfile)
|
||||
|
||||
// 10.2 绑定小红书账号
|
||||
employee.POST("/bind-xhs", employeeCtrl.BindXHS)
|
||||
|
||||
// 10.3 解绑小红书账号
|
||||
employee.POST("/unbind-xhs", employeeCtrl.UnbindXHS)
|
||||
|
||||
// 10.4 获取可领取文案列表
|
||||
employee.GET("/available-copies", employeeCtrl.GetAvailableCopies)
|
||||
|
||||
// 10.5 领取文案
|
||||
employee.POST("/claim-copy", employeeCtrl.ClaimCopy)
|
||||
|
||||
// 10.6 随机领取文案
|
||||
employee.POST("/claim-random-copy", employeeCtrl.ClaimRandomCopy)
|
||||
|
||||
// 10.7 发布内容
|
||||
employee.POST("/publish", employeeCtrl.Publish)
|
||||
|
||||
// 10.8 获取我的发布记录
|
||||
employee.GET("/my-publish-records", employeeCtrl.GetMyPublishRecords)
|
||||
|
||||
// 10.8.1 获取发布记录详情
|
||||
employee.GET("/publish-record/:id", employeeCtrl.GetPublishRecordDetail)
|
||||
|
||||
// 10.9 检查小红书绑定与Cookie状态
|
||||
employee.GET("/xhs/status", employeeCtrl.CheckXHSStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user