You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
package main
|
|
|
|
import (
|
|
"dsSzxy/Handler"
|
|
"dsSzxy/Router"
|
|
"dsSzxy/Utils"
|
|
"dsSzxy/Utils/CommonUtil"
|
|
"dsSzxy/Utils/ConfigUtil"
|
|
ginSwagger "github.com/swaggo/gin-swagger"
|
|
"github.com/swaggo/gin-swagger/swaggerFiles"
|
|
|
|
"dsSzxy/Utils/FileUtil"
|
|
_ "dsSzxy/docs"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//http://127.0.0.1:8006/swagger/index.html
|
|
|
|
// @title 智慧校园API
|
|
// @version 1.0
|
|
// @description 物联网,大数据,人工智能
|
|
// @contact.name API Support
|
|
// @contact.url http://www.swagger.io/support
|
|
// @contact.email support@swagger.io
|
|
// @license.name Apache 2.0
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
|
// @host 127.0.0.1:8006
|
|
func main() {
|
|
// 发布模式
|
|
//gin.SetMode(gin.ReleaseMode)
|
|
// 显示Logo
|
|
configIniFile := "./Config/logo.txt"
|
|
if !CommonUtil.Exists(configIniFile) {
|
|
configIniFile = "/usr/local/dsMin/dsSzxy/Config/logo.txt"
|
|
}
|
|
var logo = FileUtil.ReadFileContent(configIniFile)
|
|
fmt.Print(logo)
|
|
|
|
// 开发模式
|
|
gin.SetMode(gin.DebugMode)
|
|
// 开启gin服务器
|
|
r := gin.Default()
|
|
//注册swagger
|
|
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
|
//设置静态资源
|
|
r.Static("/dsSzxy/static", "./static")
|
|
// 使用跨域中间件
|
|
r.Use(Utils.Cors())
|
|
//参数有效性验证拦截器
|
|
r.Use(Handler.ParameterHandler())
|
|
//向融云同步数据
|
|
//go ImRelateDao.SyncRongYunUser()
|
|
//go ImRelateDao.SyncRongYunGroup()
|
|
//主路由
|
|
Router.GinRouter(r)
|
|
// 监听并在 0.0.0.0:8006 上启动服务
|
|
r.Run(":" + ConfigUtil.ServerPort)
|
|
}
|