添加ats测试接口定义
This commit is contained in:
parent
6552fd47cd
commit
a6b806130e
|
@ -0,0 +1,73 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
jwt "github.com/appleboy/gin-jwt/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
authed := api.Group("/v1/simulation").Use(authMiddleware.MiddlewareFunc())
|
||||
authed.POST("/create", create)
|
||||
authed.POST("/train/add", addTrain)
|
||||
}
|
||||
|
||||
// 创建ATS测试仿真
|
||||
//
|
||||
// @Summary 创建ATS测试仿真
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建ATS测试仿真
|
||||
// @Tags ATS测试仿真Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param SimulationCreateReqDto body dto.SimulationCreateReqDto true "创建仿真请求"
|
||||
// @Success 200 {object} dto.SimulationCreateRspDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/simulation/create [post]
|
||||
func create(c *gin.Context) {
|
||||
//user,_:=c.Get(middleware.IdentityKey)
|
||||
req := dto.SimulationCreateReqDto{}
|
||||
if err := c.ShouldBind(&req); nil != err {
|
||||
panic(err)
|
||||
}
|
||||
zap.S().Debug("创建仿真请求:", req)
|
||||
rsp := dto.SimulationCreateRspDto{}
|
||||
rsp.MapId = req.MapId
|
||||
rsp.SimulationId = fmt.Sprintf("sim-%d", req.MapId)
|
||||
c.JSON(http.StatusOK, &rsp)
|
||||
}
|
||||
|
||||
// ATS测试仿真-添加列车
|
||||
//
|
||||
// @Summary ATS测试仿真-添加列车
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description ATS测试仿真-添加列车
|
||||
// @Tags ATS测试仿真Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param AddTrainReqDto body dto.AddTrainReqDto true "ATS测试仿真-添加列车"
|
||||
// @Success 200 {object} dto.AddTrainRspDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/simulation/train/add [post]
|
||||
func addTrain(c *gin.Context) {
|
||||
//user,_:=c.Get(middleware.IdentityKey)
|
||||
req := dto.AddTrainReqDto{}
|
||||
if err := c.ShouldBind(&req); nil != err {
|
||||
panic(err)
|
||||
}
|
||||
zap.S().Debug("ATS测试仿真-添加列车,请求:", req)
|
||||
rsp := dto.AddTrainRspDto{}
|
||||
rsp.SimulationId = req.SimulationId
|
||||
rsp.TrainId = "666"
|
||||
c.JSON(http.StatusOK, &rsp)
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package dto
|
||||
|
||||
//创建仿真请求
|
||||
type SimulationCreateReqDto struct {
|
||||
//地图id
|
||||
MapId int32 `json:"mapId" form:"mapId"`
|
||||
}
|
||||
|
||||
//创建仿真响应
|
||||
type SimulationCreateRspDto struct {
|
||||
//地图id
|
||||
MapId int32 `json:"mapId" form:"mapId"`
|
||||
//仿真id
|
||||
SimulationId string `json:"simulationId" form:"simulationId"`
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 为仿真添加测试车请求
|
||||
type AddTrainReqDto struct {
|
||||
//仿真id
|
||||
SimulationId string `json:"simulationId" form:"simulationId"`
|
||||
//列车方向,true-上行,false-下行
|
||||
Up bool `json:"up" form:"up"`
|
||||
//车头所在link的索引
|
||||
HeadLinkId string `json:"headLinkId" form:"headLinkId"`
|
||||
//车头所在link内的偏移量,单位为mm
|
||||
HeadLinkOffset int64 `json:"headLinkOffset" form:"headLinkOffset"`
|
||||
}
|
||||
|
||||
//为仿真添加测试车请求
|
||||
type AddTrainRspDto struct {
|
||||
//仿真id
|
||||
SimulationId string `json:"simulationId" form:"simulationId"`
|
||||
//新添加的列车的索引
|
||||
TrainId string `json:"trainId" form:"trainId"`
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
1
main.go
1
main.go
|
@ -30,6 +30,7 @@ func main() {
|
|||
api.InitUserRouter(router, authMiddleware)
|
||||
api.InitDraftingRouter(router, authMiddleware)
|
||||
api.InitPublishedGiRouter(router, authMiddleware)
|
||||
api.InitSimulationRouter(router, authMiddleware)
|
||||
|
||||
docs.SwaggerInfo.Title = "CBTC测试系统API"
|
||||
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
|
Loading…
Reference in New Issue