【增加获取运行环境结构说明接口】

This commit is contained in:
weizhihong 2023-10-31 18:08:17 +08:00
parent 4e110e94fe
commit ec3eb2f7d0
6 changed files with 239 additions and 159 deletions

View File

@ -2,10 +2,12 @@ package api
import ( import (
"net/http" "net/http"
"reflect"
"strconv" "strconv"
jwt "github.com/appleboy/gin-jwt/v2" jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"joylink.club/bj-rtsts-server/config"
"joylink.club/bj-rtsts-server/dto" "joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/middleware" "joylink.club/bj-rtsts-server/middleware"
"joylink.club/bj-rtsts-server/service" "joylink.club/bj-rtsts-server/service"
@ -20,6 +22,7 @@ func InitProjectRunConfigRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWT
authed.GET("/:id", queryProjectRunConfig) authed.GET("/:id", queryProjectRunConfig)
authed.PUT("/:id", updateProjectRunConfig) authed.PUT("/:id", updateProjectRunConfig)
authed.DELETE("/:id", deleteProjectRunConfig) authed.DELETE("/:id", deleteProjectRunConfig)
authed.GET("/description", getRunCofigDescription)
} }
// 分页查询项目运行环境配置信息 // 分页查询项目运行环境配置信息
@ -169,3 +172,52 @@ func deleteProjectRunConfig(c *gin.Context) {
service.DeleteProjectRunConfigById(int32(id)) service.DeleteProjectRunConfigById(int32(id))
c.JSON(http.StatusOK, true) c.JSON(http.StatusOK, true)
} }
// 获取项目运行环境信息结构说明
//
// @Summary 获取项目运行环境信息结构说明
//
// @Security JwtAuth
//
// @Description 获取项目运行环境信息结构说明
// @Tags 项目运行环境配置Api
// @Accept json
// @Produce json
// @Success 200 {object} nil
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/runconfig/description [get]
func getRunCofigDescription(c *gin.Context) {
c.JSON(http.StatusOK, parseRunCofigStruct(&config.ThridPartyConfig{}))
}
// 解析环境配置结构
func parseRunCofigStruct(m interface{}) []*dto.RunConfigDescription {
var cs []*dto.RunConfigDescription
t := reflect.TypeOf(m).Elem()
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
if field.Tag.Get("description") == "" {
continue
}
c := &dto.RunConfigDescription{
FieldName: field.Tag.Get("json"),
Description: field.Tag.Get("description"),
}
k := field.Type.Kind()
switch k {
case reflect.Struct:
c.ItemTypeFields = parseRunCofigStruct(reflect.New(field.Type).Interface())
c.Type = "map"
case reflect.Slice:
e := field.Type.Elem()
c.ItemTypeFields = parseRunCofigStruct(reflect.New(e).Interface())
c.Type = "array"
default:
c.Type = k.String()
}
cs = append(cs, c)
}
return cs
}

View File

@ -53,30 +53,30 @@ type centrifugo struct {
// 第三方配置结构 // 第三方配置结构
type ThridPartyConfig struct { type ThridPartyConfig struct {
Id int32 `json:"id"` Id int32 `json:"id"`
Dynamics DynamicsConfig `json:"dynamics"` Dynamics DynamicsConfig `json:"dynamics" description:"动力学配置"`
Vobc VobcConfig `json:"vobc"` Vobc VobcConfig `json:"vobc" description:"半实物配置"`
Interlocks []InterlockConfig `json:"interlock"` Interlocks []InterlockConfig `json:"interlock" description:"联锁配置"`
} }
type DynamicsConfig struct { type DynamicsConfig struct {
Ip string `json:"ip"` Ip string `json:"ip" description:"IP配置"`
UdpLocalPort int `json:"udpLocalPort"` UdpLocalPort int `json:"udpLocalPort" description:"本机监听接收端口"`
UdpRemotePort int `json:"udpRemotePort"` UdpRemotePort int `json:"udpRemotePort" description:"远端接收道岔信息端口"`
UdpRemoteTrainPort int `json:"udpRemoteTrainPort"` UdpRemoteTrainPort int `json:"udpRemoteTrainPort" description:"远端接收列车信息端口"`
HttpPort int `json:"httpPort"` HttpPort int `json:"httpPort" description:"http服务端口"`
Open bool `json:"open"` Open bool `json:"open" description:"是否开启"`
} }
type VobcConfig struct { type VobcConfig struct {
Ip string `json:"ip"` Ip string `json:"ip" description:"IP配置"`
LocalPort int `json:"localPort"` LocalPort int `json:"localPort" description:"本机监听接收端口"`
RemotePort int `json:"remotePort"` RemotePort int `json:"remotePort" description:"远端接收列车信息端口"`
Open bool `json:"open"` Open bool `json:"open" description:"是否开启"`
} }
type InterlockConfig struct { type InterlockConfig struct {
Ip string `json:"ip"` Ip string `json:"ip" description:"IP配置"`
LocalPort int `json:"localPort"` LocalPort int `json:"localPort" description:"本机监听接收端口"`
RemotePort int `json:"remotePort"` RemotePort int `json:"remotePort" description:"远端接收采集信息端口"`
Open bool `json:"open"` Open bool `json:"open" description:"是否开启"`
Code string `json:"code"` Code string `json:"code" description:"所属集中站"`
} }
var Config AppConfig var Config AppConfig

View File

@ -2758,7 +2758,8 @@ const docTemplate = `{
{ {
"type": "string", "type": "string",
"name": "config", "name": "config",
"in": "query" "in": "query",
"required": true
}, },
{ {
"type": "string", "type": "string",
@ -2773,7 +2774,8 @@ const docTemplate = `{
{ {
"type": "string", "type": "string",
"name": "name", "name": "name",
"in": "query" "in": "query",
"required": true
} }
], ],
"responses": { "responses": {
@ -2801,6 +2803,49 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/runconfig/description": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "获取项目运行环境信息结构说明",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目运行环境配置Api"
],
"summary": "获取项目运行环境信息结构说明",
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/runconfig/list": { "/api/v1/runconfig/list": {
"get": { "get": {
"security": [ "security": [
@ -3387,49 +3432,6 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/simulation/getDataChannelName": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "获取仿真信息更新通道名称",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取仿真信息更新通道名称",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/ibp/btn/operation": { "/api/v1/simulation/ibp/btn/operation": {
"post": { "post": {
"security": [ "security": [
@ -5682,6 +5684,10 @@ const docTemplate = `{
"projectId": { "projectId": {
"description": "项目id", "description": "项目id",
"type": "integer" "type": "integer"
},
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
} }
} }
}, },
@ -5703,6 +5709,10 @@ const docTemplate = `{
"description": "项目ID", "description": "项目ID",
"type": "integer" "type": "integer"
}, },
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
},
"simulationId": { "simulationId": {
"description": "仿真id", "description": "仿真id",
"type": "string" "type": "string"
@ -5724,6 +5734,10 @@ const docTemplate = `{
"projectId": { "projectId": {
"type": "integer" "type": "integer"
}, },
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
},
"simulationId": { "simulationId": {
"type": "string" "type": "string"
} }
@ -6052,21 +6066,15 @@ const docTemplate = `{
"type": "integer", "type": "integer",
"enum": [ "enum": [
0, 0,
1, 1
2,
3
], ],
"x-enum-comments": { "x-enum-comments": {
"Section_Drst": "设置计轴直接复位", "Section_Drst": "设置计轴直接复位",
"Section_Pdrst": "设置计轴预复位", "Section_Pdrst": "设置计轴预复位"
"Section_TrainIn": "设置计轴区段内有车轴",
"Section_TrainOut": "设置计轴区段内没有车轴"
}, },
"x-enum-varnames": [ "x-enum-varnames": [
"Section_Drst", "Section_Drst",
"Section_Pdrst", "Section_Pdrst"
"Section_TrainIn",
"Section_TrainOut"
] ]
}, },
"request_proto.Signal_Operation": { "request_proto.Signal_Operation": {

View File

@ -2751,7 +2751,8 @@
{ {
"type": "string", "type": "string",
"name": "config", "name": "config",
"in": "query" "in": "query",
"required": true
}, },
{ {
"type": "string", "type": "string",
@ -2766,7 +2767,8 @@
{ {
"type": "string", "type": "string",
"name": "name", "name": "name",
"in": "query" "in": "query",
"required": true
} }
], ],
"responses": { "responses": {
@ -2794,6 +2796,49 @@
} }
} }
}, },
"/api/v1/runconfig/description": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "获取项目运行环境信息结构说明",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目运行环境配置Api"
],
"summary": "获取项目运行环境信息结构说明",
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/runconfig/list": { "/api/v1/runconfig/list": {
"get": { "get": {
"security": [ "security": [
@ -3380,49 +3425,6 @@
} }
} }
}, },
"/api/v1/simulation/getDataChannelName": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "获取仿真信息更新通道名称",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取仿真信息更新通道名称",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/ibp/btn/operation": { "/api/v1/simulation/ibp/btn/operation": {
"post": { "post": {
"security": [ "security": [
@ -5675,6 +5677,10 @@
"projectId": { "projectId": {
"description": "项目id", "description": "项目id",
"type": "integer" "type": "integer"
},
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
} }
} }
}, },
@ -5696,6 +5702,10 @@
"description": "项目ID", "description": "项目ID",
"type": "integer" "type": "integer"
}, },
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
},
"simulationId": { "simulationId": {
"description": "仿真id", "description": "仿真id",
"type": "string" "type": "string"
@ -5717,6 +5727,10 @@
"projectId": { "projectId": {
"type": "integer" "type": "integer"
}, },
"runConfigId": {
"description": "运行环境ID",
"type": "integer"
},
"simulationId": { "simulationId": {
"type": "string" "type": "string"
} }
@ -6045,21 +6059,15 @@
"type": "integer", "type": "integer",
"enum": [ "enum": [
0, 0,
1, 1
2,
3
], ],
"x-enum-comments": { "x-enum-comments": {
"Section_Drst": "设置计轴直接复位", "Section_Drst": "设置计轴直接复位",
"Section_Pdrst": "设置计轴预复位", "Section_Pdrst": "设置计轴预复位"
"Section_TrainIn": "设置计轴区段内有车轴",
"Section_TrainOut": "设置计轴区段内没有车轴"
}, },
"x-enum-varnames": [ "x-enum-varnames": [
"Section_Drst", "Section_Drst",
"Section_Pdrst", "Section_Pdrst"
"Section_TrainIn",
"Section_TrainOut"
] ]
}, },
"request_proto.Signal_Operation": { "request_proto.Signal_Operation": {

View File

@ -333,6 +333,9 @@ definitions:
projectId: projectId:
description: 项目id description: 项目id
type: integer type: integer
runConfigId:
description: 运行环境ID
type: integer
type: object type: object
dto.SimulationCreateRspDto: dto.SimulationCreateRspDto:
properties: properties:
@ -347,6 +350,9 @@ definitions:
projectId: projectId:
description: 项目ID description: 项目ID
type: integer type: integer
runConfigId:
description: 运行环境ID
type: integer
simulationId: simulationId:
description: 仿真id description: 仿真id
type: string type: string
@ -361,6 +367,9 @@ definitions:
type: array type: array
projectId: projectId:
type: integer type: integer
runConfigId:
description: 运行环境ID
type: integer
simulationId: simulationId:
type: string type: string
type: object type: object
@ -596,19 +605,13 @@ definitions:
enum: enum:
- 0 - 0
- 1 - 1
- 2
- 3
type: integer type: integer
x-enum-comments: x-enum-comments:
Section_Drst: 设置计轴直接复位 Section_Drst: 设置计轴直接复位
Section_Pdrst: 设置计轴预复位 Section_Pdrst: 设置计轴预复位
Section_TrainIn: 设置计轴区段内有车轴
Section_TrainOut: 设置计轴区段内没有车轴
x-enum-varnames: x-enum-varnames:
- Section_Drst - Section_Drst
- Section_Pdrst - Section_Pdrst
- Section_TrainIn
- Section_TrainOut
request_proto.Signal_Operation: request_proto.Signal_Operation:
enum: enum:
- 0 - 0
@ -2464,6 +2467,7 @@ paths:
parameters: parameters:
- in: query - in: query
name: config name: config
required: true
type: string type: string
- in: query - in: query
name: description name: description
@ -2473,6 +2477,7 @@ paths:
type: integer type: integer
- in: query - in: query
name: name name: name
required: true
type: string type: string
produces: produces:
- application/json - application/json
@ -2604,6 +2609,33 @@ paths:
summary: 修改项目运行环境信息 summary: 修改项目运行环境信息
tags: tags:
- 项目运行环境配置Api - 项目运行环境配置Api
/api/v1/runconfig/description:
get:
consumes:
- application/json
description: 获取项目运行环境信息结构说明
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 获取项目运行环境信息结构说明
tags:
- 项目运行环境配置Api
/api/v1/runconfig/list: /api/v1/runconfig/list:
get: get:
consumes: consumes:
@ -2869,33 +2901,6 @@ paths:
summary: ATS测试-ESB按钮操作 summary: ATS测试-ESB按钮操作
tags: tags:
- ATS测试仿真Api - ATS测试仿真Api
/api/v1/simulation/getDataChannelName:
get:
consumes:
- application/json
description: 获取仿真信息更新通道名称
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 获取仿真信息更新通道名称
tags:
- ATS测试仿真Api
/api/v1/simulation/ibp/btn/operation: /api/v1/simulation/ibp/btn/operation:
post: post:
consumes: consumes:

View File

@ -23,6 +23,13 @@ type ProjectRunConfigDto struct {
UpdateAt JsonTime `json:"updateAt" time_format:"2006-01-02 15:04:05"` UpdateAt JsonTime `json:"updateAt" time_format:"2006-01-02 15:04:05"`
} }
type RunConfigDescription struct {
FieldName string `json:"fieldName" form:"fieldName"`
Description string `json:"description" form:"description"`
Type string `json:"type" form:"type"`
ItemTypeFields []*RunConfigDescription `json:"itemTypeFields" form:"itemTypeFields"`
}
func ConvertToRunConfigDto(gi *model.ProjectRunConfig) *ProjectRunConfigDto { func ConvertToRunConfigDto(gi *model.ProjectRunConfig) *ProjectRunConfigDto {
return &ProjectRunConfigDto{ return &ProjectRunConfigDto{
Id: gi.ID, Id: gi.ID,