50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"gitee.ltd/lxh/logger"
|
|
"gitee.ltd/lxh/logger/log"
|
|
"github.com/gin-gonic/gin"
|
|
"wechat-robot/internal/initialize"
|
|
"wechat-robot/pkg/validator"
|
|
"wechat-robot/router/admin"
|
|
"wechat-robot/router/callback"
|
|
"wechat-robot/router/middleware"
|
|
)
|
|
|
|
// init
|
|
// @description: 初始系统
|
|
func init() {
|
|
// 初始化日志工具
|
|
logger.InitLogger(logger.LogConfig{Mode: logger.Dev, LokiEnable: false, FileEnable: true})
|
|
// 初始化系统
|
|
initialize.InitSystem()
|
|
}
|
|
|
|
// main
|
|
// @description: 启动入口
|
|
func main() {
|
|
// 启动TCP服务
|
|
//go tcpserver.Start()
|
|
|
|
// 注册参数绑定错误信息翻译器
|
|
validator.Init()
|
|
app := gin.Default()
|
|
|
|
// 开启自定义请求方式不允许处理函数
|
|
app.HandleMethodNotAllowed = true
|
|
// 处理请求方式不对
|
|
app.NoMethod(middleware.NoMethodHandler())
|
|
// 404返回数据
|
|
app.NoRoute(middleware.NoRouteHandler())
|
|
|
|
// 初始化接口路由
|
|
admin.InitRoute(app.Group("/admin/v1")) // 后台接口
|
|
callback.InitRoute(app.Group("/callback")) // 回调接口
|
|
|
|
// 启动服务
|
|
if err := app.Run(":8080"); err != nil {
|
|
log.Errorf("服务启动失败:%v", err)
|
|
return
|
|
}
|
|
}
|