【抛出异常的格式修改】

This commit is contained in:
weizhihong 2023-08-30 18:05:11 +08:00
parent ad88f64f7e
commit 35e2933a44
24 changed files with 1588 additions and 1350 deletions

View File

@ -49,13 +49,11 @@ func InitAuthRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware)
func pageQueryRole(c *gin.Context) {
req := dto.PageQueryDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("分页查询参数绑定错误,使用默认参数", err)
req.Default()
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
page, err := service.PageAuthRoleQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -99,8 +97,7 @@ func listQueryRole(c *gin.Context) {
func createRole(c *gin.Context) {
req := dto.AuthRoleReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
c.JSON(http.StatusOK, service.CreateAuthRole(&req))
@ -125,8 +122,7 @@ func createRole(c *gin.Context) {
func queryRoleInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -153,14 +149,12 @@ func queryRoleInfo(c *gin.Context) {
func updateRoleInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.AuthRoleReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
rid := int32(int64Id)
@ -190,8 +184,7 @@ func updateRoleInfo(c *gin.Context) {
func deleteRoleInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -222,13 +215,11 @@ func deleteRoleInfo(c *gin.Context) {
func pageQueryApiPath(c *gin.Context) {
req := dto.AuthApiPathPageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("分页查询参数绑定错误,使用默认参数", err)
req.Default()
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
page, err := service.PageAuthApiPathQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -271,8 +262,7 @@ func listQueryApiPath(c *gin.Context) {
func createApiPath(c *gin.Context) {
req := dto.AuthApiPathReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
c.JSON(http.StatusOK, service.CreateAuthApiPath(&req))
@ -297,8 +287,7 @@ func createApiPath(c *gin.Context) {
func queryApiPathInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -325,14 +314,11 @@ func queryApiPathInfo(c *gin.Context) {
func updateApiPathInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.AuthApiPathReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.UpdateAuthApiPath(int32(int64Id), &req))
@ -357,8 +343,7 @@ func updateApiPathInfo(c *gin.Context) {
func deleteApiPathInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -384,8 +369,7 @@ func deleteApiPathInfo(c *gin.Context) {
func assignRoleToUser(c *gin.Context) {
req := dto.AuthRoleUserReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
result := service.UserLinkRole(&req)
if result {

View File

@ -43,14 +43,12 @@ func pageQueryCategory(c *gin.Context) {
zap.S().Debug("分页查询厂家", user)
req := dto.PageCategoryReqDto{}
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.PageCategoryQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -74,13 +72,12 @@ func pageQueryCategory(c *gin.Context) {
func listQueryCategory(c *gin.Context) {
req := dto.CategoryReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("查厂家参数", req)
page, err := service.ListCategoryQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -104,14 +101,12 @@ func listQueryCategory(c *gin.Context) {
func createCategory(c *gin.Context) {
req := dto.CategoryDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "传入参数错误"})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateCategory(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -135,8 +130,7 @@ func createCategory(c *gin.Context) {
func queryCategoryInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -163,20 +157,17 @@ func queryCategoryInfo(c *gin.Context) {
func updateCategoryInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.CategoryDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateCategory(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存参数出错"})
}
c.JSON(http.StatusOK, result)
}
@ -203,8 +194,7 @@ func deleteCategory(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("id查询草稿的图形数据", id)
service.DeleteCategoryById(id)

View File

@ -44,14 +44,12 @@ func pageQueryDrafting(c *gin.Context) {
zap.S().Debug("分页查询草稿", user)
req := dto.PageDraftingReqDto{}
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.PageDraftingQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -77,14 +75,12 @@ func createDrafting(c *gin.Context) {
createId := user.(*model.User).ID
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateDrafting(createId, &req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -109,22 +105,19 @@ func createDrafting(c *gin.Context) {
func saveAsDrafting(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
user, _ := c.Get(middleware.IdentityKey)
createrId := user.(*model.User).ID
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
newData, err := service.SaveAsDrafting(createrId, int32(int64Id), &req)
if err != nil {
c.JSON(http.StatusInternalServerError, "保存数据出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, newData)
}
@ -148,8 +141,7 @@ func saveAsDrafting(c *gin.Context) {
func queryDraftingInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -176,20 +168,17 @@ func queryDraftingInfo(c *gin.Context) {
func updateDraftingInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.DraftingDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateDrafting(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存出错"})
}
c.JSON(http.StatusOK, result)
}
@ -216,8 +205,7 @@ func deleteDrafting(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("id查询草稿的图形数据", id)
service.DeleteDraftingById(id)

View File

@ -5,7 +5,7 @@ import (
jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin"
"github.com/golang/protobuf/proto"
"google.golang.org/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"
@ -36,8 +36,7 @@ func InitGenerateGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
func generateCalculateLinkData(c *gin.Context) {
req := dto.DraftingMapDataDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "参数获取出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
gd := &graphicData.RtssGraphicStorage{}
proto.Unmarshal(req.Proto, gd)

View File

@ -41,14 +41,12 @@ func InitProjectRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar
func pageQueryProject(c *gin.Context) {
req := dto.PageProjectReqDto{}
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.PageProjectQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -72,13 +70,12 @@ func pageQueryProject(c *gin.Context) {
func listQueryProject(c *gin.Context) {
req := dto.ProjectReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("查项目参数", req)
page, err := service.ListProjectQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -102,14 +99,12 @@ func listQueryProject(c *gin.Context) {
func createProject(c *gin.Context) {
req := dto.ProjectDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateProject(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -133,8 +128,7 @@ func createProject(c *gin.Context) {
func queryProjectInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -161,20 +155,16 @@ func queryProjectInfo(c *gin.Context) {
func updateProjectInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.ProjectDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateProject(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存出错"})
}
c.JSON(http.StatusOK, result)
}
@ -196,13 +186,10 @@ func updateProjectInfo(c *gin.Context) {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/project/{id} [delete]
func deleteProject(c *gin.Context) {
user, _ := c.Get(middleware.IdentityKey)
zap.S().Debug("id删除草稿的图形数据", user)
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("id查询草稿的图形数据", id)
service.DeleteProjectById(id)

View File

@ -39,8 +39,7 @@ func InitProjectLinkRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
func queryProjectLinkInfo(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -66,8 +65,7 @@ func queryProjectLinkInfo(c *gin.Context) {
func queryTrainSizeByMapId(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -93,8 +91,7 @@ func queryTrainSizeByMapId(c *gin.Context) {
func queryTrainSizeByPId(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
@ -121,10 +118,8 @@ func queryTrainSizeByPId(c *gin.Context) {
func saveProjectLinkInfo(c *gin.Context) {
req := dto.ProjectLinkReqDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
service.UpdateProjectLink(&req)
c.JSON(http.StatusOK, true)
}

View File

@ -104,7 +104,7 @@ func getPublishedGiById(c *gin.Context) {
zap.S().Debug("id查询发布的图形数据", id)
entity, err := service.GetPublishedGiById(id)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, entity)
}

View File

@ -63,9 +63,12 @@ func initPublishMapInfo() {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/create [post]
func create(c *gin.Context) {
if simulation.IsExistSimulation() {
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
}
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("创建仿真请求:", req)
rsp := dto.SimulationCreateRspDto{
@ -91,9 +94,12 @@ func create(c *gin.Context) {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/createByProject [post]
func createByProjectId(c *gin.Context) {
if simulation.IsExistSimulation() {
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
}
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("创建仿真请求:", req)
rsp := dto.SimulationCreateRspDto{
@ -104,6 +110,7 @@ func createByProjectId(c *gin.Context) {
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: "项目未关联地图"})
}
mapInfo := mapInfos[0]
rsp.MapId = mapInfo.ID
rsp.SimulationId = simulation.CreateSimulation(mapInfo.ID, req.ProjectId)
c.JSON(http.StatusOK, &rsp)
}
@ -167,8 +174,6 @@ func destroy(c *gin.Context) {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/list [get]
func findAllSimulations(c *gin.Context) {
zap.S().Debug("ATS测试仿真-获取ATS测试系统所有仿真实例的基本信息,请求")
//TODO 后续调用
c.JSON(http.StatusOK, simulation.ListAllSimulations())
}
@ -191,7 +196,7 @@ func findAllSimulations(c *gin.Context) {
func checkSimMapData(c *gin.Context) {
rt := &dto.CheckMapDataReqDto{}
if err := c.ShouldBind(&rt); nil != err {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
err := proto.Unmarshal(rt.Data, &graphicData.RtssGraphicStorage{})
if err != nil {
@ -219,9 +224,8 @@ func checkSimMapData(c *gin.Context) {
func addTrain(c *gin.Context) {
req := dto.AddTrainReqDto{}
if err := c.ShouldBind(&req); err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("ATS测试仿真-添加列车,请求:", req)
simulation := checkDeviceDataAndReturn(req.SimulationId)
id := getAddTrainPrimaryKey(simulation)
if id == -1 {
@ -259,7 +263,7 @@ func addTrain(c *gin.Context) {
func removeTrain(c *gin.Context) {
rt := &dto.RemoveTrainDto{}
if err := c.ShouldBind(&rt); err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("ATS测试仿真-移除列车,请求:", rt)
simulation := checkDeviceDataAndReturn(rt.SimulationId)
@ -287,7 +291,7 @@ func removeTrain(c *gin.Context) {
func switchOperation(c *gin.Context) {
req := &dto.SwitchOperationReqDto{}
if err := c.ShouldBind(&req); err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
zap.S().Info("传入状态参数", req)

View File

@ -7,7 +7,6 @@ import (
jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/middleware"
"joylink.club/bj-rtsts-server/service"
@ -54,14 +53,11 @@ func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
func pageQueryTrainModel(c *gin.Context) {
req := dto.PageTrainManageReqDto{}
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.PageTrainModelQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -85,14 +81,11 @@ func pageQueryTrainModel(c *gin.Context) {
func createTrainModel(c *gin.Context) {
req := dto.TrainModelDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateTrainModel(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -116,10 +109,8 @@ func createTrainModel(c *gin.Context) {
func queryTrainModel(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.QueryTrainModel(int32(int64Id)))
}
@ -144,20 +135,16 @@ func queryTrainModel(c *gin.Context) {
func updateTrainModel(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.TrainModelDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateTrainModel(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存参数出错"})
}
c.JSON(http.StatusOK, result)
}
@ -182,10 +169,8 @@ func deleteTrainModel(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("id查询列车型号的图形数据", id)
service.DeleteTrainModelById(id)
c.JSON(http.StatusOK, true)
}
@ -209,13 +194,11 @@ func deleteTrainModel(c *gin.Context) {
func queryTrainModelList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("分页查列车信号参数", req)
models, err := service.ListTrainModelQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, models)
}
@ -239,14 +222,11 @@ func queryTrainModelList(c *gin.Context) {
func pageQueryTrainSize(c *gin.Context) {
req := dto.PageTrainManageReqDto{}
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.PageTrainSizeQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -270,13 +250,11 @@ func pageQueryTrainSize(c *gin.Context) {
func queryTrainSizeList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("分页查列车尺寸参数", req)
sizeList, err := service.ListTrainSizeQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, sizeList)
}
@ -300,14 +278,11 @@ func queryTrainSizeList(c *gin.Context) {
func createTrainSize(c *gin.Context) {
req := dto.TrainSizeDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateTrainSize(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -331,10 +306,8 @@ func createTrainSize(c *gin.Context) {
func queryTrainSize(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.QueryTrainSize(int32(int64Id)))
}
@ -359,20 +332,16 @@ func queryTrainSize(c *gin.Context) {
func updateTrainSize(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.TrainSizeDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateTrainSize(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存出错"})
}
c.JSON(http.StatusOK, result)
}
@ -397,10 +366,8 @@ func deleteTrainSize(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("id查询列车型号的图形数据", id)
service.DeleteTrainSizeById(id)
c.JSON(http.StatusOK, true)
}
@ -424,14 +391,11 @@ func deleteTrainSize(c *gin.Context) {
func pageQueryTrainWheelDiameter(c *gin.Context) {
req := dto.PageTrainManageReqDto{}
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.PageTrainWheelDiameterQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, page)
}
@ -455,13 +419,11 @@ func pageQueryTrainWheelDiameter(c *gin.Context) {
func queryTrainWheelDiameterList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("分页查列车轮径参数", req)
wheels, err := service.ListTrainWheelDiameterQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, wheels)
}
@ -485,14 +447,11 @@ func queryTrainWheelDiameterList(c *gin.Context) {
func createTrainWheelDiameter(c *gin.Context) {
req := dto.TrainWheelDiameterDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "传入参数错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
zap.S().Debug("保存数据", req)
data, err := service.CreateTrainWheelDiameter(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
c.JSON(http.StatusOK, data)
}
@ -516,10 +475,8 @@ func createTrainWheelDiameter(c *gin.Context) {
func queryTrainWheelDiameter(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.QueryTrainWheelDiameter(int32(int64Id)))
}
@ -544,20 +501,16 @@ func queryTrainWheelDiameter(c *gin.Context) {
func updateTrainWheelDiameter(c *gin.Context) {
id, exist := c.Params.Get("id")
if !exist {
c.JSON(http.StatusBadRequest, "必要参数id不存在")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("传入参数id为" + id)
req := dto.TrainWheelDiameterDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
result := service.UpdateTrainWheelDiameter(int32(int64Id), &req)
if !result {
c.JSON(http.StatusInternalServerError, "保存参数出错")
return
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: "保存出错"})
}
c.JSON(http.StatusOK, result)
}
@ -582,10 +535,8 @@ func deleteTrainWheelDiameter(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
c.JSON(http.StatusBadRequest, "id参数解析错误")
return
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "必要参数id不存在"})
}
zap.S().Debug("id查询列车型号的图形数据", id)
service.DeleteTrainWheelDiameterById(id)
c.JSON(http.StatusOK, true)
}

View File

@ -24,7 +24,7 @@ var simulationId_prefix = (func() string {
ip := "127.0.0.1"
addrList, err := net.InterfaceAddrs()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
for _, address := range addrList {
if ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
@ -48,7 +48,7 @@ func init() {
// 拼接列车ID
trainId, err := strconv.Atoi(train.Id)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
trainInfo := decoderVobcTrainState(info)
zap.S().Info("接收到vobc发送的列车消息", trainInfo)
@ -81,6 +81,16 @@ func init() {
// 仿真存储集合
var simulationMap sync.Map
// 创建前检查
func IsExistSimulation() bool {
i := 0
simulationMap.Range(func(_, _ any) bool {
i++
return true
})
return i > 0
}
// 创建仿真对象
func CreateSimulation(mapId, projectId int32) string {
simulationId := createSimulationId(mapId)

View File

@ -16,368 +16,6 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/Project": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建项目数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "创建项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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/Project/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,查询项目信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息列表",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/Project/paging": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,分页查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "分页查询项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/Project/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息",
"parameters": [
{
"type": "integer",
"description": "项目ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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"
}
}
}
},
"put": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "修改项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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"
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "删除项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
}
],
"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/auth/path": {
"post": {
"security": [
@ -1331,12 +969,14 @@ const docTemplate = `{
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1542,12 +1182,14 @@ const docTemplate = `{
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1681,12 +1323,14 @@ const docTemplate = `{
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1771,6 +1415,368 @@ const docTemplate = `{
}
}
},
"/api/v1/project": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建项目数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "创建项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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/project/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,查询项目信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息列表",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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/project/paging": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,分页查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "分页查询项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/project/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息",
"parameters": [
{
"type": "integer",
"description": "项目ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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"
}
}
}
},
"put": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "修改项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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"
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "删除项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
}
],
"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/projectLink": {
"post": {
"security": [
@ -2613,7 +2619,7 @@ const docTemplate = `{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "地图数据校验",
"consumes": [
"application/json"
],
@ -2665,7 +2671,7 @@ const docTemplate = `{
"JwtAuth": []
}
],
"description": "创建并进入仿真后获取仿真的设备信息",
"description": "创建ATS测试仿真",
"consumes": [
"application/json"
],
@ -2675,7 +2681,59 @@ const docTemplate = `{
"tags": [
"ATS测试仿真Api"
],
"summary": "创建并进入仿真后获取仿真的设备信息",
"summary": "创建ATS测试仿真",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "创建仿真请求",
"name": "SimulationCreateReqDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SimulationCreateReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.SimulationCreateRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/createByProject": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建ATS测试仿真通过项目ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "创建ATS测试仿真",
"parameters": [
{
"type": "string",
@ -2767,7 +2825,7 @@ const docTemplate = `{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "获取ATS测试系统所有仿真实例的基本信息",
"consumes": [
"application/json"
],
@ -2793,7 +2851,7 @@ const docTemplate = `{
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.SimulationInfoRepDto"
"$ref": "#/definitions/dto.SimulationInfoRspDto"
}
}
},
@ -2806,6 +2864,56 @@ const docTemplate = `{
}
}
},
"/api/v1/simulation/state/:id": {
"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
},
{
"type": "integer",
"description": "仿真id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.SimulationCreateRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/switch/operation": {
"post": {
"security": [
@ -2813,7 +2921,7 @@ const docTemplate = `{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "ATS测试-操作道岔",
"consumes": [
"application/json"
],
@ -4524,6 +4632,10 @@ const docTemplate = `{
"mapId": {
"description": "地图id",
"type": "integer"
},
"projectId": {
"description": "项目id",
"type": "integer"
}
}
},
@ -4534,17 +4646,24 @@ const docTemplate = `{
"description": "地图id",
"type": "integer"
},
"projectId": {
"description": "项目ID",
"type": "integer"
},
"simulationId": {
"description": "仿真id",
"type": "string"
}
}
},
"dto.SimulationInfoRepDto": {
"dto.SimulationInfoRspDto": {
"type": "object",
"properties": {
"mapId": {
"type": "string"
"type": "integer"
},
"projectId": {
"type": "integer"
},
"simulationId": {
"type": "string"
@ -4610,11 +4729,13 @@ const docTemplate = `{
"type": "integer",
"enum": [
0,
1
1,
2
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
]
},
"model.AuthAPIPath": {

View File

@ -9,368 +9,6 @@
"host": "localhost:9091",
"basePath": "/",
"paths": {
"/api/v1/Project": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建项目数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "创建项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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/Project/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,查询项目信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息列表",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/Project/paging": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,分页查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "分页查询项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/Project/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息",
"parameters": [
{
"type": "integer",
"description": "项目ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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"
}
}
}
},
"put": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "修改项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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"
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "删除项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
}
],
"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/auth/path": {
"post": {
"security": [
@ -1324,12 +962,14 @@
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1535,12 +1175,14 @@
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1674,12 +1316,14 @@
{
"enum": [
0,
1
1,
2
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
],
"name": "type",
"in": "query"
@ -1764,6 +1408,368 @@
}
}
},
"/api/v1/project": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建项目数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "创建项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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/project/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,查询项目信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息列表",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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/project/paging": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过项目名称过滤,分页查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "分页查询项目信息",
"parameters": [
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"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/project/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "查询项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "查询项目信息",
"parameters": [
{
"type": "integer",
"description": "项目ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Project"
}
},
"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"
}
}
}
},
"put": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "修改项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"name": "code",
"in": "query"
},
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
}
],
"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"
}
}
}
},
"delete": {
"security": [
{
"JwtAuth": []
}
],
"description": "删除项目信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目信息Api"
],
"summary": "删除项目信息",
"parameters": [
{
"type": "integer",
"description": "项目信息ID",
"name": "id",
"in": "path",
"required": true
}
],
"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/projectLink": {
"post": {
"security": [
@ -2606,7 +2612,7 @@
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "地图数据校验",
"consumes": [
"application/json"
],
@ -2658,7 +2664,7 @@
"JwtAuth": []
}
],
"description": "创建并进入仿真后获取仿真的设备信息",
"description": "创建ATS测试仿真",
"consumes": [
"application/json"
],
@ -2668,7 +2674,59 @@
"tags": [
"ATS测试仿真Api"
],
"summary": "创建并进入仿真后获取仿真的设备信息",
"summary": "创建ATS测试仿真",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "创建仿真请求",
"name": "SimulationCreateReqDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SimulationCreateReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.SimulationCreateRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/createByProject": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "创建ATS测试仿真通过项目ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "创建ATS测试仿真",
"parameters": [
{
"type": "string",
@ -2760,7 +2818,7 @@
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "获取ATS测试系统所有仿真实例的基本信息",
"consumes": [
"application/json"
],
@ -2786,7 +2844,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.SimulationInfoRepDto"
"$ref": "#/definitions/dto.SimulationInfoRspDto"
}
}
},
@ -2799,6 +2857,56 @@
}
}
},
"/api/v1/simulation/state/:id": {
"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
},
{
"type": "integer",
"description": "仿真id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.SimulationCreateRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/switch/operation": {
"post": {
"security": [
@ -2806,7 +2914,7 @@
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"description": "ATS测试-操作道岔",
"consumes": [
"application/json"
],
@ -4517,6 +4625,10 @@
"mapId": {
"description": "地图id",
"type": "integer"
},
"projectId": {
"description": "项目id",
"type": "integer"
}
}
},
@ -4527,17 +4639,24 @@
"description": "地图id",
"type": "integer"
},
"projectId": {
"description": "项目ID",
"type": "integer"
},
"simulationId": {
"description": "仿真id",
"type": "string"
}
}
},
"dto.SimulationInfoRepDto": {
"dto.SimulationInfoRspDto": {
"type": "object",
"properties": {
"mapId": {
"type": "string"
"type": "integer"
},
"projectId": {
"type": "integer"
},
"simulationId": {
"type": "string"
@ -4603,11 +4722,13 @@
"type": "integer",
"enum": [
0,
1
1,
2
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
"PictureType_Psl",
"PictureType_RelayCabinetLayout"
]
},
"model.AuthAPIPath": {

View File

@ -179,20 +179,28 @@ definitions:
mapId:
description: 地图id
type: integer
projectId:
description: 项目id
type: integer
type: object
dto.SimulationCreateRspDto:
properties:
mapId:
description: 地图id
type: integer
projectId:
description: 项目ID
type: integer
simulationId:
description: 仿真id
type: string
type: object
dto.SimulationInfoRepDto:
dto.SimulationInfoRspDto:
properties:
mapId:
type: string
type: integer
projectId:
type: integer
simulationId:
type: string
type: object
@ -236,10 +244,12 @@ definitions:
enum:
- 0
- 1
- 2
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
model.AuthAPIPath:
properties:
id:
@ -414,235 +424,6 @@ info:
title: CBTC测试系统API
version: "1.0"
paths:
/api/v1/Project:
post:
consumes:
- application/json
description: 创建项目数据
parameters:
- in: query
name: code
type: string
- in: query
name: id
type: integer
- in: query
name: name
type: string
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/Project/{id}:
delete:
consumes:
- application/json
description: 删除项目信息
parameters:
- description: 项目信息ID
in: path
name: id
required: true
type: integer
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
get:
consumes:
- application/json
description: 查询项目信息
parameters:
- description: 项目ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.Project'
"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
put:
consumes:
- application/json
description: 修改项目信息
parameters:
- description: 项目信息ID
in: path
name: id
required: true
type: integer
- in: query
name: code
type: string
- in: query
name: id
type: integer
- in: query
name: name
type: string
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/Project/list:
get:
consumes:
- application/json
description: 可以通过项目名称过滤,查询项目信息列表
parameters:
- in: query
name: code
type: string
- in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"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/Project/paging:
get:
consumes:
- application/json
description: 可以通过项目名称过滤,分页查询项目信息
parameters:
- in: query
name: code
type: string
- in: query
name: name
type: string
- description: 页码
example: 1
in: query
name: current
required: true
type: integer
- description: 页面行数
example: 10
in: query
name: size
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"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/auth/path:
post:
consumes:
@ -1243,12 +1024,14 @@ paths:
- enum:
- 0
- 1
- 2
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
produces:
- application/json
responses:
@ -1366,12 +1149,14 @@ paths:
- enum:
- 0
- 1
- 2
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
produces:
- application/json
responses:
@ -1423,12 +1208,14 @@ paths:
- enum:
- 0
- 1
- 2
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
produces:
- application/json
responses:
@ -1530,6 +1317,235 @@ paths:
summary: 根据地图数据新生成计算的link信息
tags:
- GenerateApi
/api/v1/project:
post:
consumes:
- application/json
description: 创建项目数据
parameters:
- in: query
name: code
type: string
- in: query
name: id
type: integer
- in: query
name: name
type: string
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/project/{id}:
delete:
consumes:
- application/json
description: 删除项目信息
parameters:
- description: 项目信息ID
in: path
name: id
required: true
type: integer
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
get:
consumes:
- application/json
description: 查询项目信息
parameters:
- description: 项目ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.Project'
"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
put:
consumes:
- application/json
description: 修改项目信息
parameters:
- description: 项目信息ID
in: path
name: id
required: true
type: integer
- in: query
name: code
type: string
- in: query
name: id
type: integer
- in: query
name: name
type: string
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/project/list:
get:
consumes:
- application/json
description: 可以通过项目名称过滤,查询项目信息列表
parameters:
- in: query
name: code
type: string
- in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.Project'
"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/project/paging:
get:
consumes:
- application/json
description: 可以通过项目名称过滤,分页查询项目信息
parameters:
- in: query
name: code
type: string
- in: query
name: name
type: string
- description: 页码
example: 1
in: query
name: current
required: true
type: integer
- description: 页面行数
example: 10
in: query
name: size
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"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/projectLink:
post:
consumes:
@ -2064,7 +2080,7 @@ paths:
post:
consumes:
- application/json
description: ATS测试仿真-添加列车
description: 地图数据校验
parameters:
- description: JWT Token
in: header
@ -2097,7 +2113,7 @@ paths:
post:
consumes:
- application/json
description: 创建并进入仿真后获取仿真的设备信息
description: 创建ATS测试仿真
parameters:
- description: JWT Token
in: header
@ -2123,7 +2139,40 @@ paths:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 创建并进入仿真后获取仿真的设备信息
summary: 创建ATS测试仿真
tags:
- ATS测试仿真Api
/api/v1/simulation/createByProject:
post:
consumes:
- application/json
description: 创建ATS测试仿真通过项目ID
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: 创建仿真请求
in: body
name: SimulationCreateReqDto
required: true
schema:
$ref: '#/definitions/dto.SimulationCreateReqDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.SimulationCreateRspDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 创建ATS测试仿真
tags:
- ATS测试仿真Api
/api/v1/simulation/destroy/{id}:
@ -2162,7 +2211,7 @@ paths:
get:
consumes:
- application/json
description: ATS测试仿真-添加列车
description: 获取ATS测试系统所有仿真实例的基本信息
parameters:
- description: JWT Token
in: header
@ -2176,7 +2225,7 @@ paths:
description: OK
schema:
items:
$ref: '#/definitions/dto.SimulationInfoRepDto'
$ref: '#/definitions/dto.SimulationInfoRspDto'
type: array
"500":
description: Internal Server Error
@ -2187,11 +2236,43 @@ paths:
summary: 获取ATS测试系统所有仿真实例的基本信息
tags:
- ATS测试仿真Api
/api/v1/simulation/state/:id:
get:
consumes:
- application/json
description: 创建并进入仿真后获取仿真的设备信息
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:
$ref: '#/definitions/dto.SimulationCreateRspDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 创建并进入仿真后获取仿真的设备信息
tags:
- ATS测试仿真Api
/api/v1/simulation/switch/operation:
post:
consumes:
- application/json
description: ATS测试仿真-添加列车
description: ATS测试-操作道岔
parameters:
- description: JWT Token
in: header

View File

@ -14,4 +14,6 @@ const (
ArgumentParseError = 3000
NoAuthOperationError = 4001
QueryDBError = 5000
)

View File

@ -6,6 +6,7 @@ import (
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/bj-rtsts-server/ats/verify/simulation"
"joylink.club/bj-rtsts-server/dto"
)
type MemoryChangeServer struct {
@ -33,7 +34,7 @@ func (t *MemoryChangeServer) allMsgData(params map[string]string) []byte {
msg := &state.MemoryDataStatus{AllSimulations: arr}
data, err := proto.Marshal(msg)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
return data
}
@ -60,11 +61,14 @@ func (t *MemoryChangeServer) onTick() []TopicMsg {
delArr = append(delArr, v)
}
}
if len(addArr) == 0 && len(delArr) == 0 {
return []TopicMsg{}
} else {
msg := &state.MemoryDataStatus{AddSimulations: addArr, RemoveSimulations: delArr}
b, err := proto.Marshal(msg)
if err != nil {
panic(err)
}
msgArr := []TopicMsg{{channalName: t.getChannelName(), data: b}}
return msgArr
return []TopicMsg{{channalName: t.getChannelName(), data: b}}
}
}

View File

@ -6,6 +6,7 @@ import (
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/simulation"
"joylink.club/bj-rtsts-server/dto"
)
type SimulationServer struct{}
@ -32,7 +33,7 @@ func (t *SimulationServer) allMsgData(params map[string]string) []byte {
}
data, err := proto.Marshal(simulation.GetAllState())
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
return data
}
@ -45,7 +46,7 @@ func (t *SimulationServer) onTick() []TopicMsg {
channelName := handlerChannelName(v.SimulationId, t.getChannelName())
b, err := proto.Marshal(v.GetAllState())
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
}
msgArr[i] = TopicMsg{
channalName: channelName,

View File

@ -23,7 +23,6 @@ func permissionMiddleware() gin.HandlerFunc {
c.Next()
} else {
uid := user.(*model.User).ID
zap.S().Debugf("获取用户ID:%d", uid)
userAuth := userAuthPathMap[uid]
if userAuth == nil {
userAuthPathMap[uid] = service.QueryUserAuthApiPath(uid)

View File

@ -18,7 +18,7 @@ func PageCategoryQuery(query *dto.PageCategoryReqDto) (*dto.PageDto, error) {
}
records, total, err := dq.Debug().Select(d.ID, d.Code, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
@ -32,60 +32,60 @@ func ListCategoryQuery(query *dto.CategoryReqDto) ([]*model.Category, error) {
}
records, err := dq.Debug().Select(d.ID, d.Code, d.Name, d.UpdateAt, d.CreatedAt).Find()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return records, nil
}
// 创建草稿
func CreateCategory(dto *dto.CategoryDto) (*model.Category, error) {
if err := checkCategoryInfo(dto.Name, dto.Code, 0); err != nil {
panic(err)
func CreateCategory(cd *dto.CategoryDto) (*model.Category, error) {
if err := checkCategoryInfo(cd.Name, cd.Code, 0); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
d := model.Category{
Name: dto.Name,
Code: dto.Code,
Config: dto.Config,
Name: cd.Name,
Code: cd.Code,
Config: cd.Config,
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
err := dbquery.Category.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dbquery.Category.Where(dbquery.Category.Name.Eq(dto.Name)).Order(dbquery.Category.CreatedAt).Debug().First()
return dbquery.Category.Where(dbquery.Category.Name.Eq(cd.Name)).Order(dbquery.Category.CreatedAt).Debug().First()
}
func QueryCategory(id int32) *model.Category {
data, err := dbquery.Category.Where(dbquery.Category.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
func UpdateCategory(id int32, dto *dto.CategoryDto) bool {
if err := checkCategoryInfo(dto.Name, dto.Code, id); err != nil {
panic(err)
func UpdateCategory(id int32, cd *dto.CategoryDto) bool {
if err := checkCategoryInfo(cd.Name, cd.Code, id); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
findOldQuery := dbquery.Category
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if dto.Code != "" {
oldD.Code = dto.Code
if cd.Code != "" {
oldD.Code = cd.Code
}
if dto.Config != "" {
oldD.Config = dto.Config
if cd.Config != "" {
oldD.Config = cd.Config
}
if len(dto.Name) > 0 {
oldD.Name = dto.Name
if len(cd.Name) > 0 {
oldD.Name = cd.Name
}
oldD.UpdateAt = time.Now()
_, error := dbquery.Category.Updates(oldD)
if error != nil {
panic(error)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return true
}
@ -103,19 +103,19 @@ func checkCategoryInfo(name string, code string, id int32) error {
if name != "" {
count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if count > 0 {
panic("名称已存在")
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "名称已存在"})
}
}
if code != "" {
count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if count > 0 {
panic("编码已存在")
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "编码已存在"})
}
}
return nil

View File

@ -18,46 +18,46 @@ func PageDraftingQuery(query *dto.PageDraftingReqDto) (*dto.PageDto, error) {
}
records, total, err := dq.Debug().Omit(d.Proto).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
// 创建草稿
func CreateDrafting(createId int32, dto *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dto.Name); err != nil {
panic(err)
func CreateDrafting(createId int32, dd *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dd.Name); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
d := model.Drafting{
Name: dto.Name,
Category: dto.Category,
Type: int32(dto.Type),
Proto: dto.Proto,
Name: dd.Name,
Category: dd.Category,
Type: int32(dd.Type),
Proto: dd.Proto,
CreatorID: createId,
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
err := dbquery.Drafting.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dbquery.Drafting.Where(
dbquery.Drafting.Name.Eq(dto.Name),
dbquery.Drafting.Name.Eq(dd.Name),
dbquery.Drafting.CreatorID.Eq(createId),
).Order(dbquery.Drafting.CreatedAt).Debug().First()
}
// 另存为
func SaveAsDrafting(createId int32, oldId int32, dto *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dto.Name); err != nil {
func SaveAsDrafting(createId int32, oldId int32, dd *dto.DraftingDto) (*model.Drafting, error) {
if err := checkDraftingInfo(dd.Name); err != nil {
return nil, err
}
oldD, err := dbquery.Drafting.Where(dbquery.Drafting.ID.Eq(oldId)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
newD := model.Drafting{
Name: dto.Name,
Name: dd.Name,
Proto: oldD.Proto,
CreatorID: createId,
CreatedAt: time.Now(),
@ -65,10 +65,10 @@ func SaveAsDrafting(createId int32, oldId int32, dto *dto.DraftingDto) (*model.D
Category: oldD.Category,
}
if err = dbquery.Drafting.Save(&newD); err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dbquery.Drafting.Where(
dbquery.Drafting.Name.Eq(dto.Name),
dbquery.Drafting.Name.Eq(dd.Name),
dbquery.Drafting.CreatorID.Eq(createId),
).Order(dbquery.Drafting.CreatedAt).Debug().First()
}
@ -77,27 +77,27 @@ func QueryDrafting(id int32) *model.Drafting {
query := dbquery.Drafting
data, err := query.Where(query.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
func UpdateDrafting(id int32, dto *dto.DraftingDto) bool {
func UpdateDrafting(id int32, dd *dto.DraftingDto) bool {
findOldQuery := dbquery.Drafting
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if dto.Proto != nil {
oldD.Proto = dto.Proto
if dd.Proto != nil {
oldD.Proto = dd.Proto
}
if len(dto.Name) > 0 {
oldD.Name = dto.Name
if len(dd.Name) > 0 {
oldD.Name = dd.Name
}
oldD.UpdateAt = time.Now()
_, err2 := dbquery.Drafting.Updates(oldD)
if err2 != nil {
panic(err2)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
}
return true
}
@ -110,10 +110,10 @@ func checkDraftingInfo(name string) error {
findNameQuery := dbquery.Drafting
count, err := findNameQuery.Where(findNameQuery.Name.Eq(name)).Debug().Count()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if count > 0 {
panic("名称已存在")
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "名称已存在"})
}
return err
}

View File

@ -21,7 +21,7 @@ func PageProjectQuery(query *dto.PageProjectReqDto) (*dto.PageDto, error) {
}
records, total, err := dq.Debug().Select(d.ID, d.Code, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
@ -38,57 +38,57 @@ func ListProjectQuery(query *dto.ProjectReqDto) ([]*model.Project, error) {
}
records, err := dq.Debug().Select(d.ID, d.Code, d.Name).Find()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return records, nil
}
// 创建草稿
func CreateProject(dto *dto.ProjectDto) (*model.Project, error) {
if err := checkProjectInfo(dto.Code, 0); err != nil {
panic(err)
func CreateProject(pd *dto.ProjectDto) (*model.Project, error) {
if err := checkProjectInfo(pd.Code, 0); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
d := model.Project{
Name: dto.Name,
Code: dto.Code,
Name: pd.Name,
Code: pd.Code,
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
p := dbquery.Project
err := p.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return p.Where(p.Name.Eq(dto.Name)).Order(p.CreatedAt).Debug().First()
return p.Where(p.Name.Eq(pd.Name)).Order(p.CreatedAt).Debug().First()
}
func QueryProject(id int32) *model.Project {
data, err := dbquery.Project.Where(dbquery.Project.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
func UpdateProject(id int32, dto *dto.ProjectDto) bool {
if err := checkProjectInfo(dto.Code, id); err != nil {
panic(err)
func UpdateProject(id int32, pd *dto.ProjectDto) bool {
if err := checkProjectInfo(pd.Code, id); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
findOldQuery := dbquery.Project
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if dto.Code != "" {
oldD.Code = dto.Code
if pd.Code != "" {
oldD.Code = pd.Code
}
if dto.Name != "" {
oldD.Name = dto.Name
if pd.Name != "" {
oldD.Name = pd.Name
}
oldD.UpdateAt = time.Now()
_, error := dbquery.Project.Updates(oldD)
if error != nil {
panic(error)
_, err2 := dbquery.Project.Updates(oldD)
if err2 != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
}
return true
}
@ -106,10 +106,10 @@ func checkProjectInfo(code string, id int32) error {
if code != "" {
count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if count > 0 {
panic("编码已存在")
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "编码已存在"})
}
}
return nil

View File

@ -24,7 +24,7 @@ func QueryProjectLinkInfo(id int32) *dto.ProjectLinkRspDto {
func QueryTrainSizeByMapId(mid int32) []*dto.TrainSizeDto {
pl, err := dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.Eq(mid)).First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(pl.Pid))
}

View File

@ -3,13 +3,14 @@ package service
import (
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/dto"
)
// 查询地图数据
func QueryRtssGraphicStorage(mapId int32) *graphicData.RtssGraphicStorage {
publishdata, err := GetPublishedGiById(int(mapId))
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
graphicStorage := &graphicData.RtssGraphicStorage{}
proto.Unmarshal(publishdata.Proto, graphicStorage)

View File

@ -18,7 +18,7 @@ func PageTrainModelQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto, error)
}
records, total, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
@ -32,27 +32,27 @@ func ListTrainModelQuery(query *dto.TrainManageReqDto) ([]*model.TrainModel, err
}
records, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).Find()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return records, nil
}
// 创建列车型号信息
func CreateTrainModel(dto *dto.TrainModelDto) (*model.TrainModel, error) {
if err := checkTrainModel(dto.Name, 0); err != nil {
panic(err)
func CreateTrainModel(td *dto.TrainModelDto) (*model.TrainModel, error) {
if err := checkTrainModel(td.Name, 0); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
d := model.TrainModel{
Name: dto.Name,
Name: td.Name,
CreatedAt: time.Now(),
UpdateAt: time.Now(),
}
dt := dbquery.TrainModel
err := dt.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.CreatedAt).Debug().First()
return dt.Where(dt.Name.Eq(td.Name)).Order(dt.CreatedAt).Debug().First()
}
// 查询列车型号信息
@ -60,28 +60,28 @@ func QueryTrainModel(id int32) *model.TrainModel {
dt := dbquery.TrainModel
data, err := dt.Where(dt.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
// 更新列车型号信息
func UpdateTrainModel(id int32, dto *dto.TrainModelDto) bool {
if err := checkTrainModel(dto.Name, id); err != nil {
panic(err)
func UpdateTrainModel(id int32, td *dto.TrainModelDto) bool {
if err := checkTrainModel(td.Name, id); err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
findOldQuery := dbquery.TrainModel
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if len(dto.Name) > 0 {
oldD.Name = dto.Name
if len(td.Name) > 0 {
oldD.Name = td.Name
}
oldD.UpdateAt = time.Now()
_, error := dbquery.TrainModel.Updates(oldD)
if error != nil {
panic(error)
_, err2 := dbquery.TrainModel.Updates(oldD)
if err2 != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
}
return true
}
@ -100,7 +100,7 @@ func PageTrainSizeQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto, error)
}
records, total, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.TotalLength, d.Description).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
@ -114,25 +114,25 @@ func ListTrainSizeQuery(query *dto.TrainManageReqDto) ([]*model.TrainSize, error
}
records, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.TotalLength, d.Description).Find()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return records, nil
}
// 创建列车尺寸信息
func CreateTrainSize(dto *dto.TrainSizeDto) (*model.TrainSize, error) {
func CreateTrainSize(td *dto.TrainSizeDto) (*model.TrainSize, error) {
d := model.TrainSize{
Name: dto.Name,
CarriageLength: dto.CarriageLength,
TotalLength: dto.TotalLength,
Description: dto.Description,
Name: td.Name,
CarriageLength: td.CarriageLength,
TotalLength: td.TotalLength,
Description: td.Description,
}
dt := dbquery.TrainSize
err := dt.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.Name).Debug().First()
return dt.Where(dt.Name.Eq(td.Name)).Order(dt.Name).Debug().First()
}
// 查询列车尺寸信息
@ -140,25 +140,25 @@ func QueryTrainSize(id int32) *model.TrainSize {
dt := dbquery.TrainSize
data, err := dt.Where(dt.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
// 更新列车尺寸信息
func UpdateTrainSize(id int32, dto *dto.TrainSizeDto) bool {
func UpdateTrainSize(id int32, td *dto.TrainSizeDto) bool {
findOldQuery := dbquery.TrainSize
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
oldD.Name = dto.Name
oldD.CarriageLength = dto.CarriageLength
oldD.TotalLength = dto.TotalLength
oldD.Description = dto.Description
_, error := dbquery.TrainSize.Updates(oldD)
if error != nil {
panic(error)
oldD.Name = td.Name
oldD.CarriageLength = td.CarriageLength
oldD.TotalLength = td.TotalLength
oldD.Description = td.Description
_, err2 := dbquery.TrainSize.Updates(oldD)
if err2 != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
}
return true
}
@ -193,7 +193,7 @@ func PageTrainWheelDiameterQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto
}
records, total, err := dq.Debug().Select(d.ID, d.Name, d.Diameter, d.MinDiameter, d.MaxDiameter, d.AxialPosition, d.InstallDirection).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil
}
@ -207,27 +207,27 @@ func ListTrainWheelDiameterQuery(query *dto.TrainManageReqDto) ([]*model.TrainWh
}
records, err := dq.Debug().Select(d.ID, d.Name, d.Diameter, d.MinDiameter, d.MaxDiameter, d.AxialPosition, d.InstallDirection).Find()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return records, nil
}
// 创建列车轮径信息
func CreateTrainWheelDiameter(dto *dto.TrainWheelDiameterDto) (*model.TrainWheelDiameter, error) {
func CreateTrainWheelDiameter(twd *dto.TrainWheelDiameterDto) (*model.TrainWheelDiameter, error) {
d := model.TrainWheelDiameter{
Name: dto.Name,
Diameter: dto.Diameter,
MinDiameter: dto.MinDiameter,
MaxDiameter: dto.MaxDiameter,
AxialPosition: dto.AxialPosition,
InstallDirection: dto.InstallDirection,
Name: twd.Name,
Diameter: twd.Diameter,
MinDiameter: twd.MinDiameter,
MaxDiameter: twd.MaxDiameter,
AxialPosition: twd.AxialPosition,
InstallDirection: twd.InstallDirection,
}
dt := dbquery.TrainWheelDiameter
err := dt.Save(&d)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.Name).Debug().First()
return dt.Where(dt.Name.Eq(twd.Name)).Order(dt.Name).Debug().First()
}
// 查询列车轮径信息
@ -235,27 +235,27 @@ func QueryTrainWheelDiameter(id int32) *model.TrainWheelDiameter {
dt := dbquery.TrainWheelDiameter
data, err := dt.Where(dt.ID.Eq(id)).Debug().First()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return data
}
// 更新列车轮径信息
func UpdateTrainWheelDiameter(id int32, dto *dto.TrainWheelDiameterDto) bool {
func UpdateTrainWheelDiameter(id int32, twd *dto.TrainWheelDiameterDto) bool {
findOldQuery := dbquery.TrainWheelDiameter
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
if oldD == nil || err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
oldD.Name = dto.Name
oldD.Diameter = dto.Diameter
oldD.MinDiameter = dto.MinDiameter
oldD.MaxDiameter = dto.MaxDiameter
oldD.AxialPosition = dto.AxialPosition
oldD.InstallDirection = dto.InstallDirection
_, error := dbquery.TrainWheelDiameter.Updates(oldD)
if error != nil {
panic(error)
oldD.Name = twd.Name
oldD.Diameter = twd.Diameter
oldD.MinDiameter = twd.MinDiameter
oldD.MaxDiameter = twd.MaxDiameter
oldD.AxialPosition = twd.AxialPosition
oldD.InstallDirection = twd.InstallDirection
_, err2 := dbquery.TrainWheelDiameter.Updates(oldD)
if err2 != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
}
return true
}
@ -275,7 +275,7 @@ func checkTrainModel(name string, id int32) error {
if name != "" {
count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count()
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
if count > 0 {
panic("名称已存在")

View File

@ -22,7 +22,7 @@ func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto, error) {
}
records, total, err := uq.Debug().FindByPage(query.Offset(), query.Size)
if err != nil {
panic(err)
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: linkUserRole(records)}, err
}
@ -40,7 +40,7 @@ func Register(user *dto.RegisterUser) {
uq = uq.Where(u.Mobile.Eq(user.Mobile))
findCounter, _ := uq.Count()
if findCounter > 0 {
panic("重复的手机号")
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "重复的手机号"})
}
user.RegisterTime = time.Now()
u.Save(user)
@ -60,7 +60,7 @@ func FindUserInfo(userId int32) *dto.RegisterUser {
uq = uq.Where(u.ID.Eq(userId))
user, _ := uq.First()
if user == nil {
panic("没有获取到对应的用户信息")
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: "没有获取到对应的用户信息"})
}
return user
}