46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
jwt "github.com/appleboy/gin-jwt/v2"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/golang/protobuf/proto"
|
|
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
|
|
"joylink.club/bj-rtsts-server/dto"
|
|
"joylink.club/bj-rtsts-server/middleware"
|
|
)
|
|
|
|
func InitGenerateGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
|
authed := api.Group("/v1/generate").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
|
|
authed.POST("/calculatelink", generateCalculateLinkData)
|
|
}
|
|
|
|
// 根据地图数据新生成计算的link信息
|
|
//
|
|
// @Summary 根据地图数据新生成计算的link信息
|
|
//
|
|
// @Security JwtAuth
|
|
//
|
|
// @Description 根据地图数据新生成计算的link信息
|
|
// @Tags GenerateApi
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param DraftingMapDataDto query dto.DraftingMapDataDto true "地图信息"
|
|
// @Success 200 {object} nil
|
|
// @Failure 401 {object} dto.ErrorDto
|
|
// @Failure 404 {object} dto.ErrorDto
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
// @Router /api/v1/generate/calculatelink [post]
|
|
func generateCalculateLinkData(c *gin.Context) {
|
|
req := dto.DraftingMapDataDto{}
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
c.JSON(http.StatusBadRequest, "参数获取出错")
|
|
return
|
|
}
|
|
gd := &graphicData.RtssGraphicStorage{}
|
|
proto.Unmarshal(req.Proto, gd)
|
|
c.JSON(http.StatusOK, memory.BuildCalculateLinkData(gd))
|
|
}
|