You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB
Go

8 months ago
package router
import (
"github.com/exhibition-main/internal/middleware"
8 months ago
"github.com/exhibition-main/pkg/service"
"github.com/exhibition-main/pkg/service/common"
8 months ago
"net/http"
"github.com/gin-contrib/gzip"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
)
// 路由配置
func NewRouter() *gin.Engine {
//使用默认gin路由
r := gin.Default()
r.Use(gzip.Gzip(gzip.DefaultCompression))
//加入日志中间件,跨域中间件
//r.Use(middleware.NewLogger(), middleware.Cors(), middleware.GinRecovery(true))
8 months ago
auth := r.Group("")
8 months ago
//auth.Use(middleware.JWTAuthMiddleware())
8 months ago
// 上传
upload := auth.Group("upload")
{
upload.POST("img", common.UploadImg)
}
8 months ago
check := auth.Group("account")
{
7 months ago
check.POST("send_code", service.OnlySend) // 发送验证码
check.POST("check_code", service.OnlyCheck) // 检查验证码
8 months ago
8 months ago
}
8 months ago
registerAuth := auth.Group("register")
{
8 months ago
registerAuth.POST("register_record_list", service.RegisterList) //报名列表
registerAuth.POST("check_by_phone", service.CheckByPhone) //检索手机号
registerAuth.POST("save_register_info", service.SaveRegister) //保存
registerAuth.POST("export_register", service.ExportRegister) //导出
registerAuth.POST("scan_id_card", service.GetCardIdWithImg) //扫描身份证图片获取信息
8 months ago
}
8 months ago
//静态文件
r.StaticFS("/static", http.Dir("./runtime"))
r.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{
"status": 1,
"msg": "不存在的路由",
})
})
pprof.Register(r)
return r
}