增加动力学循环发送道岔状态任务;修改jsonTime反序列化方法
This commit is contained in:
parent
bfa8deb77c
commit
2971e68f40
@ -6,6 +6,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
||||
"joylink.club/bj-rtsts-server/middleware"
|
||||
"joylink.club/bj-rtsts-server/service"
|
||||
"net/http"
|
||||
@ -31,8 +32,7 @@ func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
||||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param pagePublishedGiReqDto query dto.PublishedGiReqDto true "分页查询参数"
|
||||
// @Param pagePublishedGiReqDto query publishedGi.PublishedGiReqDto true "分页查询参数"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
@ -40,16 +40,12 @@ func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
||||
func pageQueryPublishedGi(c *gin.Context) {
|
||||
user, _ := c.Get(middleware.IdentityKey)
|
||||
zap.S().Debug("分页查询发布的图形数据", user)
|
||||
req := dto.PublishedGiReqDto{}
|
||||
req := publishedGi.PublishedGiReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
//zap.S().Warn("分页查询参数绑定错误,使用默认参数", err)
|
||||
req.Default()
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
zap.S().Debug("分页查询发布的图形数据", req)
|
||||
page, err := service.PageQueryPublishedGi(&req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
page := service.PageQueryPublishedGi(&req)
|
||||
c.JSON(http.StatusOK, page)
|
||||
}
|
||||
|
||||
@ -63,8 +59,7 @@ func pageQueryPublishedGi(c *gin.Context) {
|
||||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param pagePublishedGiReqDto query dto.PublishedGiReqDto true "查询参数"
|
||||
// @Param pagePublishedGiReqDto query publishedGi.PublishedGiReqDto true "查询参数"
|
||||
// @Success 200 {object} []model.PublishedGi
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
@ -72,15 +67,12 @@ func pageQueryPublishedGi(c *gin.Context) {
|
||||
func listQueryPublishedGi(c *gin.Context) {
|
||||
user, _ := c.Get(middleware.IdentityKey)
|
||||
zap.S().Debug("列表查询发布的图形数据", user)
|
||||
req := dto.PublishedGiReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
zap.S().Warn("列表查询参数绑定错误", err)
|
||||
req := publishedGi.PublishedGiReqDto{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
zap.S().Debug("列表查询发布的图形数据", req)
|
||||
list, err := service.ListQueryPublishedGi(&req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
list := service.ListQueryPublishedGi(&req)
|
||||
c.JSON(http.StatusOK, list)
|
||||
}
|
||||
|
||||
@ -94,7 +86,6 @@ func listQueryPublishedGi(c *gin.Context) {
|
||||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param id path int true "id"
|
||||
// @Success 200 {object} model.PublishedGi
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
@ -106,7 +97,7 @@ func getPublishedGiById(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
panic("id参数解析错误")
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
zap.S().Debug("id查询发布的图形数据", id)
|
||||
entity, err := service.GetPublishedGiById(id)
|
||||
@ -126,8 +117,7 @@ func getPublishedGiById(c *gin.Context) {
|
||||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param PublishReqDto query dto.PublishReqDto true "查询参数"
|
||||
// @Param PublishReqDto query publishedGi.PublishReqDto true "查询参数"
|
||||
// @Success 200
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
@ -135,10 +125,11 @@ func getPublishedGiById(c *gin.Context) {
|
||||
func publishFromDraft(c *gin.Context) {
|
||||
user, _ := c.Get(middleware.IdentityKey)
|
||||
zap.S().Debug("发布图形数据", user)
|
||||
req := dto.PublishReqDto{}
|
||||
req := publishedGi.PublishReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
zap.S().Warn("发布图形数据参数绑定错误", err)
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
//todo
|
||||
zap.S().Debug("发布图形数据请求参数", req)
|
||||
service.PublishFormDraft(&req, user.(*model.User))
|
||||
}
|
||||
@ -153,7 +144,6 @@ func publishFromDraft(c *gin.Context) {
|
||||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param id path int true "id"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
@ -165,7 +155,7 @@ func deletePublishedGiById(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
panic("id参数解析错误")
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
zap.S().Debug("id查询发布的图形数据", id)
|
||||
service.DeletePublishedGiById(id)
|
||||
|
153
docs/docs.go
153
docs/docs.go
@ -413,13 +413,6 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "列表查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
@ -440,6 +433,11 @@ const docTemplate = `{
|
||||
"name": "size",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -486,13 +484,6 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "分页查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
@ -513,6 +504,11 @@ const docTemplate = `{
|
||||
"name": "size",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -555,17 +551,10 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "从草稿发布数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "草稿数据的id",
|
||||
"name": "draftId",
|
||||
"name": "draftingId",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
@ -613,13 +602,6 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "id查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
@ -667,13 +649,6 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "id删除发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
@ -805,56 +780,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/destroy/{id}": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"JwtAuth": []
|
||||
}
|
||||
],
|
||||
"description": "ATS测试仿真-添加列车",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"ATS测试仿真Api"
|
||||
],
|
||||
"summary": "ATS仿真销毁",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "仿真id",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ErrorDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/list": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -1005,6 +930,56 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/train/destroy/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JwtAuth": []
|
||||
}
|
||||
],
|
||||
"description": "ATS测试仿真-添加列车",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"ATS测试仿真Api"
|
||||
],
|
||||
"summary": "ATS仿真销毁",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "仿真id",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ErrorDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/train/remove": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -1460,7 +1435,9 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"simulationId",
|
||||
"switchIndex"
|
||||
"switchIndex",
|
||||
"turnNormal",
|
||||
"turnReverse"
|
||||
],
|
||||
"properties": {
|
||||
"simulationId": {
|
||||
@ -1564,7 +1541,7 @@ const docTemplate = `{
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "localhost:8080",
|
||||
Host: "localhost:9091",
|
||||
BasePath: "/",
|
||||
Schemes: []string{},
|
||||
Title: "CBTC测试系统API",
|
||||
|
@ -6,7 +6,7 @@
|
||||
"contact": {},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"host": "localhost:9091",
|
||||
"basePath": "/",
|
||||
"paths": {
|
||||
"/api/v1/drafting": {
|
||||
@ -406,13 +406,6 @@
|
||||
],
|
||||
"summary": "列表查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
@ -433,6 +426,11 @@
|
||||
"name": "size",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -479,13 +477,6 @@
|
||||
],
|
||||
"summary": "分页查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
@ -506,6 +497,11 @@
|
||||
"name": "size",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -548,17 +544,10 @@
|
||||
],
|
||||
"summary": "从草稿发布数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "草稿数据的id",
|
||||
"name": "draftId",
|
||||
"name": "draftingId",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
@ -606,13 +595,6 @@
|
||||
],
|
||||
"summary": "id查询发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
@ -660,13 +642,6 @@
|
||||
],
|
||||
"summary": "id删除发布的图形数据",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
@ -798,56 +773,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/destroy/{id}": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"JwtAuth": []
|
||||
}
|
||||
],
|
||||
"description": "ATS测试仿真-添加列车",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"ATS测试仿真Api"
|
||||
],
|
||||
"summary": "ATS仿真销毁",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "仿真id",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ErrorDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/list": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -998,6 +923,56 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/train/destroy/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JwtAuth": []
|
||||
}
|
||||
],
|
||||
"description": "ATS测试仿真-添加列车",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"ATS测试仿真Api"
|
||||
],
|
||||
"summary": "ATS仿真销毁",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "JWT Token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "仿真id",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ErrorDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/simulation/train/remove": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -1453,7 +1428,9 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"simulationId",
|
||||
"switchIndex"
|
||||
"switchIndex",
|
||||
"turnNormal",
|
||||
"turnReverse"
|
||||
],
|
||||
"properties": {
|
||||
"simulationId": {
|
||||
|
@ -153,6 +153,8 @@ definitions:
|
||||
required:
|
||||
- simulationId
|
||||
- switchIndex
|
||||
- turnNormal
|
||||
- turnReverse
|
||||
type: object
|
||||
dto.TokenRespDto:
|
||||
properties:
|
||||
@ -206,7 +208,7 @@ definitions:
|
||||
description: 发布用户id
|
||||
type: integer
|
||||
type: object
|
||||
host: localhost:8080
|
||||
host: localhost:9091
|
||||
info:
|
||||
contact: {}
|
||||
description: CBTC测试服务.
|
||||
@ -460,11 +462,6 @@ paths:
|
||||
- application/json
|
||||
description: 可以通过名称过滤
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: id
|
||||
in: path
|
||||
name: id
|
||||
@ -493,11 +490,6 @@ paths:
|
||||
- application/json
|
||||
description: 可以通过名称过滤
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: id
|
||||
in: path
|
||||
name: id
|
||||
@ -529,11 +521,6 @@ paths:
|
||||
- application/json
|
||||
description: 可以通过名称过滤
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- in: query
|
||||
name: name
|
||||
type: string
|
||||
@ -549,6 +536,9 @@ paths:
|
||||
name: size
|
||||
required: true
|
||||
type: integer
|
||||
- in: query
|
||||
name: time
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@ -577,11 +567,6 @@ paths:
|
||||
- application/json
|
||||
description: 可以通过名称过滤
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- in: query
|
||||
name: name
|
||||
type: string
|
||||
@ -597,6 +582,9 @@ paths:
|
||||
name: size
|
||||
required: true
|
||||
type: integer
|
||||
- in: query
|
||||
name: time
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@ -622,14 +610,9 @@ paths:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: 草稿数据的id
|
||||
in: query
|
||||
name: draftId
|
||||
name: draftingId
|
||||
type: integer
|
||||
- description: 发布后的名称
|
||||
in: query
|
||||
@ -719,38 +702,6 @@ paths:
|
||||
summary: 创建ATS测试仿真
|
||||
tags:
|
||||
- ATS测试仿真Api
|
||||
/api/v1/simulation/destroy/{id}:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: ATS测试仿真-添加列车
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: 仿真id
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: string
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ErrorDto'
|
||||
security:
|
||||
- JwtAuth: []
|
||||
summary: ATS仿真销毁
|
||||
tags:
|
||||
- ATS测试仿真Api
|
||||
/api/v1/simulation/list:
|
||||
get:
|
||||
consumes:
|
||||
@ -846,6 +797,38 @@ paths:
|
||||
summary: ATS测试仿真-添加列车
|
||||
tags:
|
||||
- ATS测试仿真Api
|
||||
/api/v1/simulation/train/destroy/{id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: ATS测试仿真-添加列车
|
||||
parameters:
|
||||
- description: JWT Token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: 仿真id
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: string
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ErrorDto'
|
||||
security:
|
||||
- JwtAuth: []
|
||||
summary: ATS仿真销毁
|
||||
tags:
|
||||
- ATS测试仿真Api
|
||||
/api/v1/simulation/train/remove:
|
||||
post:
|
||||
consumes:
|
||||
|
@ -45,11 +45,10 @@ func (jt *JsonTime) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (jt *JsonTime) UnmarshalJSON(data []byte) error {
|
||||
var str string
|
||||
err := json.Unmarshal(data, &str)
|
||||
if err != nil {
|
||||
panic(ErrorDto{ArgumentParseError, fmt.Sprintf("时间参数解析出错:\n%s", err.Error())})
|
||||
if data[0] == '"' {
|
||||
data = data[1 : len(data)-1]
|
||||
}
|
||||
str := string(data)
|
||||
parse, err := time.Parse(time.DateTime, str)
|
||||
if err != nil {
|
||||
panic(ErrorDto{ArgumentParseError, fmt.Sprintf("时间参数格式化出错:\n%s", err.Error())})
|
||||
@ -58,6 +57,10 @@ func (jt *JsonTime) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (jt *JsonTime) String() string {
|
||||
return time.Time(*jt).Format(time.DateTime)
|
||||
}
|
||||
|
||||
// 数据库分页偏移
|
||||
func (p *PageQueryDto) Offset() int {
|
||||
if p.Page > 0 {
|
||||
|
@ -1,25 +0,0 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type PublishedGiReqDto struct {
|
||||
PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type PublishReqDto struct {
|
||||
//发布后的名称
|
||||
Name string `json:"name" form:"name"`
|
||||
//草稿数据的id
|
||||
DraftId int32 `json:"draftId" form:"draftId"`
|
||||
////是否覆盖同名数据
|
||||
//Overwrite bool `json:"overwrite" form:"overwrite"`
|
||||
}
|
||||
|
||||
type PublishedGi struct {
|
||||
ID int32
|
||||
Name string
|
||||
Proto []byte
|
||||
UserID int32
|
||||
PublishAt time.Time
|
||||
}
|
50
dto/publishedGi/publishedGi.go
Normal file
50
dto/publishedGi/publishedGi.go
Normal file
@ -0,0 +1,50 @@
|
||||
package publishedGi
|
||||
|
||||
import (
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
type PublishedGiReqDto struct {
|
||||
dto.PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
|
||||
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
|
||||
}
|
||||
|
||||
type PublishReqDto struct {
|
||||
//发布后的名称
|
||||
Name string `json:"name" form:"name"`
|
||||
//草稿数据的id
|
||||
DraftId int32 `json:"draftingId" form:"draftingId"`
|
||||
|
||||
//Time dto.JsonTime `json:"time" form:"time"`
|
||||
////是否覆盖同名数据
|
||||
//Overwrite bool `json:"overwrite" form:"overwrite"`
|
||||
}
|
||||
|
||||
type PublishedGiDto struct {
|
||||
ID int32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Proto []byte `json:"proto"`
|
||||
UserID int32 `json:"userID"`
|
||||
PublishAt dto.JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"`
|
||||
}
|
||||
|
||||
func ConvertFrom(gi *model.PublishedGi) *PublishedGiDto {
|
||||
return &PublishedGiDto{
|
||||
ID: gi.ID,
|
||||
Name: gi.Name,
|
||||
Proto: gi.Proto,
|
||||
UserID: gi.UserID,
|
||||
PublishAt: dto.JsonTime(gi.PublishAt),
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertFromSlice(giSlice []*model.PublishedGi) []*PublishedGiDto {
|
||||
var result []*PublishedGiDto
|
||||
for _, gi := range giSlice {
|
||||
result = append(result, ConvertFrom(gi))
|
||||
}
|
||||
return result
|
||||
}
|
@ -7,8 +7,27 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
// TurnoutInfoChan 用来存放要发送的道岔信息
|
||||
TurnoutInfoChan = make(chan *TurnoutInfo, 1000)
|
||||
)
|
||||
|
||||
func RunSendTurnoutInfoTask() {
|
||||
go func() {
|
||||
tick := time.Tick(10 * time.Millisecond)
|
||||
for range tick {
|
||||
info := <-TurnoutInfoChan
|
||||
err := SendTurnoutInfo(info)
|
||||
if err != nil {
|
||||
zap.S().Error(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// SendTurnoutInfo 发送道岔信息
|
||||
func SendTurnoutInfo(info *TurnoutInfo) error {
|
||||
defer func() {
|
||||
@ -21,6 +40,7 @@ func SendTurnoutInfo(info *TurnoutInfo) error {
|
||||
conn, err := net.DialUDP("udp", nil, remoteAddr)
|
||||
if err != nil {
|
||||
zap.S().Error("UDP通信失败", err)
|
||||
return err
|
||||
}
|
||||
defer func(conn *net.UDPConn) {
|
||||
err := conn.Close()
|
||||
|
4
go.mod
4
go.mod
@ -27,10 +27,14 @@ require (
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
|
||||
github.com/howeyc/fsnotify v0.9.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a // indirect
|
||||
github.com/pilu/fresh v0.0.0-20190826141211-0fa698148017 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
go.opentelemetry.io/otel v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
||||
|
11
go.sum
11
go.sum
@ -41,6 +41,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/appleboy/gin-jwt/v2 v2.9.1 h1:l29et8iLW6omcHltsOP6LLk4s3v4g2FbFs0koxGWVZs=
|
||||
github.com/appleboy/gin-jwt/v2 v2.9.1/go.mod h1:jwcPZJ92uoC9nOUTOKWoN/f6JZOgMSKlFSHw5/FrRUk=
|
||||
github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4=
|
||||
@ -194,6 +196,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY=
|
||||
github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
@ -239,6 +243,8 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
@ -263,6 +269,10 @@ github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZO
|
||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
|
||||
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
|
||||
github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a h1:Tg4E4cXPZSZyd3H1tJlYo6ZreXV0ZJvE/lorNqyw1AU=
|
||||
github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a/go.mod h1:9Or9aIl95Kp43zONcHd5tLZGKXb9iLx0pZjau0uJ5zg=
|
||||
github.com/pilu/fresh v0.0.0-20190826141211-0fa698148017 h1:XXDLZIIt9NqdeIEva0DM+z1npM0Tsx6h5TYqwNvXfP0=
|
||||
github.com/pilu/fresh v0.0.0-20190826141211-0fa698148017/go.mod h1:2LLTtftTZSdAPR/iVyennXZDLZOYzyDn+T0qEKJ8eSw=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@ -502,6 +512,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
5
main.go
5
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/dynamics"
|
||||
|
||||
swaggerFiles "github.com/swaggo/files" // swagger embed files
|
||||
ginSwagger "github.com/swaggo/gin-swagger" // gin-swagger middleware
|
||||
@ -15,7 +16,7 @@ import (
|
||||
// @version 1.0
|
||||
// @description CBTC测试服务.
|
||||
|
||||
// @host localhost:8080
|
||||
// @host localhost:9091
|
||||
// @BasePath /
|
||||
|
||||
// @securityDefinitions.apikey JwtAuth
|
||||
@ -35,6 +36,8 @@ func main() {
|
||||
docs.SwaggerInfo.Title = "CBTC测试系统API"
|
||||
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
dynamics.RunSendTurnoutInfoTask()
|
||||
|
||||
serverConfig := config.Config.Server
|
||||
if serverConfig.Port == 0 {
|
||||
serverConfig.Port = 8080
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,39 +2,46 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
||||
"time"
|
||||
)
|
||||
|
||||
func PageQueryPublishedGi(req *dto.PublishedGiReqDto) (*dto.PageDto, error) {
|
||||
w := dbquery.PublishedGi.Where()
|
||||
if req.Name != "" {
|
||||
w = w.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
result, count, err := w.Debug().FindByPage(req.Offset(), req.Size)
|
||||
return &dto.PageDto{
|
||||
Total: int(count),
|
||||
PageQueryDto: req.PageQueryDto,
|
||||
Records: result,
|
||||
}, err
|
||||
}
|
||||
|
||||
func ListQueryPublishedGi(req *dto.PublishedGiReqDto) ([]*model.PublishedGi, error) {
|
||||
func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto {
|
||||
where := dbquery.PublishedGi.Where()
|
||||
if req.Name != "" {
|
||||
where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
return where.Debug().Find()
|
||||
result, count, err := where.Debug().FindByPage(req.Offset(), req.Size)
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
return &dto.PageDto{
|
||||
Total: int(count),
|
||||
PageQueryDto: req.PageQueryDto,
|
||||
Records: publishedGi.ConvertFromSlice(result),
|
||||
}
|
||||
}
|
||||
|
||||
func ListQueryPublishedGi(req *publishedGi.PublishedGiReqDto) []*publishedGi.PublishedGiDto {
|
||||
where := dbquery.PublishedGi.Where()
|
||||
if req.Name != "" {
|
||||
where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
find, err := where.Debug().Find()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
return publishedGi.ConvertFromSlice(find)
|
||||
}
|
||||
|
||||
func GetPublishedGiById(id int) (*model.PublishedGi, error) {
|
||||
return dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(int32(id))).Debug().First()
|
||||
}
|
||||
|
||||
func PublishFormDraft(req *dto.PublishReqDto, user *model.User) {
|
||||
func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
|
||||
draft := QueryDrafting(req.DraftId)
|
||||
if draft.Proto == nil || len(draft.Proto) == 0 {
|
||||
panic(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId))
|
||||
|
Loading…
Reference in New Issue
Block a user