|
@@ -1,10 +1,12 @@
|
|
|
package initialize
|
|
|
|
|
|
import (
|
|
|
- "confrontation-training/api"
|
|
|
+ "confrontation-training/api/gateway"
|
|
|
+ "confrontation-training/api/question"
|
|
|
"confrontation-training/global"
|
|
|
_ "confrontation-training/global"
|
|
|
"confrontation-training/middleware"
|
|
|
+ "confrontation-training/models"
|
|
|
"fmt"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
swaggerFiles "github.com/swaggo/files"
|
|
@@ -13,6 +15,13 @@ import (
|
|
|
)
|
|
|
|
|
|
func Router() {
|
|
|
+
|
|
|
+ //初始化表格
|
|
|
+ initTableErr := global.Db.AutoMigrate(&models.User{}, &models.Question{})
|
|
|
+ if initTableErr != nil {
|
|
|
+ fmt.Printf("初始化表格异常:%s", initTableErr.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
engine := gin.Default()
|
|
|
//解决跨域
|
|
@@ -31,21 +40,26 @@ func Router() {
|
|
|
//group
|
|
|
v1 := engine.Group("/v1")
|
|
|
user := v1.Group("/user")
|
|
|
- user.POST("/login", api.GetUser().UserLogin)
|
|
|
+ user.POST("/login", gateway.GetUser().UserLogin)
|
|
|
|
|
|
//user.Use(middleware.JwtAuth())
|
|
|
- user.POST("/register", api.GetUser().UseRegister)
|
|
|
- user.POST("/reset", api.GetUser().ResetPassword)
|
|
|
- user.POST("/find", api.GetUser().UserList)
|
|
|
- user.POST("/change/password", api.GetUser().ModePass)
|
|
|
+ user.POST("/register", gateway.GetUser().UseRegister)
|
|
|
+ user.POST("/reset", gateway.GetUser().ResetPassword)
|
|
|
+ user.POST("/find", gateway.GetUser().UserList)
|
|
|
+ user.POST("/change/password", gateway.GetUser().ModePass)
|
|
|
device := v1.Group("/device")
|
|
|
- device.GET("/scan", api.ScanDevice)
|
|
|
- device.GET("/connection", api.ConnectDevice)
|
|
|
- device.POST("/write/data/", api.WriteData)
|
|
|
- device.GET("/open/notify/", api.OpenNotify)
|
|
|
- device.GET("/:mac/stop/trans/", api.StopTrans)
|
|
|
- device.GET("/:mac/stop/collect/", api.StopCollect)
|
|
|
- device.GET("/:mac/disconnect/", api.Disconnect)
|
|
|
+ device.GET("/scan", gateway.ScanDevice)
|
|
|
+ device.GET("/connection", gateway.ConnectDevice)
|
|
|
+ device.POST("/write/data/", gateway.WriteData)
|
|
|
+ device.GET("/open/notify/", gateway.OpenNotify)
|
|
|
+ device.GET("/:mac/stop/trans/", gateway.StopTrans)
|
|
|
+ device.GET("/:mac/stop/collect/", gateway.StopCollect)
|
|
|
+ device.GET("/:mac/disconnect/", gateway.Disconnect)
|
|
|
+ chat := v1.Group("/chat")
|
|
|
+ chat.GET("/get/question/", question.GetQuestionService().GetQuestion)
|
|
|
+ chat.POST("/create/question/", question.GetQuestionService().CreateQuestion)
|
|
|
+ chat.GET("/get/answer/", question.GteAnswerService().CreateAnswer)
|
|
|
+
|
|
|
//
|
|
|
//record := v1.Group("/record")
|
|
|
//record.POST("/create", api.GetRecord().SaveRecord)
|