From 6b5e4c7cc3594e0e892ca48d2609566339462ee5 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 25 Aug 2023 10:41:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=A1=B9=E7=9B=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E3=80=81=E5=88=97=E8=BD=A6=E5=B0=BA=E5=AF=B8=E3=80=81=E5=88=97?= =?UTF-8?q?=E8=BD=A6=E8=BD=AE=E5=BE=84=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E3=80=91=20=E3=80=90=E5=8D=8A=E5=AE=9E=E7=89=A9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=A7=A3=E6=9E=90BUG=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/category.go | 2 +- api/project.go | 210 +++ api/projectLink.go | 100 ++ api/simulation.go | 2 +- api/trainManage.go | 497 ++++++ api/trainModel.go | 179 -- ats/verify/simulation/simulation_manage.go | 40 +- db/dbquery/gen.go | 118 +- db/dbquery/project.gen.go | 396 +++++ db/dbquery/project_publish_link.gen.go | 388 +++++ db/dbquery/project_train_size.gen.go | 388 +++++ db/dbquery/project_train_size_link.gen.go | 388 +++++ db/dbquery/train_model.gen.go | 16 +- db/dbquery/train_size.gen.go | 396 +++++ db/dbquery/train_wheel_diameter.gen.go | 408 +++++ db/model/project.gen.go | 25 + db/model/project_publish_link.gen.go | 19 + db/model/project_train_size.gen.go | 19 + db/model/project_train_size_link.gen.go | 19 + db/model/train_model.gen.go | 9 +- db/model/train_size.gen.go | 21 + db/model/train_wheel_diameter.gen.go | 27 + docs/docs.go | 1741 +++++++++++++++++++- docs/swagger.json | 1741 +++++++++++++++++++- docs/swagger.yaml | 1125 ++++++++++++- dto/project.go | 17 + dto/projectLink.go | 41 + dto/simulation.go | 6 +- dto/trainManage.go | 49 + dto/trainModel.go | 16 - main.go | 5 + service/project.go | 116 ++ service/projectLink.go | 70 + service/publishedGi.go | 16 + service/trainManage.go | 285 ++++ service/trainModel.go | 122 -- 36 files changed, 8549 insertions(+), 468 deletions(-) create mode 100644 api/project.go create mode 100644 api/projectLink.go create mode 100644 api/trainManage.go delete mode 100644 api/trainModel.go create mode 100644 db/dbquery/project.gen.go create mode 100644 db/dbquery/project_publish_link.gen.go create mode 100644 db/dbquery/project_train_size.gen.go create mode 100644 db/dbquery/project_train_size_link.gen.go create mode 100644 db/dbquery/train_size.gen.go create mode 100644 db/dbquery/train_wheel_diameter.gen.go create mode 100644 db/model/project.gen.go create mode 100644 db/model/project_publish_link.gen.go create mode 100644 db/model/project_train_size.gen.go create mode 100644 db/model/project_train_size_link.gen.go create mode 100644 db/model/train_size.gen.go create mode 100644 db/model/train_wheel_diameter.gen.go create mode 100644 dto/project.go create mode 100644 dto/projectLink.go create mode 100644 dto/trainManage.go delete mode 100644 dto/trainModel.go create mode 100644 service/project.go create mode 100644 service/projectLink.go create mode 100644 service/trainManage.go delete mode 100644 service/trainModel.go diff --git a/api/category.go b/api/category.go index ebd4ec3..ab99916 100644 --- a/api/category.go +++ b/api/category.go @@ -127,7 +127,7 @@ func createCategory(c *gin.Context) { // @Accept json // @Produce json // @Param id path int true "厂家ID" -// @Success 200 {object} model.Drafting +// @Success 200 {object} model.Category // @Failure 401 {object} dto.ErrorDto // @Failure 404 {object} dto.ErrorDto // @Failure 500 {object} dto.ErrorDto diff --git a/api/project.go b/api/project.go new file mode 100644 index 0000000..9539519 --- /dev/null +++ b/api/project.go @@ -0,0 +1,210 @@ +package api + +import ( + "net/http" + "strconv" + + 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" +) + +func InitProjectRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { + authed := api.Group("/v1/project").Use(authMiddleware.MiddlewareFunc()) + authed.GET("/paging", pageQueryProject) + authed.GET("/list", listQueryProject) + authed.POST("", createProject) + authed.GET("/:id", queryProjectInfo) + authed.PUT("/:id", updateProjectInfo) + authed.DELETE("/:id", deleteProject) +} + +// 分页查询项目信息 +// +// @Summary 分页查询项目信息 +// +// @Security JwtAuth +// +// @Description 可以通过项目名称过滤,分页查询项目信息 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param PageProjectReqDto query dto.PageProjectReqDto true "项目查询条件带分页信息" +// @Success 200 {object} dto.PageDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/Project/paging [get] +func pageQueryProject(c *gin.Context) { + req := dto.PageProjectReqDto{} + if err := c.ShouldBind(&req); err != nil { + zap.S().Warn("分页查询参数绑定错误,使用默认参数", err) + req.Default() + } + zap.S().Debug("分页查项目参数", req) + page, err := service.PageProjectQuery(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, page) +} + +// 查询项目信息列表 +// +// @Summary 查询项目信息列表 +// +// @Security JwtAuth +// +// @Description 可以通过项目名称过滤,查询项目信息列表 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param ProjectReqDto query dto.ProjectReqDto true "项目查询条件" +// @Success 200 {object} dto.PageDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/Project/list [get] +func listQueryProject(c *gin.Context) { + req := dto.ProjectReqDto{} + if err := c.ShouldBind(&req); err != nil { + zap.S().Warn("查询参数绑定错误,使用默认参数", err) + } + zap.S().Debug("查项目参数", req) + page, err := service.ListProjectQuery(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, page) +} + +// 创建项目信息 +// +// @Summary 创建项目信息 +// +// @Security JwtAuth +// +// @Description 创建项目数据 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param ProjectDto query dto.ProjectDto true "创建的项目信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/Project [post] +func createProject(c *gin.Context) { + req := dto.ProjectDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "传入参数错误") + return + } + zap.S().Debug("保存数据", req) + data, err := service.CreateProject(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, data) +} + +// 查询项目信息 +// +// @Summary 查询项目信息 +// +// @Security JwtAuth +// +// @Description 查询项目信息 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param id path int true "项目ID" +// @Success 200 {object} model.Project +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/Project/:id [get] +func queryProjectInfo(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryProject(int32(int64Id))) +} + +// 修改项目信息 +// +// @Summary 修改项目信息 +// +// @Security JwtAuth +// +// @Description 修改项目信息 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param id path int true "项目信息ID" +// @Param ProjectDto query dto.ProjectDto true "修改的项目信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/Project/:id [put] +func updateProjectInfo(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + req := dto.ProjectDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "保存参数出错") + return + } + int64Id, _ := strconv.ParseInt(id, 10, 64) + result := service.UpdateProject(int32(int64Id), &req) + if !result { + c.JSON(http.StatusInternalServerError, "保存参数出错") + return + } + c.JSON(http.StatusOK, result) +} + +// 删除项目信息 +// +// @Summary 删除项目信息 +// +// @Security JwtAuth +// +// @Description 删除项目信息 +// @Tags 项目信息Api +// @Accept json +// @Produce json +// @Param id path int true "项目信息ID" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @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 + } + zap.S().Debug("id查询草稿的图形数据", id) + service.DeleteProjectById(id) + c.JSON(http.StatusOK, true) +} diff --git a/api/projectLink.go b/api/projectLink.go new file mode 100644 index 0000000..a1407da --- /dev/null +++ b/api/projectLink.go @@ -0,0 +1,100 @@ +package api + +import ( + "net/http" + "strconv" + + 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/service" +) + +func InitProjectLinkRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { + authed := api.Group("/v1/projectLink").Use(authMiddleware.MiddlewareFunc()) + authed.GET("/info/:id", queryProjectLinkInfo) + authed.GET("/trainSize/:id", queryProjectTrainSizeInfo) + authed.POST("", saveProjectLinkInfo) +} + +// 查询项目的所有关联信息 +// +// @Summary 查询项目的所有关联信息 +// +// @Security JwtAuth +// +// @Description 查询项目的所有关联信息 +// @Tags 项目关联信息Api +// @Accept json +// @Produce json +// @Param id path int true "项目ID" +// @Success 200 {object} dto.ProjectLinkRspDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/projectLink/info/:id [get] +func queryProjectLinkInfo(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryProjectLinkInfo(int32(int64Id))) +} + +// 查询项目的关联列车尺寸信息 +// +// @Summary 查询项目的关联列车尺寸信息 +// +// @Security JwtAuth +// +// @Description 查询项目的关联列车尺寸信息 +// @Tags 项目关联信息Api +// @Accept json +// @Produce json +// @Param id path int true "项目ID" +// @Success 200 {object} dto.TrainSizeDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/projectLink/trainSize/:id [get] +func queryProjectTrainSizeInfo(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryTrainSizeByMapId(int32(int64Id))) +} + +// 保存项目的所有关联信息 +// +// @Summary 保存项目的所有关联信息 +// +// @Security JwtAuth +// +// @Description 保存项目的所有关联信息 +// @Tags 项目关联信息Api +// @Accept json +// @Produce json +// @Param projectLinkReqDto query dto.ProjectLinkReqDto true "关联关系实体" +// @Success 200 {object} bool +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/projectLink [post] +func saveProjectLinkInfo(c *gin.Context) { + req := dto.ProjectLinkReqDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "传入参数错误") + return + } + zap.S().Debug("保存数据", req) + service.UpdateProjectLink(&req) + c.JSON(http.StatusOK, true) +} diff --git a/api/simulation.go b/api/simulation.go index 01c1282..fce4f24 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -199,7 +199,7 @@ func addTrain(c *gin.Context) { HeadOffset: req.HeadOffset, DevicePort: req.DevicePort, RunDirection: req.RunDirection, - //TrainLength: int64(service.CalcTrainLenght(req.TrainModelId, req.CarriageNum)), + TrainLength: req.TrainLength, } memory.AddTrainState(simulation, rsp) c.JSON(http.StatusOK, &rsp) diff --git a/api/trainManage.go b/api/trainManage.go new file mode 100644 index 0000000..7449082 --- /dev/null +++ b/api/trainManage.go @@ -0,0 +1,497 @@ +package api + +// 列车相关的关系管理 +import ( + "net/http" + "strconv" + + 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/service" +) + +func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { + authed := api.Group("/v1/trainManage").Use(authMiddleware.MiddlewareFunc()) + authed.GET("/model/paging", pageQueryTrainModel) + authed.POST("/model", createTrainModel) + authed.GET("/model/:id", queryTrainModel) + authed.PUT("/model/:id", updateTrainModel) + authed.DELETE("/model/:id", deleteTrainModel) + authed.GET("/size/paging", pageQueryTrainSize) + authed.POST("/size", createTrainSize) + authed.GET("/size/:id", queryTrainSize) + authed.PUT("/size/:id", updateTrainSize) + authed.DELETE("/size/:id", deleteTrainSize) + authed.GET("/wheelDiameter/paging", pageQueryTrainWheelDiameter) + authed.POST("/wheelDiameter", createTrainWheelDiameter) + authed.GET("/wheelDiameter/:id", queryTrainWheelDiameter) + authed.PUT("/wheelDiameter/:id", updateTrainWheelDiameter) + authed.DELETE("/wheelDiameter/:id", deleteTrainWheelDiameter) +} + +// 分页查询列车型号列表 +// +// @Summary 分页查询列车型号信息列表 +// +// @Security JwtAuth +// +// @Description 可以通过列车型号名称过滤,分页查询列车型号信息列表 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车型号查询条件带分页信息" +// @Success 200 {object} dto.PageDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/model/paging [get] +func pageQueryTrainModel(c *gin.Context) { + req := dto.PageTrainManageReqDto{} + if err := c.ShouldBind(&req); err != nil { + zap.S().Warn("分页查询参数绑定错误,使用默认参数", err) + req.Default() + } + zap.S().Debug("分页查列车组次参数", req) + page, err := service.PageTrainModelQuery(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, page) +} + +// 创建列车型号 +// +// @Summary 创建列车型号 +// +// @Security JwtAuth +// +// @Description 创建列车型号数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param trainModelDto query dto.TrainModelDto true "创建的列车型号信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/model [post] +func createTrainModel(c *gin.Context) { + req := dto.TrainModelDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "传入参数错误") + return + } + zap.S().Debug("保存数据", req) + data, err := service.CreateTrainModel(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, data) +} + +// 查询列车型号详情 +// +// @Summary 查询列车型号详情 +// +// @Security JwtAuth +// +// @Description 查询列车型号详情 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车型号ID" +// @Success 200 {object} model.TrainModel +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/model/:id [get] +func queryTrainModel(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryTrainModel(int32(int64Id))) +} + +// 修改列车型号信息 +// +// @Summary 修改列车型号信息 +// +// @Security JwtAuth +// +// @Description 修改列车型号信息 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车型号ID" +// @Param trainModelDto query dto.TrainModelDto true "修改的列车型号信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/model/:id [put] +func updateTrainModel(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + req := dto.TrainModelDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "保存参数出错") + return + } + int64Id, _ := strconv.ParseInt(id, 10, 64) + result := service.UpdateTrainModel(int32(int64Id), &req) + if !result { + c.JSON(http.StatusInternalServerError, "保存参数出错") + return + } + c.JSON(http.StatusOK, result) +} + +// 删除列车型号数据 +// +// @Summary 删除列车型号数据 +// +// @Security JwtAuth +// +// @Description 删除列车型号数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车型号ID" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/model/:id [delete] +func deleteTrainModel(c *gin.Context) { + idStr := c.Param("id") + id, err := strconv.Atoi(idStr) + if err != nil { + c.JSON(http.StatusBadRequest, "id参数解析错误") + return + } + zap.S().Debug("id查询列车型号的图形数据", id) + service.DeleteTrainModelById(id) + c.JSON(http.StatusOK, true) +} + +// 分页查询列车尺寸列表 +// +// @Summary 分页查询列车尺寸信息列表 +// +// @Security JwtAuth +// +// @Description 可以通过列车尺寸名称过滤,分页查询列车尺寸信息列表 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车尺寸查询条件带分页信息" +// @Success 200 {object} dto.PageDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/size/paging [get] +func pageQueryTrainSize(c *gin.Context) { + req := dto.PageTrainManageReqDto{} + if err := c.ShouldBind(&req); err != nil { + zap.S().Warn("分页查询参数绑定错误,使用默认参数", err) + req.Default() + } + zap.S().Debug("分页查列车尺寸参数", req) + page, err := service.PageTrainSizeQuery(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, page) +} + +// 创建列车尺寸 +// +// @Summary 创建列车尺寸 +// +// @Security JwtAuth +// +// @Description 创建列车尺寸数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param trainSizeDto query dto.TrainSizeDto true "创建的列车尺寸信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/size [post] +func createTrainSize(c *gin.Context) { + req := dto.TrainSizeDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "传入参数错误") + return + } + zap.S().Debug("保存数据", req) + data, err := service.CreateTrainSize(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, data) +} + +// 查询列车尺寸详情 +// +// @Summary 查询列车尺寸详情 +// +// @Security JwtAuth +// +// @Description 查询列车尺寸详情 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车尺寸ID" +// @Success 200 {object} model.TrainSize +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/size/:id [get] +func queryTrainSize(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryTrainSize(int32(int64Id))) +} + +// 修改列车尺寸信息 +// +// @Summary 修改列车尺寸信息 +// +// @Security JwtAuth +// +// @Description 修改列车尺寸信息 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车尺寸ID" +// @Param trainSizeDto query dto.TrainSizeDto true "修改的列车尺寸信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/size/:id [put] +func updateTrainSize(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + req := dto.TrainSizeDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "保存参数出错") + return + } + int64Id, _ := strconv.ParseInt(id, 10, 64) + result := service.UpdateTrainSize(int32(int64Id), &req) + if !result { + c.JSON(http.StatusInternalServerError, "保存参数出错") + return + } + c.JSON(http.StatusOK, result) +} + +// 删除列车尺寸数据 +// +// @Summary 删除列车尺寸数据 +// +// @Security JwtAuth +// +// @Description 删除列车尺寸数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车尺寸ID" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/size/:id [delete] +func deleteTrainSize(c *gin.Context) { + idStr := c.Param("id") + id, err := strconv.Atoi(idStr) + if err != nil { + c.JSON(http.StatusBadRequest, "id参数解析错误") + return + } + zap.S().Debug("id查询列车型号的图形数据", id) + service.DeleteTrainSizeById(id) + c.JSON(http.StatusOK, true) +} + +// 分页查询列车轮径列表 +// +// @Summary 分页查询列车轮径信息列表 +// +// @Security JwtAuth +// +// @Description 可以通过列车轮径名称过滤,分页查询列车轮径信息列表 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车轮径查询条件带分页信息" +// @Success 200 {object} dto.PageDto +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/wheelDiameter/paging [get] +func pageQueryTrainWheelDiameter(c *gin.Context) { + req := dto.PageTrainManageReqDto{} + if err := c.ShouldBind(&req); err != nil { + zap.S().Warn("分页查询参数绑定错误,使用默认参数", err) + req.Default() + } + zap.S().Debug("分页查列车尺寸参数", req) + page, err := service.PageTrainWheelDiameterQuery(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, page) +} + +// 创建列车轮径 +// +// @Summary 创建列车轮径 +// +// @Security JwtAuth +// +// @Description 创建列车轮径数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param trainWheelDiameterDto query dto.TrainWheelDiameterDto true "创建的列车轮径信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/wheelDiameter [post] +func createTrainWheelDiameter(c *gin.Context) { + req := dto.TrainWheelDiameterDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "传入参数错误") + return + } + zap.S().Debug("保存数据", req) + data, err := service.CreateTrainWheelDiameter(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, err.Error()) + return + } + c.JSON(http.StatusOK, data) +} + +// 查询列车轮径详情 +// +// @Summary 查询列车轮径详情 +// +// @Security JwtAuth +// +// @Description 查询列车轮径详情 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车轮径ID" +// @Success 200 {object} model.TrainWheelDiameter +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/wheelDiameter/:id [get] +func queryTrainWheelDiameter(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + int64Id, _ := strconv.ParseInt(id, 10, 64) + c.JSON(http.StatusOK, service.QueryTrainWheelDiameter(int32(int64Id))) +} + +// 修改列车轮径信息 +// +// @Summary 修改列车轮径信息 +// +// @Security JwtAuth +// +// @Description 修改列车轮径信息 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车轮径ID" +// @Param trainWheelDiameterDto query dto.TrainWheelDiameterDto true "修改的列车轮径信息" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/wheelDiameter/:id [put] +func updateTrainWheelDiameter(c *gin.Context) { + id, exist := c.Params.Get("id") + if !exist { + c.JSON(http.StatusBadRequest, "必要参数id不存在") + return + } + zap.S().Debug("传入参数id为" + id) + req := dto.TrainWheelDiameterDto{} + if err := c.ShouldBind(&req); err != nil { + c.JSON(http.StatusBadRequest, "保存参数出错") + return + } + int64Id, _ := strconv.ParseInt(id, 10, 64) + result := service.UpdateTrainWheelDiameter(int32(int64Id), &req) + if !result { + c.JSON(http.StatusInternalServerError, "保存参数出错") + return + } + c.JSON(http.StatusOK, result) +} + +// 删除列车轮径数据 +// +// @Summary 删除列车轮径数据 +// +// @Security JwtAuth +// +// @Description 删除列车轮径数据 +// @Tags 列车管理Api +// @Accept json +// @Produce json +// @Param id path int true "列车轮径ID" +// @Success 200 {object} nil +// @Failure 401 {object} dto.ErrorDto +// @Failure 404 {object} dto.ErrorDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/trainManage/wheelDiameter/:id [delete] +func deleteTrainWheelDiameter(c *gin.Context) { + idStr := c.Param("id") + id, err := strconv.Atoi(idStr) + if err != nil { + c.JSON(http.StatusBadRequest, "id参数解析错误") + return + } + zap.S().Debug("id查询列车型号的图形数据", id) + service.DeleteTrainWheelDiameterById(id) + c.JSON(http.StatusOK, true) +} diff --git a/api/trainModel.go b/api/trainModel.go deleted file mode 100644 index d698873..0000000 --- a/api/trainModel.go +++ /dev/null @@ -1,179 +0,0 @@ -package api - -import ( - "net/http" - "strconv" - - 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" -) - -func InitTrainModelRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { - authed := api.Group("/v1/trainModel").Use(authMiddleware.MiddlewareFunc()) - authed.GET("/paging", pageQueryTrainModel) - authed.POST("", createTrainModel) - authed.GET("/:id", queryTrainModel) - authed.PUT("/:id", updateTrainModel) - authed.DELETE("/:id", deleteTrainModel) -} - -// 分页查询列车型号列表 -// -// @Summary 分页查询列车型号信息列表 -// -// @Security JwtAuth -// -// @Description 可以通过列车型号名称过滤,分页查询列车型号信息列表 -// @Tags 列车型号Api -// @Accept json -// @Produce json -// @Param pageTrainModelReqDto query dto.PageTrainModelReqDto true "列车型号查询条件带分页信息" -// @Success 200 {object} dto.PageDto -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/trainModel/paging [get] -func pageQueryTrainModel(c *gin.Context) { - user, _ := c.Get(middleware.IdentityKey) - zap.S().Debug("分页查询列车组次", user) - req := dto.PageTrainModelReqDto{} - if err := c.ShouldBind(&req); err != nil { - zap.S().Warn("分页查询参数绑定错误,使用默认参数", err) - req.Default() - } - zap.S().Debug("分页查列车组次参数", req) - page, err := service.PageTrainModelQuery(&req) - if err != nil { - c.JSON(http.StatusInternalServerError, err.Error()) - return - } - c.JSON(http.StatusOK, page) -} - -// 创建列车型号 -// -// @Summary 创建列车型号 -// -// @Security JwtAuth -// -// @Description 创建列车型号数据 -// @Tags 列车型号Api -// @Accept json -// @Produce json -// @Param trainModelDto query dto.TrainModelDto true "创建的列车型号信息" -// @Success 200 {object} nil -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/trainModel [post] -func createTrainModel(c *gin.Context) { - req := dto.TrainModelDto{} - if err := c.ShouldBind(&req); err != nil { - c.JSON(http.StatusBadRequest, "传入参数错误") - return - } - zap.S().Debug("保存数据", req) - data, err := service.CreateTrainModel(&req) - if err != nil { - c.JSON(http.StatusInternalServerError, err.Error()) - return - } - c.JSON(http.StatusOK, data) -} - -// 查询列车型号详情 -// -// @Summary 查询列车型号详情 -// -// @Security JwtAuth -// -// @Description 查询列车型号详情 -// @Tags 列车型号Api -// @Accept json -// @Produce json -// @Param id path int true "列车型号ID" -// @Success 200 {object} model.TrainModel -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/trainModel/:id [get] -func queryTrainModel(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - c.JSON(http.StatusBadRequest, "必要参数id不存在") - return - } - zap.S().Debug("传入参数id为" + id) - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.QueryTrainModel(int32(int64Id))) -} - -// 修改列车型号信息 -// -// @Summary 修改列车型号信息 -// -// @Security JwtAuth -// -// @Description 修改列车型号信息 -// @Tags 列车型号Api -// @Accept json -// @Produce json -// @Param id path int true "列车型号ID" -// @Param trainModelDto query dto.TrainModelDto true "修改的列车型号信息" -// @Success 200 {object} nil -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/trainModel/:id [put] -func updateTrainModel(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - c.JSON(http.StatusBadRequest, "必要参数id不存在") - return - } - zap.S().Debug("传入参数id为" + id) - req := dto.TrainModelDto{} - if err := c.ShouldBind(&req); err != nil { - c.JSON(http.StatusBadRequest, "保存参数出错") - return - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - result := service.UpdateTrainModel(int32(int64Id), &req) - if !result { - c.JSON(http.StatusInternalServerError, "保存参数出错") - return - } - c.JSON(http.StatusOK, result) -} - -// 删除列车型号数据 -// -// @Summary 删除列车型号数据 -// -// @Security JwtAuth -// -// @Description 删除列车型号数据 -// @Tags 列车型号Api -// @Accept json -// @Produce json -// @Param id path int true "列车型号ID" -// @Success 200 {object} nil -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/trainModel/:id [delete] -func deleteTrainModel(c *gin.Context) { - idStr := c.Param("id") - id, err := strconv.Atoi(idStr) - if err != nil { - c.JSON(http.StatusBadRequest, "id参数解析错误") - return - } - zap.S().Debug("id查询列车型号的图形数据", id) - service.DeleteTrainModelById(id) - c.JSON(http.StatusOK, true) -} diff --git a/ats/verify/simulation/simulation_manage.go b/ats/verify/simulation/simulation_manage.go index 2e30c49..74af0bf 100644 --- a/ats/verify/simulation/simulation_manage.go +++ b/ats/verify/simulation/simulation_manage.go @@ -287,31 +287,31 @@ func decoderVobcTrainState(buf []byte) *state.TrainVobcState { trainVobcInfo := &state.TrainVobcState{} trainVobcInfo.LifeSignal = int32(binary.BigEndian.Uint16(buf[0:2])) b2 := buf[2] - trainVobcInfo.Tc1Active = (b2 & (1 << 7)) != 0 - trainVobcInfo.Tc2Active = (b2 & (1 << 6)) != 0 - trainVobcInfo.DirectionForward = (b2 & (1 << 5)) != 0 - trainVobcInfo.DirectionBackward = (b2 & (1 << 4)) != 0 - trainVobcInfo.TractionStatus = (b2 & (1 << 3)) != 0 - trainVobcInfo.BrakingStatus = (b2 & (1 << 2)) != 0 - trainVobcInfo.EmergencyBrakingStatus = (b2 & (1 << 1)) != 0 - trainVobcInfo.TurnbackStatus = (b2 & 1) != 0 + trainVobcInfo.Tc1Active = (b2 & 1) != 0 + trainVobcInfo.Tc2Active = (b2 & (1 << 1)) != 0 + trainVobcInfo.DirectionForward = (b2 & (1 << 2)) != 0 + trainVobcInfo.DirectionBackward = (b2 & (1 << 3)) != 0 + trainVobcInfo.TractionStatus = (b2 & (1 << 4)) != 0 + trainVobcInfo.BrakingStatus = (b2 & (1 << 5)) != 0 + trainVobcInfo.EmergencyBrakingStatus = (b2 & (1 << 6)) != 0 + trainVobcInfo.TurnbackStatus = (b2 & 7) != 0 b3 := buf[3] - trainVobcInfo.JumpStatus = (b3 & (1 << 7)) != 0 - trainVobcInfo.Ato = (b3 & (1 << 6)) != 0 - trainVobcInfo.Fam = (b3 & (1 << 5)) != 0 - trainVobcInfo.Cam = (b3 & (1 << 4)) != 0 - trainVobcInfo.TractionSafetyCircuit = (b3 & (1 << 3)) != 0 - trainVobcInfo.ParkingBrakeStatus = (b3 & (1 << 2)) != 0 - trainVobcInfo.MaintainBrakeStatus = (b3 & (1 << 1)) != 0 + trainVobcInfo.JumpStatus = (b3 & 1) != 0 + trainVobcInfo.Ato = (b3 & (1 << 1)) != 0 + trainVobcInfo.Fam = (b3 & (1 << 2)) != 0 + trainVobcInfo.Cam = (b3 & (1 << 3)) != 0 + trainVobcInfo.TractionSafetyCircuit = (b3 & (1 << 4)) != 0 + trainVobcInfo.ParkingBrakeStatus = (b3 & (1 << 5)) != 0 + trainVobcInfo.MaintainBrakeStatus = (b3 & (1 << 6)) != 0 trainVobcInfo.TractionForce = int64(binary.BigEndian.Uint16(buf[4:6])) trainVobcInfo.BrakeForce = int64(binary.BigEndian.Uint16(buf[6:8])) trainVobcInfo.TrainLoad = int64(binary.BigEndian.Uint16(buf[8:10])) b4 := buf[15] - trainVobcInfo.LeftDoorOpenCommand = (b4 & (1 << 7)) != 0 - trainVobcInfo.RightDoorOpenCommand = (b4 & (1 << 6)) != 0 - trainVobcInfo.LeftDoorCloseCommand = (b4 & (1 << 5)) != 0 - trainVobcInfo.RightDoorCloseCommand = (b4 & (1 << 4)) != 0 - trainVobcInfo.AllDoorClose = (b4 & (1 << 3)) != 0 + trainVobcInfo.LeftDoorOpenCommand = (b4 & 1) != 0 + trainVobcInfo.RightDoorOpenCommand = (b4 & (1 << 1)) != 0 + trainVobcInfo.LeftDoorCloseCommand = (b4 & (1 << 2)) != 0 + trainVobcInfo.RightDoorCloseCommand = (b4 & (1 << 3)) != 0 + trainVobcInfo.AllDoorClose = (b4 & (1 << 4)) != 0 return trainVobcInfo } diff --git a/db/dbquery/gen.go b/db/dbquery/gen.go index 840abac..503b6ec 100644 --- a/db/dbquery/gen.go +++ b/db/dbquery/gen.go @@ -16,54 +16,79 @@ import ( ) var ( - Q = new(Query) - Category *category - Drafting *drafting - PublishedGi *publishedGi - TrainModel *trainModel - User *user + Q = new(Query) + Category *category + Drafting *drafting + Project *project + ProjectPublishLink *projectPublishLink + ProjectTrainSizeLink *projectTrainSizeLink + PublishedGi *publishedGi + TrainModel *trainModel + TrainSize *trainSize + TrainWheelDiameter *trainWheelDiameter + User *user ) func SetDefault(db *gorm.DB, opts ...gen.DOOption) { *Q = *Use(db, opts...) Category = &Q.Category Drafting = &Q.Drafting + Project = &Q.Project + ProjectPublishLink = &Q.ProjectPublishLink + ProjectTrainSizeLink = &Q.ProjectTrainSizeLink PublishedGi = &Q.PublishedGi TrainModel = &Q.TrainModel + TrainSize = &Q.TrainSize + TrainWheelDiameter = &Q.TrainWheelDiameter User = &Q.User } func Use(db *gorm.DB, opts ...gen.DOOption) *Query { return &Query{ - db: db, - Category: newCategory(db, opts...), - Drafting: newDrafting(db, opts...), - PublishedGi: newPublishedGi(db, opts...), - TrainModel: newTrainModel(db, opts...), - User: newUser(db, opts...), + db: db, + Category: newCategory(db, opts...), + Drafting: newDrafting(db, opts...), + Project: newProject(db, opts...), + ProjectPublishLink: newProjectPublishLink(db, opts...), + ProjectTrainSizeLink: newProjectTrainSizeLink(db, opts...), + PublishedGi: newPublishedGi(db, opts...), + TrainModel: newTrainModel(db, opts...), + TrainSize: newTrainSize(db, opts...), + TrainWheelDiameter: newTrainWheelDiameter(db, opts...), + User: newUser(db, opts...), } } type Query struct { db *gorm.DB - Category category - Drafting drafting - PublishedGi publishedGi - TrainModel trainModel - User user + Category category + Drafting drafting + Project project + ProjectPublishLink projectPublishLink + ProjectTrainSizeLink projectTrainSizeLink + PublishedGi publishedGi + TrainModel trainModel + TrainSize trainSize + TrainWheelDiameter trainWheelDiameter + User user } func (q *Query) Available() bool { return q.db != nil } func (q *Query) clone(db *gorm.DB) *Query { return &Query{ - db: db, - Category: q.Category.clone(db), - Drafting: q.Drafting.clone(db), - PublishedGi: q.PublishedGi.clone(db), - TrainModel: q.TrainModel.clone(db), - User: q.User.clone(db), + db: db, + Category: q.Category.clone(db), + Drafting: q.Drafting.clone(db), + Project: q.Project.clone(db), + ProjectPublishLink: q.ProjectPublishLink.clone(db), + ProjectTrainSizeLink: q.ProjectTrainSizeLink.clone(db), + PublishedGi: q.PublishedGi.clone(db), + TrainModel: q.TrainModel.clone(db), + TrainSize: q.TrainSize.clone(db), + TrainWheelDiameter: q.TrainWheelDiameter.clone(db), + User: q.User.clone(db), } } @@ -77,30 +102,45 @@ func (q *Query) WriteDB() *Query { func (q *Query) ReplaceDB(db *gorm.DB) *Query { return &Query{ - db: db, - Category: q.Category.replaceDB(db), - Drafting: q.Drafting.replaceDB(db), - PublishedGi: q.PublishedGi.replaceDB(db), - TrainModel: q.TrainModel.replaceDB(db), - User: q.User.replaceDB(db), + db: db, + Category: q.Category.replaceDB(db), + Drafting: q.Drafting.replaceDB(db), + Project: q.Project.replaceDB(db), + ProjectPublishLink: q.ProjectPublishLink.replaceDB(db), + ProjectTrainSizeLink: q.ProjectTrainSizeLink.replaceDB(db), + PublishedGi: q.PublishedGi.replaceDB(db), + TrainModel: q.TrainModel.replaceDB(db), + TrainSize: q.TrainSize.replaceDB(db), + TrainWheelDiameter: q.TrainWheelDiameter.replaceDB(db), + User: q.User.replaceDB(db), } } type queryCtx struct { - Category ICategoryDo - Drafting IDraftingDo - PublishedGi IPublishedGiDo - TrainModel ITrainModelDo - User IUserDo + Category ICategoryDo + Drafting IDraftingDo + Project IProjectDo + ProjectPublishLink IProjectPublishLinkDo + ProjectTrainSizeLink IProjectTrainSizeLinkDo + PublishedGi IPublishedGiDo + TrainModel ITrainModelDo + TrainSize ITrainSizeDo + TrainWheelDiameter ITrainWheelDiameterDo + User IUserDo } func (q *Query) WithContext(ctx context.Context) *queryCtx { return &queryCtx{ - Category: q.Category.WithContext(ctx), - Drafting: q.Drafting.WithContext(ctx), - PublishedGi: q.PublishedGi.WithContext(ctx), - TrainModel: q.TrainModel.WithContext(ctx), - User: q.User.WithContext(ctx), + Category: q.Category.WithContext(ctx), + Drafting: q.Drafting.WithContext(ctx), + Project: q.Project.WithContext(ctx), + ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx), + ProjectTrainSizeLink: q.ProjectTrainSizeLink.WithContext(ctx), + PublishedGi: q.PublishedGi.WithContext(ctx), + TrainModel: q.TrainModel.WithContext(ctx), + TrainSize: q.TrainSize.WithContext(ctx), + TrainWheelDiameter: q.TrainWheelDiameter.WithContext(ctx), + User: q.User.WithContext(ctx), } } diff --git a/db/dbquery/project.gen.go b/db/dbquery/project.gen.go new file mode 100644 index 0000000..32a0ff5 --- /dev/null +++ b/db/dbquery/project.gen.go @@ -0,0 +1,396 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newProject(db *gorm.DB, opts ...gen.DOOption) project { + _project := project{} + + _project.projectDo.UseDB(db, opts...) + _project.projectDo.UseModel(&model.Project{}) + + tableName := _project.projectDo.TableName() + _project.ALL = field.NewAsterisk(tableName) + _project.ID = field.NewInt32(tableName, "id") + _project.Name = field.NewString(tableName, "name") + _project.Code = field.NewString(tableName, "code") + _project.CreatedAt = field.NewTime(tableName, "created_at") + _project.UpdateAt = field.NewTime(tableName, "update_at") + + _project.fillFieldMap() + + return _project +} + +type project struct { + projectDo + + ALL field.Asterisk + ID field.Int32 // 主键 + Name field.String // 名称 + Code field.String // 项目编码 + CreatedAt field.Time // 创建时间 + UpdateAt field.Time // 更新时间 + + fieldMap map[string]field.Expr +} + +func (p project) Table(newTableName string) *project { + p.projectDo.UseTable(newTableName) + return p.updateTableName(newTableName) +} + +func (p project) As(alias string) *project { + p.projectDo.DO = *(p.projectDo.As(alias).(*gen.DO)) + return p.updateTableName(alias) +} + +func (p *project) updateTableName(table string) *project { + p.ALL = field.NewAsterisk(table) + p.ID = field.NewInt32(table, "id") + p.Name = field.NewString(table, "name") + p.Code = field.NewString(table, "code") + p.CreatedAt = field.NewTime(table, "created_at") + p.UpdateAt = field.NewTime(table, "update_at") + + p.fillFieldMap() + + return p +} + +func (p *project) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := p.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (p *project) fillFieldMap() { + p.fieldMap = make(map[string]field.Expr, 5) + p.fieldMap["id"] = p.ID + p.fieldMap["name"] = p.Name + p.fieldMap["code"] = p.Code + p.fieldMap["created_at"] = p.CreatedAt + p.fieldMap["update_at"] = p.UpdateAt +} + +func (p project) clone(db *gorm.DB) project { + p.projectDo.ReplaceConnPool(db.Statement.ConnPool) + return p +} + +func (p project) replaceDB(db *gorm.DB) project { + p.projectDo.ReplaceDB(db) + return p +} + +type projectDo struct{ gen.DO } + +type IProjectDo interface { + gen.SubQuery + Debug() IProjectDo + WithContext(ctx context.Context) IProjectDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() IProjectDo + WriteDB() IProjectDo + As(alias string) gen.Dao + Session(config *gorm.Session) IProjectDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) IProjectDo + Not(conds ...gen.Condition) IProjectDo + Or(conds ...gen.Condition) IProjectDo + Select(conds ...field.Expr) IProjectDo + Where(conds ...gen.Condition) IProjectDo + Order(conds ...field.Expr) IProjectDo + Distinct(cols ...field.Expr) IProjectDo + Omit(cols ...field.Expr) IProjectDo + Join(table schema.Tabler, on ...field.Expr) IProjectDo + LeftJoin(table schema.Tabler, on ...field.Expr) IProjectDo + RightJoin(table schema.Tabler, on ...field.Expr) IProjectDo + Group(cols ...field.Expr) IProjectDo + Having(conds ...gen.Condition) IProjectDo + Limit(limit int) IProjectDo + Offset(offset int) IProjectDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectDo + Unscoped() IProjectDo + Create(values ...*model.Project) error + CreateInBatches(values []*model.Project, batchSize int) error + Save(values ...*model.Project) error + First() (*model.Project, error) + Take() (*model.Project, error) + Last() (*model.Project, error) + Find() ([]*model.Project, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Project, err error) + FindInBatches(result *[]*model.Project, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.Project) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) IProjectDo + Assign(attrs ...field.AssignExpr) IProjectDo + Joins(fields ...field.RelationField) IProjectDo + Preload(fields ...field.RelationField) IProjectDo + FirstOrInit() (*model.Project, error) + FirstOrCreate() (*model.Project, error) + FindByPage(offset int, limit int) (result []*model.Project, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) IProjectDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (p projectDo) Debug() IProjectDo { + return p.withDO(p.DO.Debug()) +} + +func (p projectDo) WithContext(ctx context.Context) IProjectDo { + return p.withDO(p.DO.WithContext(ctx)) +} + +func (p projectDo) ReadDB() IProjectDo { + return p.Clauses(dbresolver.Read) +} + +func (p projectDo) WriteDB() IProjectDo { + return p.Clauses(dbresolver.Write) +} + +func (p projectDo) Session(config *gorm.Session) IProjectDo { + return p.withDO(p.DO.Session(config)) +} + +func (p projectDo) Clauses(conds ...clause.Expression) IProjectDo { + return p.withDO(p.DO.Clauses(conds...)) +} + +func (p projectDo) Returning(value interface{}, columns ...string) IProjectDo { + return p.withDO(p.DO.Returning(value, columns...)) +} + +func (p projectDo) Not(conds ...gen.Condition) IProjectDo { + return p.withDO(p.DO.Not(conds...)) +} + +func (p projectDo) Or(conds ...gen.Condition) IProjectDo { + return p.withDO(p.DO.Or(conds...)) +} + +func (p projectDo) Select(conds ...field.Expr) IProjectDo { + return p.withDO(p.DO.Select(conds...)) +} + +func (p projectDo) Where(conds ...gen.Condition) IProjectDo { + return p.withDO(p.DO.Where(conds...)) +} + +func (p projectDo) Order(conds ...field.Expr) IProjectDo { + return p.withDO(p.DO.Order(conds...)) +} + +func (p projectDo) Distinct(cols ...field.Expr) IProjectDo { + return p.withDO(p.DO.Distinct(cols...)) +} + +func (p projectDo) Omit(cols ...field.Expr) IProjectDo { + return p.withDO(p.DO.Omit(cols...)) +} + +func (p projectDo) Join(table schema.Tabler, on ...field.Expr) IProjectDo { + return p.withDO(p.DO.Join(table, on...)) +} + +func (p projectDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectDo { + return p.withDO(p.DO.LeftJoin(table, on...)) +} + +func (p projectDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectDo { + return p.withDO(p.DO.RightJoin(table, on...)) +} + +func (p projectDo) Group(cols ...field.Expr) IProjectDo { + return p.withDO(p.DO.Group(cols...)) +} + +func (p projectDo) Having(conds ...gen.Condition) IProjectDo { + return p.withDO(p.DO.Having(conds...)) +} + +func (p projectDo) Limit(limit int) IProjectDo { + return p.withDO(p.DO.Limit(limit)) +} + +func (p projectDo) Offset(offset int) IProjectDo { + return p.withDO(p.DO.Offset(offset)) +} + +func (p projectDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectDo { + return p.withDO(p.DO.Scopes(funcs...)) +} + +func (p projectDo) Unscoped() IProjectDo { + return p.withDO(p.DO.Unscoped()) +} + +func (p projectDo) Create(values ...*model.Project) error { + if len(values) == 0 { + return nil + } + return p.DO.Create(values) +} + +func (p projectDo) CreateInBatches(values []*model.Project, batchSize int) error { + return p.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (p projectDo) Save(values ...*model.Project) error { + if len(values) == 0 { + return nil + } + return p.DO.Save(values) +} + +func (p projectDo) First() (*model.Project, error) { + if result, err := p.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.Project), nil + } +} + +func (p projectDo) Take() (*model.Project, error) { + if result, err := p.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.Project), nil + } +} + +func (p projectDo) Last() (*model.Project, error) { + if result, err := p.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.Project), nil + } +} + +func (p projectDo) Find() ([]*model.Project, error) { + result, err := p.DO.Find() + return result.([]*model.Project), err +} + +func (p projectDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Project, err error) { + buf := make([]*model.Project, 0, batchSize) + err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (p projectDo) FindInBatches(result *[]*model.Project, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return p.DO.FindInBatches(result, batchSize, fc) +} + +func (p projectDo) Attrs(attrs ...field.AssignExpr) IProjectDo { + return p.withDO(p.DO.Attrs(attrs...)) +} + +func (p projectDo) Assign(attrs ...field.AssignExpr) IProjectDo { + return p.withDO(p.DO.Assign(attrs...)) +} + +func (p projectDo) Joins(fields ...field.RelationField) IProjectDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Joins(_f)) + } + return &p +} + +func (p projectDo) Preload(fields ...field.RelationField) IProjectDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Preload(_f)) + } + return &p +} + +func (p projectDo) FirstOrInit() (*model.Project, error) { + if result, err := p.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.Project), nil + } +} + +func (p projectDo) FirstOrCreate() (*model.Project, error) { + if result, err := p.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.Project), nil + } +} + +func (p projectDo) FindByPage(offset int, limit int) (result []*model.Project, count int64, err error) { + result, err = p.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = p.Offset(-1).Limit(-1).Count() + return +} + +func (p projectDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = p.Count() + if err != nil { + return + } + + err = p.Offset(offset).Limit(limit).Scan(result) + return +} + +func (p projectDo) Scan(result interface{}) (err error) { + return p.DO.Scan(result) +} + +func (p projectDo) Delete(models ...*model.Project) (result gen.ResultInfo, err error) { + return p.DO.Delete(models) +} + +func (p *projectDo) withDO(do gen.Dao) *projectDo { + p.DO = *do.(*gen.DO) + return p +} diff --git a/db/dbquery/project_publish_link.gen.go b/db/dbquery/project_publish_link.gen.go new file mode 100644 index 0000000..daec2dd --- /dev/null +++ b/db/dbquery/project_publish_link.gen.go @@ -0,0 +1,388 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newProjectPublishLink(db *gorm.DB, opts ...gen.DOOption) projectPublishLink { + _projectPublishLink := projectPublishLink{} + + _projectPublishLink.projectPublishLinkDo.UseDB(db, opts...) + _projectPublishLink.projectPublishLinkDo.UseModel(&model.ProjectPublishLink{}) + + tableName := _projectPublishLink.projectPublishLinkDo.TableName() + _projectPublishLink.ALL = field.NewAsterisk(tableName) + _projectPublishLink.ID = field.NewInt32(tableName, "id") + _projectPublishLink.Pid = field.NewInt32(tableName, "pid") + _projectPublishLink.Mid = field.NewInt32(tableName, "mid") + + _projectPublishLink.fillFieldMap() + + return _projectPublishLink +} + +type projectPublishLink struct { + projectPublishLinkDo + + ALL field.Asterisk + ID field.Int32 // 主键 + Pid field.Int32 // 项目主键 + Mid field.Int32 // 发布的地图ID + + fieldMap map[string]field.Expr +} + +func (p projectPublishLink) Table(newTableName string) *projectPublishLink { + p.projectPublishLinkDo.UseTable(newTableName) + return p.updateTableName(newTableName) +} + +func (p projectPublishLink) As(alias string) *projectPublishLink { + p.projectPublishLinkDo.DO = *(p.projectPublishLinkDo.As(alias).(*gen.DO)) + return p.updateTableName(alias) +} + +func (p *projectPublishLink) updateTableName(table string) *projectPublishLink { + p.ALL = field.NewAsterisk(table) + p.ID = field.NewInt32(table, "id") + p.Pid = field.NewInt32(table, "pid") + p.Mid = field.NewInt32(table, "mid") + + p.fillFieldMap() + + return p +} + +func (p *projectPublishLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := p.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (p *projectPublishLink) fillFieldMap() { + p.fieldMap = make(map[string]field.Expr, 3) + p.fieldMap["id"] = p.ID + p.fieldMap["pid"] = p.Pid + p.fieldMap["mid"] = p.Mid +} + +func (p projectPublishLink) clone(db *gorm.DB) projectPublishLink { + p.projectPublishLinkDo.ReplaceConnPool(db.Statement.ConnPool) + return p +} + +func (p projectPublishLink) replaceDB(db *gorm.DB) projectPublishLink { + p.projectPublishLinkDo.ReplaceDB(db) + return p +} + +type projectPublishLinkDo struct{ gen.DO } + +type IProjectPublishLinkDo interface { + gen.SubQuery + Debug() IProjectPublishLinkDo + WithContext(ctx context.Context) IProjectPublishLinkDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() IProjectPublishLinkDo + WriteDB() IProjectPublishLinkDo + As(alias string) gen.Dao + Session(config *gorm.Session) IProjectPublishLinkDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) IProjectPublishLinkDo + Not(conds ...gen.Condition) IProjectPublishLinkDo + Or(conds ...gen.Condition) IProjectPublishLinkDo + Select(conds ...field.Expr) IProjectPublishLinkDo + Where(conds ...gen.Condition) IProjectPublishLinkDo + Order(conds ...field.Expr) IProjectPublishLinkDo + Distinct(cols ...field.Expr) IProjectPublishLinkDo + Omit(cols ...field.Expr) IProjectPublishLinkDo + Join(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo + LeftJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo + RightJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo + Group(cols ...field.Expr) IProjectPublishLinkDo + Having(conds ...gen.Condition) IProjectPublishLinkDo + Limit(limit int) IProjectPublishLinkDo + Offset(offset int) IProjectPublishLinkDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectPublishLinkDo + Unscoped() IProjectPublishLinkDo + Create(values ...*model.ProjectPublishLink) error + CreateInBatches(values []*model.ProjectPublishLink, batchSize int) error + Save(values ...*model.ProjectPublishLink) error + First() (*model.ProjectPublishLink, error) + Take() (*model.ProjectPublishLink, error) + Last() (*model.ProjectPublishLink, error) + Find() ([]*model.ProjectPublishLink, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectPublishLink, err error) + FindInBatches(result *[]*model.ProjectPublishLink, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.ProjectPublishLink) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) IProjectPublishLinkDo + Assign(attrs ...field.AssignExpr) IProjectPublishLinkDo + Joins(fields ...field.RelationField) IProjectPublishLinkDo + Preload(fields ...field.RelationField) IProjectPublishLinkDo + FirstOrInit() (*model.ProjectPublishLink, error) + FirstOrCreate() (*model.ProjectPublishLink, error) + FindByPage(offset int, limit int) (result []*model.ProjectPublishLink, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) IProjectPublishLinkDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (p projectPublishLinkDo) Debug() IProjectPublishLinkDo { + return p.withDO(p.DO.Debug()) +} + +func (p projectPublishLinkDo) WithContext(ctx context.Context) IProjectPublishLinkDo { + return p.withDO(p.DO.WithContext(ctx)) +} + +func (p projectPublishLinkDo) ReadDB() IProjectPublishLinkDo { + return p.Clauses(dbresolver.Read) +} + +func (p projectPublishLinkDo) WriteDB() IProjectPublishLinkDo { + return p.Clauses(dbresolver.Write) +} + +func (p projectPublishLinkDo) Session(config *gorm.Session) IProjectPublishLinkDo { + return p.withDO(p.DO.Session(config)) +} + +func (p projectPublishLinkDo) Clauses(conds ...clause.Expression) IProjectPublishLinkDo { + return p.withDO(p.DO.Clauses(conds...)) +} + +func (p projectPublishLinkDo) Returning(value interface{}, columns ...string) IProjectPublishLinkDo { + return p.withDO(p.DO.Returning(value, columns...)) +} + +func (p projectPublishLinkDo) Not(conds ...gen.Condition) IProjectPublishLinkDo { + return p.withDO(p.DO.Not(conds...)) +} + +func (p projectPublishLinkDo) Or(conds ...gen.Condition) IProjectPublishLinkDo { + return p.withDO(p.DO.Or(conds...)) +} + +func (p projectPublishLinkDo) Select(conds ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Select(conds...)) +} + +func (p projectPublishLinkDo) Where(conds ...gen.Condition) IProjectPublishLinkDo { + return p.withDO(p.DO.Where(conds...)) +} + +func (p projectPublishLinkDo) Order(conds ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Order(conds...)) +} + +func (p projectPublishLinkDo) Distinct(cols ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Distinct(cols...)) +} + +func (p projectPublishLinkDo) Omit(cols ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Omit(cols...)) +} + +func (p projectPublishLinkDo) Join(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Join(table, on...)) +} + +func (p projectPublishLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.LeftJoin(table, on...)) +} + +func (p projectPublishLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.RightJoin(table, on...)) +} + +func (p projectPublishLinkDo) Group(cols ...field.Expr) IProjectPublishLinkDo { + return p.withDO(p.DO.Group(cols...)) +} + +func (p projectPublishLinkDo) Having(conds ...gen.Condition) IProjectPublishLinkDo { + return p.withDO(p.DO.Having(conds...)) +} + +func (p projectPublishLinkDo) Limit(limit int) IProjectPublishLinkDo { + return p.withDO(p.DO.Limit(limit)) +} + +func (p projectPublishLinkDo) Offset(offset int) IProjectPublishLinkDo { + return p.withDO(p.DO.Offset(offset)) +} + +func (p projectPublishLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectPublishLinkDo { + return p.withDO(p.DO.Scopes(funcs...)) +} + +func (p projectPublishLinkDo) Unscoped() IProjectPublishLinkDo { + return p.withDO(p.DO.Unscoped()) +} + +func (p projectPublishLinkDo) Create(values ...*model.ProjectPublishLink) error { + if len(values) == 0 { + return nil + } + return p.DO.Create(values) +} + +func (p projectPublishLinkDo) CreateInBatches(values []*model.ProjectPublishLink, batchSize int) error { + return p.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (p projectPublishLinkDo) Save(values ...*model.ProjectPublishLink) error { + if len(values) == 0 { + return nil + } + return p.DO.Save(values) +} + +func (p projectPublishLinkDo) First() (*model.ProjectPublishLink, error) { + if result, err := p.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.ProjectPublishLink), nil + } +} + +func (p projectPublishLinkDo) Take() (*model.ProjectPublishLink, error) { + if result, err := p.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.ProjectPublishLink), nil + } +} + +func (p projectPublishLinkDo) Last() (*model.ProjectPublishLink, error) { + if result, err := p.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.ProjectPublishLink), nil + } +} + +func (p projectPublishLinkDo) Find() ([]*model.ProjectPublishLink, error) { + result, err := p.DO.Find() + return result.([]*model.ProjectPublishLink), err +} + +func (p projectPublishLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectPublishLink, err error) { + buf := make([]*model.ProjectPublishLink, 0, batchSize) + err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (p projectPublishLinkDo) FindInBatches(result *[]*model.ProjectPublishLink, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return p.DO.FindInBatches(result, batchSize, fc) +} + +func (p projectPublishLinkDo) Attrs(attrs ...field.AssignExpr) IProjectPublishLinkDo { + return p.withDO(p.DO.Attrs(attrs...)) +} + +func (p projectPublishLinkDo) Assign(attrs ...field.AssignExpr) IProjectPublishLinkDo { + return p.withDO(p.DO.Assign(attrs...)) +} + +func (p projectPublishLinkDo) Joins(fields ...field.RelationField) IProjectPublishLinkDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Joins(_f)) + } + return &p +} + +func (p projectPublishLinkDo) Preload(fields ...field.RelationField) IProjectPublishLinkDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Preload(_f)) + } + return &p +} + +func (p projectPublishLinkDo) FirstOrInit() (*model.ProjectPublishLink, error) { + if result, err := p.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.ProjectPublishLink), nil + } +} + +func (p projectPublishLinkDo) FirstOrCreate() (*model.ProjectPublishLink, error) { + if result, err := p.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.ProjectPublishLink), nil + } +} + +func (p projectPublishLinkDo) FindByPage(offset int, limit int) (result []*model.ProjectPublishLink, count int64, err error) { + result, err = p.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = p.Offset(-1).Limit(-1).Count() + return +} + +func (p projectPublishLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = p.Count() + if err != nil { + return + } + + err = p.Offset(offset).Limit(limit).Scan(result) + return +} + +func (p projectPublishLinkDo) Scan(result interface{}) (err error) { + return p.DO.Scan(result) +} + +func (p projectPublishLinkDo) Delete(models ...*model.ProjectPublishLink) (result gen.ResultInfo, err error) { + return p.DO.Delete(models) +} + +func (p *projectPublishLinkDo) withDO(do gen.Dao) *projectPublishLinkDo { + p.DO = *do.(*gen.DO) + return p +} diff --git a/db/dbquery/project_train_size.gen.go b/db/dbquery/project_train_size.gen.go new file mode 100644 index 0000000..888c060 --- /dev/null +++ b/db/dbquery/project_train_size.gen.go @@ -0,0 +1,388 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newProjectTrainSize(db *gorm.DB, opts ...gen.DOOption) projectTrainSize { + _projectTrainSize := projectTrainSize{} + + _projectTrainSize.projectTrainSizeDo.UseDB(db, opts...) + _projectTrainSize.projectTrainSizeDo.UseModel(&model.ProjectTrainSize{}) + + tableName := _projectTrainSize.projectTrainSizeDo.TableName() + _projectTrainSize.ALL = field.NewAsterisk(tableName) + _projectTrainSize.ID = field.NewInt32(tableName, "id") + _projectTrainSize.Pid = field.NewInt32(tableName, "pid") + _projectTrainSize.Sid = field.NewInt32(tableName, "sid") + + _projectTrainSize.fillFieldMap() + + return _projectTrainSize +} + +type projectTrainSize struct { + projectTrainSizeDo + + ALL field.Asterisk + ID field.Int32 // 主键 + Pid field.Int32 // 项目主键 + Sid field.Int32 // 列车尺寸主键 + + fieldMap map[string]field.Expr +} + +func (p projectTrainSize) Table(newTableName string) *projectTrainSize { + p.projectTrainSizeDo.UseTable(newTableName) + return p.updateTableName(newTableName) +} + +func (p projectTrainSize) As(alias string) *projectTrainSize { + p.projectTrainSizeDo.DO = *(p.projectTrainSizeDo.As(alias).(*gen.DO)) + return p.updateTableName(alias) +} + +func (p *projectTrainSize) updateTableName(table string) *projectTrainSize { + p.ALL = field.NewAsterisk(table) + p.ID = field.NewInt32(table, "id") + p.Pid = field.NewInt32(table, "pid") + p.Sid = field.NewInt32(table, "sid") + + p.fillFieldMap() + + return p +} + +func (p *projectTrainSize) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := p.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (p *projectTrainSize) fillFieldMap() { + p.fieldMap = make(map[string]field.Expr, 3) + p.fieldMap["id"] = p.ID + p.fieldMap["pid"] = p.Pid + p.fieldMap["sid"] = p.Sid +} + +func (p projectTrainSize) clone(db *gorm.DB) projectTrainSize { + p.projectTrainSizeDo.ReplaceConnPool(db.Statement.ConnPool) + return p +} + +func (p projectTrainSize) replaceDB(db *gorm.DB) projectTrainSize { + p.projectTrainSizeDo.ReplaceDB(db) + return p +} + +type projectTrainSizeDo struct{ gen.DO } + +type IProjectTrainSizeDo interface { + gen.SubQuery + Debug() IProjectTrainSizeDo + WithContext(ctx context.Context) IProjectTrainSizeDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() IProjectTrainSizeDo + WriteDB() IProjectTrainSizeDo + As(alias string) gen.Dao + Session(config *gorm.Session) IProjectTrainSizeDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) IProjectTrainSizeDo + Not(conds ...gen.Condition) IProjectTrainSizeDo + Or(conds ...gen.Condition) IProjectTrainSizeDo + Select(conds ...field.Expr) IProjectTrainSizeDo + Where(conds ...gen.Condition) IProjectTrainSizeDo + Order(conds ...field.Expr) IProjectTrainSizeDo + Distinct(cols ...field.Expr) IProjectTrainSizeDo + Omit(cols ...field.Expr) IProjectTrainSizeDo + Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo + LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo + RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo + Group(cols ...field.Expr) IProjectTrainSizeDo + Having(conds ...gen.Condition) IProjectTrainSizeDo + Limit(limit int) IProjectTrainSizeDo + Offset(offset int) IProjectTrainSizeDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeDo + Unscoped() IProjectTrainSizeDo + Create(values ...*model.ProjectTrainSize) error + CreateInBatches(values []*model.ProjectTrainSize, batchSize int) error + Save(values ...*model.ProjectTrainSize) error + First() (*model.ProjectTrainSize, error) + Take() (*model.ProjectTrainSize, error) + Last() (*model.ProjectTrainSize, error) + Find() ([]*model.ProjectTrainSize, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSize, err error) + FindInBatches(result *[]*model.ProjectTrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.ProjectTrainSize) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) IProjectTrainSizeDo + Assign(attrs ...field.AssignExpr) IProjectTrainSizeDo + Joins(fields ...field.RelationField) IProjectTrainSizeDo + Preload(fields ...field.RelationField) IProjectTrainSizeDo + FirstOrInit() (*model.ProjectTrainSize, error) + FirstOrCreate() (*model.ProjectTrainSize, error) + FindByPage(offset int, limit int) (result []*model.ProjectTrainSize, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) IProjectTrainSizeDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (p projectTrainSizeDo) Debug() IProjectTrainSizeDo { + return p.withDO(p.DO.Debug()) +} + +func (p projectTrainSizeDo) WithContext(ctx context.Context) IProjectTrainSizeDo { + return p.withDO(p.DO.WithContext(ctx)) +} + +func (p projectTrainSizeDo) ReadDB() IProjectTrainSizeDo { + return p.Clauses(dbresolver.Read) +} + +func (p projectTrainSizeDo) WriteDB() IProjectTrainSizeDo { + return p.Clauses(dbresolver.Write) +} + +func (p projectTrainSizeDo) Session(config *gorm.Session) IProjectTrainSizeDo { + return p.withDO(p.DO.Session(config)) +} + +func (p projectTrainSizeDo) Clauses(conds ...clause.Expression) IProjectTrainSizeDo { + return p.withDO(p.DO.Clauses(conds...)) +} + +func (p projectTrainSizeDo) Returning(value interface{}, columns ...string) IProjectTrainSizeDo { + return p.withDO(p.DO.Returning(value, columns...)) +} + +func (p projectTrainSizeDo) Not(conds ...gen.Condition) IProjectTrainSizeDo { + return p.withDO(p.DO.Not(conds...)) +} + +func (p projectTrainSizeDo) Or(conds ...gen.Condition) IProjectTrainSizeDo { + return p.withDO(p.DO.Or(conds...)) +} + +func (p projectTrainSizeDo) Select(conds ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Select(conds...)) +} + +func (p projectTrainSizeDo) Where(conds ...gen.Condition) IProjectTrainSizeDo { + return p.withDO(p.DO.Where(conds...)) +} + +func (p projectTrainSizeDo) Order(conds ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Order(conds...)) +} + +func (p projectTrainSizeDo) Distinct(cols ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Distinct(cols...)) +} + +func (p projectTrainSizeDo) Omit(cols ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Omit(cols...)) +} + +func (p projectTrainSizeDo) Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Join(table, on...)) +} + +func (p projectTrainSizeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.LeftJoin(table, on...)) +} + +func (p projectTrainSizeDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.RightJoin(table, on...)) +} + +func (p projectTrainSizeDo) Group(cols ...field.Expr) IProjectTrainSizeDo { + return p.withDO(p.DO.Group(cols...)) +} + +func (p projectTrainSizeDo) Having(conds ...gen.Condition) IProjectTrainSizeDo { + return p.withDO(p.DO.Having(conds...)) +} + +func (p projectTrainSizeDo) Limit(limit int) IProjectTrainSizeDo { + return p.withDO(p.DO.Limit(limit)) +} + +func (p projectTrainSizeDo) Offset(offset int) IProjectTrainSizeDo { + return p.withDO(p.DO.Offset(offset)) +} + +func (p projectTrainSizeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeDo { + return p.withDO(p.DO.Scopes(funcs...)) +} + +func (p projectTrainSizeDo) Unscoped() IProjectTrainSizeDo { + return p.withDO(p.DO.Unscoped()) +} + +func (p projectTrainSizeDo) Create(values ...*model.ProjectTrainSize) error { + if len(values) == 0 { + return nil + } + return p.DO.Create(values) +} + +func (p projectTrainSizeDo) CreateInBatches(values []*model.ProjectTrainSize, batchSize int) error { + return p.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (p projectTrainSizeDo) Save(values ...*model.ProjectTrainSize) error { + if len(values) == 0 { + return nil + } + return p.DO.Save(values) +} + +func (p projectTrainSizeDo) First() (*model.ProjectTrainSize, error) { + if result, err := p.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSize), nil + } +} + +func (p projectTrainSizeDo) Take() (*model.ProjectTrainSize, error) { + if result, err := p.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSize), nil + } +} + +func (p projectTrainSizeDo) Last() (*model.ProjectTrainSize, error) { + if result, err := p.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSize), nil + } +} + +func (p projectTrainSizeDo) Find() ([]*model.ProjectTrainSize, error) { + result, err := p.DO.Find() + return result.([]*model.ProjectTrainSize), err +} + +func (p projectTrainSizeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSize, err error) { + buf := make([]*model.ProjectTrainSize, 0, batchSize) + err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (p projectTrainSizeDo) FindInBatches(result *[]*model.ProjectTrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return p.DO.FindInBatches(result, batchSize, fc) +} + +func (p projectTrainSizeDo) Attrs(attrs ...field.AssignExpr) IProjectTrainSizeDo { + return p.withDO(p.DO.Attrs(attrs...)) +} + +func (p projectTrainSizeDo) Assign(attrs ...field.AssignExpr) IProjectTrainSizeDo { + return p.withDO(p.DO.Assign(attrs...)) +} + +func (p projectTrainSizeDo) Joins(fields ...field.RelationField) IProjectTrainSizeDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Joins(_f)) + } + return &p +} + +func (p projectTrainSizeDo) Preload(fields ...field.RelationField) IProjectTrainSizeDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Preload(_f)) + } + return &p +} + +func (p projectTrainSizeDo) FirstOrInit() (*model.ProjectTrainSize, error) { + if result, err := p.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSize), nil + } +} + +func (p projectTrainSizeDo) FirstOrCreate() (*model.ProjectTrainSize, error) { + if result, err := p.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSize), nil + } +} + +func (p projectTrainSizeDo) FindByPage(offset int, limit int) (result []*model.ProjectTrainSize, count int64, err error) { + result, err = p.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = p.Offset(-1).Limit(-1).Count() + return +} + +func (p projectTrainSizeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = p.Count() + if err != nil { + return + } + + err = p.Offset(offset).Limit(limit).Scan(result) + return +} + +func (p projectTrainSizeDo) Scan(result interface{}) (err error) { + return p.DO.Scan(result) +} + +func (p projectTrainSizeDo) Delete(models ...*model.ProjectTrainSize) (result gen.ResultInfo, err error) { + return p.DO.Delete(models) +} + +func (p *projectTrainSizeDo) withDO(do gen.Dao) *projectTrainSizeDo { + p.DO = *do.(*gen.DO) + return p +} diff --git a/db/dbquery/project_train_size_link.gen.go b/db/dbquery/project_train_size_link.gen.go new file mode 100644 index 0000000..b18efcd --- /dev/null +++ b/db/dbquery/project_train_size_link.gen.go @@ -0,0 +1,388 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newProjectTrainSizeLink(db *gorm.DB, opts ...gen.DOOption) projectTrainSizeLink { + _projectTrainSizeLink := projectTrainSizeLink{} + + _projectTrainSizeLink.projectTrainSizeLinkDo.UseDB(db, opts...) + _projectTrainSizeLink.projectTrainSizeLinkDo.UseModel(&model.ProjectTrainSizeLink{}) + + tableName := _projectTrainSizeLink.projectTrainSizeLinkDo.TableName() + _projectTrainSizeLink.ALL = field.NewAsterisk(tableName) + _projectTrainSizeLink.ID = field.NewInt32(tableName, "id") + _projectTrainSizeLink.Pid = field.NewInt32(tableName, "pid") + _projectTrainSizeLink.Sid = field.NewInt32(tableName, "sid") + + _projectTrainSizeLink.fillFieldMap() + + return _projectTrainSizeLink +} + +type projectTrainSizeLink struct { + projectTrainSizeLinkDo + + ALL field.Asterisk + ID field.Int32 // 主键 + Pid field.Int32 // 项目主键 + Sid field.Int32 // 列车尺寸主键 + + fieldMap map[string]field.Expr +} + +func (p projectTrainSizeLink) Table(newTableName string) *projectTrainSizeLink { + p.projectTrainSizeLinkDo.UseTable(newTableName) + return p.updateTableName(newTableName) +} + +func (p projectTrainSizeLink) As(alias string) *projectTrainSizeLink { + p.projectTrainSizeLinkDo.DO = *(p.projectTrainSizeLinkDo.As(alias).(*gen.DO)) + return p.updateTableName(alias) +} + +func (p *projectTrainSizeLink) updateTableName(table string) *projectTrainSizeLink { + p.ALL = field.NewAsterisk(table) + p.ID = field.NewInt32(table, "id") + p.Pid = field.NewInt32(table, "pid") + p.Sid = field.NewInt32(table, "sid") + + p.fillFieldMap() + + return p +} + +func (p *projectTrainSizeLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := p.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (p *projectTrainSizeLink) fillFieldMap() { + p.fieldMap = make(map[string]field.Expr, 3) + p.fieldMap["id"] = p.ID + p.fieldMap["pid"] = p.Pid + p.fieldMap["sid"] = p.Sid +} + +func (p projectTrainSizeLink) clone(db *gorm.DB) projectTrainSizeLink { + p.projectTrainSizeLinkDo.ReplaceConnPool(db.Statement.ConnPool) + return p +} + +func (p projectTrainSizeLink) replaceDB(db *gorm.DB) projectTrainSizeLink { + p.projectTrainSizeLinkDo.ReplaceDB(db) + return p +} + +type projectTrainSizeLinkDo struct{ gen.DO } + +type IProjectTrainSizeLinkDo interface { + gen.SubQuery + Debug() IProjectTrainSizeLinkDo + WithContext(ctx context.Context) IProjectTrainSizeLinkDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() IProjectTrainSizeLinkDo + WriteDB() IProjectTrainSizeLinkDo + As(alias string) gen.Dao + Session(config *gorm.Session) IProjectTrainSizeLinkDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo + Not(conds ...gen.Condition) IProjectTrainSizeLinkDo + Or(conds ...gen.Condition) IProjectTrainSizeLinkDo + Select(conds ...field.Expr) IProjectTrainSizeLinkDo + Where(conds ...gen.Condition) IProjectTrainSizeLinkDo + Order(conds ...field.Expr) IProjectTrainSizeLinkDo + Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo + Omit(cols ...field.Expr) IProjectTrainSizeLinkDo + Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo + LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo + RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo + Group(cols ...field.Expr) IProjectTrainSizeLinkDo + Having(conds ...gen.Condition) IProjectTrainSizeLinkDo + Limit(limit int) IProjectTrainSizeLinkDo + Offset(offset int) IProjectTrainSizeLinkDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo + Unscoped() IProjectTrainSizeLinkDo + Create(values ...*model.ProjectTrainSizeLink) error + CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error + Save(values ...*model.ProjectTrainSizeLink) error + First() (*model.ProjectTrainSizeLink, error) + Take() (*model.ProjectTrainSizeLink, error) + Last() (*model.ProjectTrainSizeLink, error) + Find() ([]*model.ProjectTrainSizeLink, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error) + FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.ProjectTrainSizeLink) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo + Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo + Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo + Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo + FirstOrInit() (*model.ProjectTrainSizeLink, error) + FirstOrCreate() (*model.ProjectTrainSizeLink, error) + FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) IProjectTrainSizeLinkDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (p projectTrainSizeLinkDo) Debug() IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Debug()) +} + +func (p projectTrainSizeLinkDo) WithContext(ctx context.Context) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.WithContext(ctx)) +} + +func (p projectTrainSizeLinkDo) ReadDB() IProjectTrainSizeLinkDo { + return p.Clauses(dbresolver.Read) +} + +func (p projectTrainSizeLinkDo) WriteDB() IProjectTrainSizeLinkDo { + return p.Clauses(dbresolver.Write) +} + +func (p projectTrainSizeLinkDo) Session(config *gorm.Session) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Session(config)) +} + +func (p projectTrainSizeLinkDo) Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Clauses(conds...)) +} + +func (p projectTrainSizeLinkDo) Returning(value interface{}, columns ...string) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Returning(value, columns...)) +} + +func (p projectTrainSizeLinkDo) Not(conds ...gen.Condition) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Not(conds...)) +} + +func (p projectTrainSizeLinkDo) Or(conds ...gen.Condition) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Or(conds...)) +} + +func (p projectTrainSizeLinkDo) Select(conds ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Select(conds...)) +} + +func (p projectTrainSizeLinkDo) Where(conds ...gen.Condition) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Where(conds...)) +} + +func (p projectTrainSizeLinkDo) Order(conds ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Order(conds...)) +} + +func (p projectTrainSizeLinkDo) Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Distinct(cols...)) +} + +func (p projectTrainSizeLinkDo) Omit(cols ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Omit(cols...)) +} + +func (p projectTrainSizeLinkDo) Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Join(table, on...)) +} + +func (p projectTrainSizeLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.LeftJoin(table, on...)) +} + +func (p projectTrainSizeLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.RightJoin(table, on...)) +} + +func (p projectTrainSizeLinkDo) Group(cols ...field.Expr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Group(cols...)) +} + +func (p projectTrainSizeLinkDo) Having(conds ...gen.Condition) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Having(conds...)) +} + +func (p projectTrainSizeLinkDo) Limit(limit int) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Limit(limit)) +} + +func (p projectTrainSizeLinkDo) Offset(offset int) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Offset(offset)) +} + +func (p projectTrainSizeLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Scopes(funcs...)) +} + +func (p projectTrainSizeLinkDo) Unscoped() IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Unscoped()) +} + +func (p projectTrainSizeLinkDo) Create(values ...*model.ProjectTrainSizeLink) error { + if len(values) == 0 { + return nil + } + return p.DO.Create(values) +} + +func (p projectTrainSizeLinkDo) CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error { + return p.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (p projectTrainSizeLinkDo) Save(values ...*model.ProjectTrainSizeLink) error { + if len(values) == 0 { + return nil + } + return p.DO.Save(values) +} + +func (p projectTrainSizeLinkDo) First() (*model.ProjectTrainSizeLink, error) { + if result, err := p.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSizeLink), nil + } +} + +func (p projectTrainSizeLinkDo) Take() (*model.ProjectTrainSizeLink, error) { + if result, err := p.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSizeLink), nil + } +} + +func (p projectTrainSizeLinkDo) Last() (*model.ProjectTrainSizeLink, error) { + if result, err := p.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSizeLink), nil + } +} + +func (p projectTrainSizeLinkDo) Find() ([]*model.ProjectTrainSizeLink, error) { + result, err := p.DO.Find() + return result.([]*model.ProjectTrainSizeLink), err +} + +func (p projectTrainSizeLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error) { + buf := make([]*model.ProjectTrainSizeLink, 0, batchSize) + err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (p projectTrainSizeLinkDo) FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return p.DO.FindInBatches(result, batchSize, fc) +} + +func (p projectTrainSizeLinkDo) Attrs(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Attrs(attrs...)) +} + +func (p projectTrainSizeLinkDo) Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo { + return p.withDO(p.DO.Assign(attrs...)) +} + +func (p projectTrainSizeLinkDo) Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Joins(_f)) + } + return &p +} + +func (p projectTrainSizeLinkDo) Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo { + for _, _f := range fields { + p = *p.withDO(p.DO.Preload(_f)) + } + return &p +} + +func (p projectTrainSizeLinkDo) FirstOrInit() (*model.ProjectTrainSizeLink, error) { + if result, err := p.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSizeLink), nil + } +} + +func (p projectTrainSizeLinkDo) FirstOrCreate() (*model.ProjectTrainSizeLink, error) { + if result, err := p.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.ProjectTrainSizeLink), nil + } +} + +func (p projectTrainSizeLinkDo) FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, count int64, err error) { + result, err = p.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = p.Offset(-1).Limit(-1).Count() + return +} + +func (p projectTrainSizeLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = p.Count() + if err != nil { + return + } + + err = p.Offset(offset).Limit(limit).Scan(result) + return +} + +func (p projectTrainSizeLinkDo) Scan(result interface{}) (err error) { + return p.DO.Scan(result) +} + +func (p projectTrainSizeLinkDo) Delete(models ...*model.ProjectTrainSizeLink) (result gen.ResultInfo, err error) { + return p.DO.Delete(models) +} + +func (p *projectTrainSizeLinkDo) withDO(do gen.Dao) *projectTrainSizeLinkDo { + p.DO = *do.(*gen.DO) + return p +} diff --git a/db/dbquery/train_model.gen.go b/db/dbquery/train_model.gen.go index da39e72..1f88009 100644 --- a/db/dbquery/train_model.gen.go +++ b/db/dbquery/train_model.gen.go @@ -29,7 +29,6 @@ func newTrainModel(db *gorm.DB, opts ...gen.DOOption) trainModel { _trainModel.ALL = field.NewAsterisk(tableName) _trainModel.ID = field.NewInt32(tableName, "id") _trainModel.Name = field.NewString(tableName, "name") - _trainModel.CarriageLength = field.NewInt32(tableName, "carriage_length") _trainModel.CreatedAt = field.NewTime(tableName, "created_at") _trainModel.UpdateAt = field.NewTime(tableName, "update_at") @@ -41,12 +40,11 @@ func newTrainModel(db *gorm.DB, opts ...gen.DOOption) trainModel { type trainModel struct { trainModelDo - ALL field.Asterisk - ID field.Int32 - Name field.String // 组次名称 - CarriageLength field.Int32 // 单个车厢长度 - CreatedAt field.Time // 创建时间 - UpdateAt field.Time // 更新时间 + ALL field.Asterisk + ID field.Int32 + Name field.String // 组次名称 + CreatedAt field.Time // 创建时间 + UpdateAt field.Time // 更新时间 fieldMap map[string]field.Expr } @@ -65,7 +63,6 @@ func (t *trainModel) updateTableName(table string) *trainModel { t.ALL = field.NewAsterisk(table) t.ID = field.NewInt32(table, "id") t.Name = field.NewString(table, "name") - t.CarriageLength = field.NewInt32(table, "carriage_length") t.CreatedAt = field.NewTime(table, "created_at") t.UpdateAt = field.NewTime(table, "update_at") @@ -84,10 +81,9 @@ func (t *trainModel) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (t *trainModel) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 5) + t.fieldMap = make(map[string]field.Expr, 4) t.fieldMap["id"] = t.ID t.fieldMap["name"] = t.Name - t.fieldMap["carriage_length"] = t.CarriageLength t.fieldMap["created_at"] = t.CreatedAt t.fieldMap["update_at"] = t.UpdateAt } diff --git a/db/dbquery/train_size.gen.go b/db/dbquery/train_size.gen.go new file mode 100644 index 0000000..cb1e62a --- /dev/null +++ b/db/dbquery/train_size.gen.go @@ -0,0 +1,396 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newTrainSize(db *gorm.DB, opts ...gen.DOOption) trainSize { + _trainSize := trainSize{} + + _trainSize.trainSizeDo.UseDB(db, opts...) + _trainSize.trainSizeDo.UseModel(&model.TrainSize{}) + + tableName := _trainSize.trainSizeDo.TableName() + _trainSize.ALL = field.NewAsterisk(tableName) + _trainSize.ID = field.NewInt32(tableName, "id") + _trainSize.Name = field.NewString(tableName, "name") + _trainSize.CarriageLength = field.NewInt32(tableName, "carriage_length") + _trainSize.TotalLength = field.NewInt32(tableName, "total_length") + _trainSize.Description = field.NewString(tableName, "description") + + _trainSize.fillFieldMap() + + return _trainSize +} + +type trainSize struct { + trainSizeDo + + ALL field.Asterisk + ID field.Int32 // 主键 + Name field.String // 名称 + CarriageLength field.Int32 // 列车车厢长度 + TotalLength field.Int32 // 总长度 + Description field.String // 其他描述内容 + + fieldMap map[string]field.Expr +} + +func (t trainSize) Table(newTableName string) *trainSize { + t.trainSizeDo.UseTable(newTableName) + return t.updateTableName(newTableName) +} + +func (t trainSize) As(alias string) *trainSize { + t.trainSizeDo.DO = *(t.trainSizeDo.As(alias).(*gen.DO)) + return t.updateTableName(alias) +} + +func (t *trainSize) updateTableName(table string) *trainSize { + t.ALL = field.NewAsterisk(table) + t.ID = field.NewInt32(table, "id") + t.Name = field.NewString(table, "name") + t.CarriageLength = field.NewInt32(table, "carriage_length") + t.TotalLength = field.NewInt32(table, "total_length") + t.Description = field.NewString(table, "description") + + t.fillFieldMap() + + return t +} + +func (t *trainSize) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := t.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (t *trainSize) fillFieldMap() { + t.fieldMap = make(map[string]field.Expr, 5) + t.fieldMap["id"] = t.ID + t.fieldMap["name"] = t.Name + t.fieldMap["carriage_length"] = t.CarriageLength + t.fieldMap["total_length"] = t.TotalLength + t.fieldMap["description"] = t.Description +} + +func (t trainSize) clone(db *gorm.DB) trainSize { + t.trainSizeDo.ReplaceConnPool(db.Statement.ConnPool) + return t +} + +func (t trainSize) replaceDB(db *gorm.DB) trainSize { + t.trainSizeDo.ReplaceDB(db) + return t +} + +type trainSizeDo struct{ gen.DO } + +type ITrainSizeDo interface { + gen.SubQuery + Debug() ITrainSizeDo + WithContext(ctx context.Context) ITrainSizeDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() ITrainSizeDo + WriteDB() ITrainSizeDo + As(alias string) gen.Dao + Session(config *gorm.Session) ITrainSizeDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) ITrainSizeDo + Not(conds ...gen.Condition) ITrainSizeDo + Or(conds ...gen.Condition) ITrainSizeDo + Select(conds ...field.Expr) ITrainSizeDo + Where(conds ...gen.Condition) ITrainSizeDo + Order(conds ...field.Expr) ITrainSizeDo + Distinct(cols ...field.Expr) ITrainSizeDo + Omit(cols ...field.Expr) ITrainSizeDo + Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo + LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo + RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo + Group(cols ...field.Expr) ITrainSizeDo + Having(conds ...gen.Condition) ITrainSizeDo + Limit(limit int) ITrainSizeDo + Offset(offset int) ITrainSizeDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo + Unscoped() ITrainSizeDo + Create(values ...*model.TrainSize) error + CreateInBatches(values []*model.TrainSize, batchSize int) error + Save(values ...*model.TrainSize) error + First() (*model.TrainSize, error) + Take() (*model.TrainSize, error) + Last() (*model.TrainSize, error) + Find() ([]*model.TrainSize, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) + FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.TrainSize) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) ITrainSizeDo + Assign(attrs ...field.AssignExpr) ITrainSizeDo + Joins(fields ...field.RelationField) ITrainSizeDo + Preload(fields ...field.RelationField) ITrainSizeDo + FirstOrInit() (*model.TrainSize, error) + FirstOrCreate() (*model.TrainSize, error) + FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) ITrainSizeDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (t trainSizeDo) Debug() ITrainSizeDo { + return t.withDO(t.DO.Debug()) +} + +func (t trainSizeDo) WithContext(ctx context.Context) ITrainSizeDo { + return t.withDO(t.DO.WithContext(ctx)) +} + +func (t trainSizeDo) ReadDB() ITrainSizeDo { + return t.Clauses(dbresolver.Read) +} + +func (t trainSizeDo) WriteDB() ITrainSizeDo { + return t.Clauses(dbresolver.Write) +} + +func (t trainSizeDo) Session(config *gorm.Session) ITrainSizeDo { + return t.withDO(t.DO.Session(config)) +} + +func (t trainSizeDo) Clauses(conds ...clause.Expression) ITrainSizeDo { + return t.withDO(t.DO.Clauses(conds...)) +} + +func (t trainSizeDo) Returning(value interface{}, columns ...string) ITrainSizeDo { + return t.withDO(t.DO.Returning(value, columns...)) +} + +func (t trainSizeDo) Not(conds ...gen.Condition) ITrainSizeDo { + return t.withDO(t.DO.Not(conds...)) +} + +func (t trainSizeDo) Or(conds ...gen.Condition) ITrainSizeDo { + return t.withDO(t.DO.Or(conds...)) +} + +func (t trainSizeDo) Select(conds ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Select(conds...)) +} + +func (t trainSizeDo) Where(conds ...gen.Condition) ITrainSizeDo { + return t.withDO(t.DO.Where(conds...)) +} + +func (t trainSizeDo) Order(conds ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Order(conds...)) +} + +func (t trainSizeDo) Distinct(cols ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Distinct(cols...)) +} + +func (t trainSizeDo) Omit(cols ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Omit(cols...)) +} + +func (t trainSizeDo) Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Join(table, on...)) +} + +func (t trainSizeDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.LeftJoin(table, on...)) +} + +func (t trainSizeDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.RightJoin(table, on...)) +} + +func (t trainSizeDo) Group(cols ...field.Expr) ITrainSizeDo { + return t.withDO(t.DO.Group(cols...)) +} + +func (t trainSizeDo) Having(conds ...gen.Condition) ITrainSizeDo { + return t.withDO(t.DO.Having(conds...)) +} + +func (t trainSizeDo) Limit(limit int) ITrainSizeDo { + return t.withDO(t.DO.Limit(limit)) +} + +func (t trainSizeDo) Offset(offset int) ITrainSizeDo { + return t.withDO(t.DO.Offset(offset)) +} + +func (t trainSizeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo { + return t.withDO(t.DO.Scopes(funcs...)) +} + +func (t trainSizeDo) Unscoped() ITrainSizeDo { + return t.withDO(t.DO.Unscoped()) +} + +func (t trainSizeDo) Create(values ...*model.TrainSize) error { + if len(values) == 0 { + return nil + } + return t.DO.Create(values) +} + +func (t trainSizeDo) CreateInBatches(values []*model.TrainSize, batchSize int) error { + return t.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (t trainSizeDo) Save(values ...*model.TrainSize) error { + if len(values) == 0 { + return nil + } + return t.DO.Save(values) +} + +func (t trainSizeDo) First() (*model.TrainSize, error) { + if result, err := t.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.TrainSize), nil + } +} + +func (t trainSizeDo) Take() (*model.TrainSize, error) { + if result, err := t.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.TrainSize), nil + } +} + +func (t trainSizeDo) Last() (*model.TrainSize, error) { + if result, err := t.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.TrainSize), nil + } +} + +func (t trainSizeDo) Find() ([]*model.TrainSize, error) { + result, err := t.DO.Find() + return result.([]*model.TrainSize), err +} + +func (t trainSizeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) { + buf := make([]*model.TrainSize, 0, batchSize) + err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (t trainSizeDo) FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return t.DO.FindInBatches(result, batchSize, fc) +} + +func (t trainSizeDo) Attrs(attrs ...field.AssignExpr) ITrainSizeDo { + return t.withDO(t.DO.Attrs(attrs...)) +} + +func (t trainSizeDo) Assign(attrs ...field.AssignExpr) ITrainSizeDo { + return t.withDO(t.DO.Assign(attrs...)) +} + +func (t trainSizeDo) Joins(fields ...field.RelationField) ITrainSizeDo { + for _, _f := range fields { + t = *t.withDO(t.DO.Joins(_f)) + } + return &t +} + +func (t trainSizeDo) Preload(fields ...field.RelationField) ITrainSizeDo { + for _, _f := range fields { + t = *t.withDO(t.DO.Preload(_f)) + } + return &t +} + +func (t trainSizeDo) FirstOrInit() (*model.TrainSize, error) { + if result, err := t.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.TrainSize), nil + } +} + +func (t trainSizeDo) FirstOrCreate() (*model.TrainSize, error) { + if result, err := t.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.TrainSize), nil + } +} + +func (t trainSizeDo) FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) { + result, err = t.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = t.Offset(-1).Limit(-1).Count() + return +} + +func (t trainSizeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = t.Count() + if err != nil { + return + } + + err = t.Offset(offset).Limit(limit).Scan(result) + return +} + +func (t trainSizeDo) Scan(result interface{}) (err error) { + return t.DO.Scan(result) +} + +func (t trainSizeDo) Delete(models ...*model.TrainSize) (result gen.ResultInfo, err error) { + return t.DO.Delete(models) +} + +func (t *trainSizeDo) withDO(do gen.Dao) *trainSizeDo { + t.DO = *do.(*gen.DO) + return t +} diff --git a/db/dbquery/train_wheel_diameter.gen.go b/db/dbquery/train_wheel_diameter.gen.go new file mode 100644 index 0000000..6b512d4 --- /dev/null +++ b/db/dbquery/train_wheel_diameter.gen.go @@ -0,0 +1,408 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package dbquery + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "joylink.club/bj-rtsts-server/db/model" +) + +func newTrainWheelDiameter(db *gorm.DB, opts ...gen.DOOption) trainWheelDiameter { + _trainWheelDiameter := trainWheelDiameter{} + + _trainWheelDiameter.trainWheelDiameterDo.UseDB(db, opts...) + _trainWheelDiameter.trainWheelDiameterDo.UseModel(&model.TrainWheelDiameter{}) + + tableName := _trainWheelDiameter.trainWheelDiameterDo.TableName() + _trainWheelDiameter.ALL = field.NewAsterisk(tableName) + _trainWheelDiameter.ID = field.NewInt32(tableName, "id") + _trainWheelDiameter.Name = field.NewString(tableName, "name") + _trainWheelDiameter.Diameter = field.NewInt32(tableName, "diameter") + _trainWheelDiameter.MinDiameter = field.NewInt32(tableName, "min_diameter") + _trainWheelDiameter.MaxDiameter = field.NewInt32(tableName, "max_diameter") + _trainWheelDiameter.AxialPosition = field.NewInt32(tableName, "axial_position") + _trainWheelDiameter.InstallDirection = field.NewString(tableName, "install_direction") + + _trainWheelDiameter.fillFieldMap() + + return _trainWheelDiameter +} + +type trainWheelDiameter struct { + trainWheelDiameterDo + + ALL field.Asterisk + ID field.Int32 + Name field.String // 名称 + Diameter field.Int32 // 速度传感器安装处车轮的出厂直径(mm) + MinDiameter field.Int32 // 速度传感器安装处车轮的最小直径(mm) + MaxDiameter field.Int32 // 速度传感器安装处车轮的最大直径(mm) + AxialPosition field.Int32 // 速度传感器安装轴位,本端车前进方向的第几轴 + /* + 速度传感器安装方向, + 本端车前进方向的左侧或右侧 + */ + InstallDirection field.String + + fieldMap map[string]field.Expr +} + +func (t trainWheelDiameter) Table(newTableName string) *trainWheelDiameter { + t.trainWheelDiameterDo.UseTable(newTableName) + return t.updateTableName(newTableName) +} + +func (t trainWheelDiameter) As(alias string) *trainWheelDiameter { + t.trainWheelDiameterDo.DO = *(t.trainWheelDiameterDo.As(alias).(*gen.DO)) + return t.updateTableName(alias) +} + +func (t *trainWheelDiameter) updateTableName(table string) *trainWheelDiameter { + t.ALL = field.NewAsterisk(table) + t.ID = field.NewInt32(table, "id") + t.Name = field.NewString(table, "name") + t.Diameter = field.NewInt32(table, "diameter") + t.MinDiameter = field.NewInt32(table, "min_diameter") + t.MaxDiameter = field.NewInt32(table, "max_diameter") + t.AxialPosition = field.NewInt32(table, "axial_position") + t.InstallDirection = field.NewString(table, "install_direction") + + t.fillFieldMap() + + return t +} + +func (t *trainWheelDiameter) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := t.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (t *trainWheelDiameter) fillFieldMap() { + t.fieldMap = make(map[string]field.Expr, 7) + t.fieldMap["id"] = t.ID + t.fieldMap["name"] = t.Name + t.fieldMap["diameter"] = t.Diameter + t.fieldMap["min_diameter"] = t.MinDiameter + t.fieldMap["max_diameter"] = t.MaxDiameter + t.fieldMap["axial_position"] = t.AxialPosition + t.fieldMap["install_direction"] = t.InstallDirection +} + +func (t trainWheelDiameter) clone(db *gorm.DB) trainWheelDiameter { + t.trainWheelDiameterDo.ReplaceConnPool(db.Statement.ConnPool) + return t +} + +func (t trainWheelDiameter) replaceDB(db *gorm.DB) trainWheelDiameter { + t.trainWheelDiameterDo.ReplaceDB(db) + return t +} + +type trainWheelDiameterDo struct{ gen.DO } + +type ITrainWheelDiameterDo interface { + gen.SubQuery + Debug() ITrainWheelDiameterDo + WithContext(ctx context.Context) ITrainWheelDiameterDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() ITrainWheelDiameterDo + WriteDB() ITrainWheelDiameterDo + As(alias string) gen.Dao + Session(config *gorm.Session) ITrainWheelDiameterDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) ITrainWheelDiameterDo + Not(conds ...gen.Condition) ITrainWheelDiameterDo + Or(conds ...gen.Condition) ITrainWheelDiameterDo + Select(conds ...field.Expr) ITrainWheelDiameterDo + Where(conds ...gen.Condition) ITrainWheelDiameterDo + Order(conds ...field.Expr) ITrainWheelDiameterDo + Distinct(cols ...field.Expr) ITrainWheelDiameterDo + Omit(cols ...field.Expr) ITrainWheelDiameterDo + Join(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo + LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo + RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo + Group(cols ...field.Expr) ITrainWheelDiameterDo + Having(conds ...gen.Condition) ITrainWheelDiameterDo + Limit(limit int) ITrainWheelDiameterDo + Offset(offset int) ITrainWheelDiameterDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDiameterDo + Unscoped() ITrainWheelDiameterDo + Create(values ...*model.TrainWheelDiameter) error + CreateInBatches(values []*model.TrainWheelDiameter, batchSize int) error + Save(values ...*model.TrainWheelDiameter) error + First() (*model.TrainWheelDiameter, error) + Take() (*model.TrainWheelDiameter, error) + Last() (*model.TrainWheelDiameter, error) + Find() ([]*model.TrainWheelDiameter, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheelDiameter, err error) + FindInBatches(result *[]*model.TrainWheelDiameter, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.TrainWheelDiameter) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) ITrainWheelDiameterDo + Assign(attrs ...field.AssignExpr) ITrainWheelDiameterDo + Joins(fields ...field.RelationField) ITrainWheelDiameterDo + Preload(fields ...field.RelationField) ITrainWheelDiameterDo + FirstOrInit() (*model.TrainWheelDiameter, error) + FirstOrCreate() (*model.TrainWheelDiameter, error) + FindByPage(offset int, limit int) (result []*model.TrainWheelDiameter, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) ITrainWheelDiameterDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (t trainWheelDiameterDo) Debug() ITrainWheelDiameterDo { + return t.withDO(t.DO.Debug()) +} + +func (t trainWheelDiameterDo) WithContext(ctx context.Context) ITrainWheelDiameterDo { + return t.withDO(t.DO.WithContext(ctx)) +} + +func (t trainWheelDiameterDo) ReadDB() ITrainWheelDiameterDo { + return t.Clauses(dbresolver.Read) +} + +func (t trainWheelDiameterDo) WriteDB() ITrainWheelDiameterDo { + return t.Clauses(dbresolver.Write) +} + +func (t trainWheelDiameterDo) Session(config *gorm.Session) ITrainWheelDiameterDo { + return t.withDO(t.DO.Session(config)) +} + +func (t trainWheelDiameterDo) Clauses(conds ...clause.Expression) ITrainWheelDiameterDo { + return t.withDO(t.DO.Clauses(conds...)) +} + +func (t trainWheelDiameterDo) Returning(value interface{}, columns ...string) ITrainWheelDiameterDo { + return t.withDO(t.DO.Returning(value, columns...)) +} + +func (t trainWheelDiameterDo) Not(conds ...gen.Condition) ITrainWheelDiameterDo { + return t.withDO(t.DO.Not(conds...)) +} + +func (t trainWheelDiameterDo) Or(conds ...gen.Condition) ITrainWheelDiameterDo { + return t.withDO(t.DO.Or(conds...)) +} + +func (t trainWheelDiameterDo) Select(conds ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Select(conds...)) +} + +func (t trainWheelDiameterDo) Where(conds ...gen.Condition) ITrainWheelDiameterDo { + return t.withDO(t.DO.Where(conds...)) +} + +func (t trainWheelDiameterDo) Order(conds ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Order(conds...)) +} + +func (t trainWheelDiameterDo) Distinct(cols ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Distinct(cols...)) +} + +func (t trainWheelDiameterDo) Omit(cols ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Omit(cols...)) +} + +func (t trainWheelDiameterDo) Join(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Join(table, on...)) +} + +func (t trainWheelDiameterDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.LeftJoin(table, on...)) +} + +func (t trainWheelDiameterDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.RightJoin(table, on...)) +} + +func (t trainWheelDiameterDo) Group(cols ...field.Expr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Group(cols...)) +} + +func (t trainWheelDiameterDo) Having(conds ...gen.Condition) ITrainWheelDiameterDo { + return t.withDO(t.DO.Having(conds...)) +} + +func (t trainWheelDiameterDo) Limit(limit int) ITrainWheelDiameterDo { + return t.withDO(t.DO.Limit(limit)) +} + +func (t trainWheelDiameterDo) Offset(offset int) ITrainWheelDiameterDo { + return t.withDO(t.DO.Offset(offset)) +} + +func (t trainWheelDiameterDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDiameterDo { + return t.withDO(t.DO.Scopes(funcs...)) +} + +func (t trainWheelDiameterDo) Unscoped() ITrainWheelDiameterDo { + return t.withDO(t.DO.Unscoped()) +} + +func (t trainWheelDiameterDo) Create(values ...*model.TrainWheelDiameter) error { + if len(values) == 0 { + return nil + } + return t.DO.Create(values) +} + +func (t trainWheelDiameterDo) CreateInBatches(values []*model.TrainWheelDiameter, batchSize int) error { + return t.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (t trainWheelDiameterDo) Save(values ...*model.TrainWheelDiameter) error { + if len(values) == 0 { + return nil + } + return t.DO.Save(values) +} + +func (t trainWheelDiameterDo) First() (*model.TrainWheelDiameter, error) { + if result, err := t.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.TrainWheelDiameter), nil + } +} + +func (t trainWheelDiameterDo) Take() (*model.TrainWheelDiameter, error) { + if result, err := t.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.TrainWheelDiameter), nil + } +} + +func (t trainWheelDiameterDo) Last() (*model.TrainWheelDiameter, error) { + if result, err := t.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.TrainWheelDiameter), nil + } +} + +func (t trainWheelDiameterDo) Find() ([]*model.TrainWheelDiameter, error) { + result, err := t.DO.Find() + return result.([]*model.TrainWheelDiameter), err +} + +func (t trainWheelDiameterDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheelDiameter, err error) { + buf := make([]*model.TrainWheelDiameter, 0, batchSize) + err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (t trainWheelDiameterDo) FindInBatches(result *[]*model.TrainWheelDiameter, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return t.DO.FindInBatches(result, batchSize, fc) +} + +func (t trainWheelDiameterDo) Attrs(attrs ...field.AssignExpr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Attrs(attrs...)) +} + +func (t trainWheelDiameterDo) Assign(attrs ...field.AssignExpr) ITrainWheelDiameterDo { + return t.withDO(t.DO.Assign(attrs...)) +} + +func (t trainWheelDiameterDo) Joins(fields ...field.RelationField) ITrainWheelDiameterDo { + for _, _f := range fields { + t = *t.withDO(t.DO.Joins(_f)) + } + return &t +} + +func (t trainWheelDiameterDo) Preload(fields ...field.RelationField) ITrainWheelDiameterDo { + for _, _f := range fields { + t = *t.withDO(t.DO.Preload(_f)) + } + return &t +} + +func (t trainWheelDiameterDo) FirstOrInit() (*model.TrainWheelDiameter, error) { + if result, err := t.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.TrainWheelDiameter), nil + } +} + +func (t trainWheelDiameterDo) FirstOrCreate() (*model.TrainWheelDiameter, error) { + if result, err := t.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.TrainWheelDiameter), nil + } +} + +func (t trainWheelDiameterDo) FindByPage(offset int, limit int) (result []*model.TrainWheelDiameter, count int64, err error) { + result, err = t.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = t.Offset(-1).Limit(-1).Count() + return +} + +func (t trainWheelDiameterDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = t.Count() + if err != nil { + return + } + + err = t.Offset(offset).Limit(limit).Scan(result) + return +} + +func (t trainWheelDiameterDo) Scan(result interface{}) (err error) { + return t.DO.Scan(result) +} + +func (t trainWheelDiameterDo) Delete(models ...*model.TrainWheelDiameter) (result gen.ResultInfo, err error) { + return t.DO.Delete(models) +} + +func (t *trainWheelDiameterDo) withDO(do gen.Dao) *trainWheelDiameterDo { + t.DO = *do.(*gen.DO) + return t +} diff --git a/db/model/project.gen.go b/db/model/project.gen.go new file mode 100644 index 0000000..3813fd1 --- /dev/null +++ b/db/model/project.gen.go @@ -0,0 +1,25 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +import ( + "time" +) + +const TableNameProject = "project" + +// Project mapped from table +type Project struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 + Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 + Code string `gorm:"column:code;comment:项目编码" json:"code"` // 项目编码 + CreatedAt time.Time `gorm:"column:created_at;comment:创建时间" json:"created_at"` // 创建时间 + UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间 +} + +// TableName Project's table name +func (*Project) TableName() string { + return TableNameProject +} diff --git a/db/model/project_publish_link.gen.go b/db/model/project_publish_link.gen.go new file mode 100644 index 0000000..3dd85bc --- /dev/null +++ b/db/model/project_publish_link.gen.go @@ -0,0 +1,19 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +const TableNameProjectPublishLink = "project_publish_link" + +// ProjectPublishLink mapped from table +type ProjectPublishLink struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 + Pid int32 `gorm:"column:pid;comment:项目主键" json:"pid"` // 项目主键 + Mid int32 `gorm:"column:mid;comment:发布的地图ID" json:"mid"` // 发布的地图ID +} + +// TableName ProjectPublishLink's table name +func (*ProjectPublishLink) TableName() string { + return TableNameProjectPublishLink +} diff --git a/db/model/project_train_size.gen.go b/db/model/project_train_size.gen.go new file mode 100644 index 0000000..7af082b --- /dev/null +++ b/db/model/project_train_size.gen.go @@ -0,0 +1,19 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +const TableNameProjectTrainSize = "project_train_size" + +// ProjectTrainSize mapped from table +type ProjectTrainSize struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 + Pid int32 `gorm:"column:pid;comment:项目主键" json:"pid"` // 项目主键 + Sid int32 `gorm:"column:sid;comment:列车尺寸主键" json:"sid"` // 列车尺寸主键 +} + +// TableName ProjectTrainSize's table name +func (*ProjectTrainSize) TableName() string { + return TableNameProjectTrainSize +} diff --git a/db/model/project_train_size_link.gen.go b/db/model/project_train_size_link.gen.go new file mode 100644 index 0000000..c553cf6 --- /dev/null +++ b/db/model/project_train_size_link.gen.go @@ -0,0 +1,19 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +const TableNameProjectTrainSizeLink = "project_train_size_link" + +// ProjectTrainSizeLink mapped from table +type ProjectTrainSizeLink struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 + Pid int32 `gorm:"column:pid;comment:项目主键" json:"pid"` // 项目主键 + Sid int32 `gorm:"column:sid;comment:列车尺寸主键" json:"sid"` // 列车尺寸主键 +} + +// TableName ProjectTrainSizeLink's table name +func (*ProjectTrainSizeLink) TableName() string { + return TableNameProjectTrainSizeLink +} diff --git a/db/model/train_model.gen.go b/db/model/train_model.gen.go index 271516f..7f13f54 100644 --- a/db/model/train_model.gen.go +++ b/db/model/train_model.gen.go @@ -12,11 +12,10 @@ const TableNameTrainModel = "train_model" // TrainModel mapped from table type TrainModel struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` - Name string `gorm:"column:name;comment:组次名称" json:"name"` // 组次名称 - CarriageLength int32 `gorm:"column:carriage_length;comment:单个车厢长度" json:"carriage_length"` // 单个车厢长度 - CreatedAt time.Time `gorm:"column:created_at;comment:创建时间" json:"created_at"` // 创建时间 - UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` + Name string `gorm:"column:name;comment:组次名称" json:"name"` // 组次名称 + CreatedAt time.Time `gorm:"column:created_at;comment:创建时间" json:"created_at"` // 创建时间 + UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间 } // TableName TrainModel's table name diff --git a/db/model/train_size.gen.go b/db/model/train_size.gen.go new file mode 100644 index 0000000..37b0b0f --- /dev/null +++ b/db/model/train_size.gen.go @@ -0,0 +1,21 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +const TableNameTrainSize = "train_size" + +// TrainSize mapped from table +type TrainSize struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 + Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 + CarriageLength int32 `gorm:"column:carriage_length;comment:列车车厢长度" json:"carriage_length"` // 列车车厢长度 + TotalLength int32 `gorm:"column:total_length;comment:总长度" json:"total_length"` // 总长度 + Description string `gorm:"column:description;comment:其他描述内容" json:"description"` // 其他描述内容 +} + +// TableName TrainSize's table name +func (*TrainSize) TableName() string { + return TableNameTrainSize +} diff --git a/db/model/train_wheel_diameter.gen.go b/db/model/train_wheel_diameter.gen.go new file mode 100644 index 0000000..8adcf56 --- /dev/null +++ b/db/model/train_wheel_diameter.gen.go @@ -0,0 +1,27 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +const TableNameTrainWheelDiameter = "train_wheel_diameter" + +// TrainWheelDiameter mapped from table +type TrainWheelDiameter struct { + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` + Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 + Diameter int32 `gorm:"column:diameter;comment:速度传感器安装处车轮的出厂直径(mm)" json:"diameter"` // 速度传感器安装处车轮的出厂直径(mm) + MinDiameter int32 `gorm:"column:min_diameter;comment:速度传感器安装处车轮的最小直径(mm)" json:"min_diameter"` // 速度传感器安装处车轮的最小直径(mm) + MaxDiameter int32 `gorm:"column:max_diameter;comment:速度传感器安装处车轮的最大直径(mm)" json:"max_diameter"` // 速度传感器安装处车轮的最大直径(mm) + AxialPosition int32 `gorm:"column:axial_position;comment:速度传感器安装轴位,本端车前进方向的第几轴" json:"axial_position"` // 速度传感器安装轴位,本端车前进方向的第几轴 + /* + 速度传感器安装方向, + 本端车前进方向的左侧或右侧 + */ + InstallDirection string `gorm:"column:install_direction;comment:速度传感器安装方向,\n本端车前进方向的左侧或右侧" json:"install_direction"` +} + +// TableName TrainWheelDiameter's table name +func (*TrainWheelDiameter) TableName() string { + return TableNameTrainWheelDiameter +} diff --git a/docs/docs.go b/docs/docs.go index 3844597..8103327 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -16,6 +16,368 @@ 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/: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/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/category": { "post": { "security": [ @@ -35,6 +397,11 @@ const docTemplate = `{ ], "summary": "创建厂家信息", "parameters": [ + { + "type": "string", + "name": "code", + "in": "query" + }, { "type": "string", "name": "config", @@ -107,7 +474,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/model.Drafting" + "$ref": "#/definitions/model.Category" } }, "401": { @@ -155,6 +522,11 @@ const docTemplate = `{ "in": "path", "required": true }, + { + "type": "string", + "name": "code", + "in": "query" + }, { "type": "string", "name": "config", @@ -269,22 +641,6 @@ const docTemplate = `{ "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": { @@ -404,7 +760,7 @@ const docTemplate = `{ "summary": "创建草稿", "parameters": [ { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -533,7 +889,7 @@ const docTemplate = `{ "required": true }, { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -659,7 +1015,7 @@ const docTemplate = `{ "required": true }, { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -831,6 +1187,187 @@ const docTemplate = `{ } } }, + "/api/v1/projectLink": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "保存项目的所有关联信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "项目关联信息Api" + ], + "summary": "保存项目的所有关联信息", + "parameters": [ + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "mids", + "in": "query" + }, + { + "type": "integer", + "name": "pid", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "sids", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "boolean" + } + }, + "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/info/: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/dto.ProjectLinkRspDto" + } + }, + "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/trainSize/: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/dto.TrainSizeDto" + } + }, + "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/publishedGi/list": { "get": { "security": [ @@ -991,7 +1528,7 @@ const docTemplate = `{ { "type": "integer", "description": "草稿数据的id", - "name": "draftingId", + "name": "draftId", "in": "query" }, { @@ -1054,7 +1591,7 @@ const docTemplate = `{ { "type": "integer", "description": "草稿数据的id", - "name": "draftingId", + "name": "draftId", "in": "query" }, { @@ -1537,6 +2074,953 @@ const docTemplate = `{ } } }, + "/api/v1/trainManage/model": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车型号数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车型号", + "parameters": [ + { + "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/trainManage/model/: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.TrainModel" + } + }, + "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": "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/trainManage/model/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车型号名称过滤,分页查询列车型号信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车型号信息列表", + "parameters": [ + { + "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/trainManage/size": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车尺寸数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车尺寸", + "parameters": [ + { + "type": "integer", + "name": "carriageLength", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "name": "totalLength", + "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/trainManage/size/: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.TrainSize" + } + }, + "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": "integer", + "name": "carriageLength", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "name": "totalLength", + "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/trainManage/size/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车尺寸名称过滤,分页查询列车尺寸信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车尺寸信息列表", + "parameters": [ + { + "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/trainManage/wheelDiameter": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车轮径数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车轮径", + "parameters": [ + { + "type": "integer", + "name": "AxialPosition", + "in": "query" + }, + { + "type": "integer", + "name": "diameter", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "installDirection", + "in": "query" + }, + { + "type": "integer", + "name": "maxDiameter", + "in": "query" + }, + { + "type": "integer", + "name": "minDiameter", + "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/trainManage/wheelDiameter/: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.TrainWheelDiameter" + } + }, + "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": "integer", + "name": "AxialPosition", + "in": "query" + }, + { + "type": "integer", + "name": "diameter", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "installDirection", + "in": "query" + }, + { + "type": "integer", + "name": "maxDiameter", + "in": "query" + }, + { + "type": "integer", + "name": "minDiameter", + "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/trainManage/wheelDiameter/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车轮径名称过滤,分页查询列车轮径信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车轮径信息列表", + "parameters": [ + { + "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/user/current": { "get": { "description": "获取当前登录用户信息", @@ -1736,6 +3220,10 @@ const docTemplate = `{ "dto.AddTrainReqDto": { "type": "object", "properties": { + "devicePort": { + "description": "道岔端口", + "type": "string" + }, "headLinkId": { "description": "车头所在link的索引", "type": "string" @@ -1744,10 +3232,22 @@ const docTemplate = `{ "description": "车头所在link内的偏移量,单位为mm", "type": "integer" }, + "headOffset": { + "description": "车头所在link内的偏移量,单位为mm", + "type": "integer" + }, + "id": { + "description": "物理区段、道岔ID", + "type": "string" + }, "simulationId": { "description": "仿真id", "type": "string" }, + "trainLength": { + "description": "列车长度", + "type": "integer" + }, "up": { "description": "列车方向,true-上行,false-下行", "type": "boolean" @@ -1866,6 +3366,46 @@ const docTemplate = `{ } } }, + "dto.ProjectLinkRspDto": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "mapInfoLinks": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PublishedGiLinkDto" + } + }, + "name": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "trainSizeLinks": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.TrainSizeDto" + } + } + } + }, + "dto.PublishedGiLinkDto": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "dto.RegisterUser": { "type": "object", "properties": { @@ -1971,12 +3511,61 @@ const docTemplate = `{ } } }, + "dto.TrainSizeDto": { + "type": "object", + "properties": { + "carriageLength": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "totalLength": { + "type": "integer" + } + } + }, + "model.Category": { + "type": "object", + "properties": { + "code": { + "description": "编码", + "type": "string" + }, + "config": { + "description": "厂家配置", + "type": "string" + }, + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "id", + "type": "integer" + }, + "name": { + "description": "厂家名", + "type": "string" + }, + "update_at": { + "description": "修改时间", + "type": "string" + } + } + }, "model.Drafting": { "type": "object", "properties": { "category": { - "description": "厂家id", - "type": "integer" + "description": "厂家编码", + "type": "string" }, "created_at": { "description": "创建时间", @@ -2007,12 +3596,37 @@ const docTemplate = `{ } } }, + "model.Project": { + "type": "object", + "properties": { + "code": { + "description": "项目编码", + "type": "string" + }, + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + }, + "update_at": { + "description": "更新时间", + "type": "string" + } + } + }, "model.PublishedGi": { "type": "object", "properties": { "category": { "description": "厂家信息", - "type": "integer" + "type": "string" }, "id": { "description": "id", @@ -2046,6 +3660,83 @@ const docTemplate = `{ "type": "integer" } } + }, + "model.TrainModel": { + "type": "object", + "properties": { + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "组次名称", + "type": "string" + }, + "update_at": { + "description": "更新时间", + "type": "string" + } + } + }, + "model.TrainSize": { + "type": "object", + "properties": { + "carriage_length": { + "description": "列车车厢长度", + "type": "integer" + }, + "description": { + "description": "其他描述内容", + "type": "string" + }, + "id": { + "description": "主键", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + }, + "total_length": { + "description": "总长度", + "type": "integer" + } + } + }, + "model.TrainWheelDiameter": { + "type": "object", + "properties": { + "axial_position": { + "description": "速度传感器安装轴位,本端车前进方向的第几轴", + "type": "integer" + }, + "diameter": { + "description": "速度传感器安装处车轮的出厂直径(mm)", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "install_direction": { + "description": "速度传感器安装方向,\n\t\t本端车前进方向的左侧或右侧", + "type": "string" + }, + "max_diameter": { + "description": "速度传感器安装处车轮的最大直径(mm)", + "type": "integer" + }, + "min_diameter": { + "description": "速度传感器安装处车轮的最小直径(mm)", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index 7e30c6e..00e6b7f 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -9,6 +9,368 @@ "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/: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/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/category": { "post": { "security": [ @@ -28,6 +390,11 @@ ], "summary": "创建厂家信息", "parameters": [ + { + "type": "string", + "name": "code", + "in": "query" + }, { "type": "string", "name": "config", @@ -100,7 +467,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/model.Drafting" + "$ref": "#/definitions/model.Category" } }, "401": { @@ -148,6 +515,11 @@ "in": "path", "required": true }, + { + "type": "string", + "name": "code", + "in": "query" + }, { "type": "string", "name": "config", @@ -262,22 +634,6 @@ "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": { @@ -397,7 +753,7 @@ "summary": "创建草稿", "parameters": [ { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -526,7 +882,7 @@ "required": true }, { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -652,7 +1008,7 @@ "required": true }, { - "type": "integer", + "type": "string", "name": "category", "in": "query" }, @@ -824,6 +1180,187 @@ } } }, + "/api/v1/projectLink": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "保存项目的所有关联信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "项目关联信息Api" + ], + "summary": "保存项目的所有关联信息", + "parameters": [ + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "mids", + "in": "query" + }, + { + "type": "integer", + "name": "pid", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "sids", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "boolean" + } + }, + "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/info/: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/dto.ProjectLinkRspDto" + } + }, + "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/trainSize/: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/dto.TrainSizeDto" + } + }, + "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/publishedGi/list": { "get": { "security": [ @@ -984,7 +1521,7 @@ { "type": "integer", "description": "草稿数据的id", - "name": "draftingId", + "name": "draftId", "in": "query" }, { @@ -1047,7 +1584,7 @@ { "type": "integer", "description": "草稿数据的id", - "name": "draftingId", + "name": "draftId", "in": "query" }, { @@ -1530,6 +2067,953 @@ } } }, + "/api/v1/trainManage/model": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车型号数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车型号", + "parameters": [ + { + "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/trainManage/model/: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.TrainModel" + } + }, + "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": "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/trainManage/model/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车型号名称过滤,分页查询列车型号信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车型号信息列表", + "parameters": [ + { + "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/trainManage/size": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车尺寸数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车尺寸", + "parameters": [ + { + "type": "integer", + "name": "carriageLength", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "name": "totalLength", + "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/trainManage/size/: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.TrainSize" + } + }, + "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": "integer", + "name": "carriageLength", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "name": "totalLength", + "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/trainManage/size/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车尺寸名称过滤,分页查询列车尺寸信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车尺寸信息列表", + "parameters": [ + { + "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/trainManage/wheelDiameter": { + "post": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "创建列车轮径数据", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "创建列车轮径", + "parameters": [ + { + "type": "integer", + "name": "AxialPosition", + "in": "query" + }, + { + "type": "integer", + "name": "diameter", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "installDirection", + "in": "query" + }, + { + "type": "integer", + "name": "maxDiameter", + "in": "query" + }, + { + "type": "integer", + "name": "minDiameter", + "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/trainManage/wheelDiameter/: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.TrainWheelDiameter" + } + }, + "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": "integer", + "name": "AxialPosition", + "in": "query" + }, + { + "type": "integer", + "name": "diameter", + "in": "query" + }, + { + "type": "integer", + "name": "id", + "in": "query" + }, + { + "type": "string", + "name": "installDirection", + "in": "query" + }, + { + "type": "integer", + "name": "maxDiameter", + "in": "query" + }, + { + "type": "integer", + "name": "minDiameter", + "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/trainManage/wheelDiameter/paging": { + "get": { + "security": [ + { + "JwtAuth": [] + } + ], + "description": "可以通过列车轮径名称过滤,分页查询列车轮径信息列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "列车管理Api" + ], + "summary": "分页查询列车轮径信息列表", + "parameters": [ + { + "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/user/current": { "get": { "description": "获取当前登录用户信息", @@ -1729,6 +3213,10 @@ "dto.AddTrainReqDto": { "type": "object", "properties": { + "devicePort": { + "description": "道岔端口", + "type": "string" + }, "headLinkId": { "description": "车头所在link的索引", "type": "string" @@ -1737,10 +3225,22 @@ "description": "车头所在link内的偏移量,单位为mm", "type": "integer" }, + "headOffset": { + "description": "车头所在link内的偏移量,单位为mm", + "type": "integer" + }, + "id": { + "description": "物理区段、道岔ID", + "type": "string" + }, "simulationId": { "description": "仿真id", "type": "string" }, + "trainLength": { + "description": "列车长度", + "type": "integer" + }, "up": { "description": "列车方向,true-上行,false-下行", "type": "boolean" @@ -1859,6 +3359,46 @@ } } }, + "dto.ProjectLinkRspDto": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "mapInfoLinks": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PublishedGiLinkDto" + } + }, + "name": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "trainSizeLinks": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.TrainSizeDto" + } + } + } + }, + "dto.PublishedGiLinkDto": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "dto.RegisterUser": { "type": "object", "properties": { @@ -1964,12 +3504,61 @@ } } }, + "dto.TrainSizeDto": { + "type": "object", + "properties": { + "carriageLength": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "totalLength": { + "type": "integer" + } + } + }, + "model.Category": { + "type": "object", + "properties": { + "code": { + "description": "编码", + "type": "string" + }, + "config": { + "description": "厂家配置", + "type": "string" + }, + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "id", + "type": "integer" + }, + "name": { + "description": "厂家名", + "type": "string" + }, + "update_at": { + "description": "修改时间", + "type": "string" + } + } + }, "model.Drafting": { "type": "object", "properties": { "category": { - "description": "厂家id", - "type": "integer" + "description": "厂家编码", + "type": "string" }, "created_at": { "description": "创建时间", @@ -2000,12 +3589,37 @@ } } }, + "model.Project": { + "type": "object", + "properties": { + "code": { + "description": "项目编码", + "type": "string" + }, + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + }, + "update_at": { + "description": "更新时间", + "type": "string" + } + } + }, "model.PublishedGi": { "type": "object", "properties": { "category": { "description": "厂家信息", - "type": "integer" + "type": "string" }, "id": { "description": "id", @@ -2039,6 +3653,83 @@ "type": "integer" } } + }, + "model.TrainModel": { + "type": "object", + "properties": { + "created_at": { + "description": "创建时间", + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "组次名称", + "type": "string" + }, + "update_at": { + "description": "更新时间", + "type": "string" + } + } + }, + "model.TrainSize": { + "type": "object", + "properties": { + "carriage_length": { + "description": "列车车厢长度", + "type": "integer" + }, + "description": { + "description": "其他描述内容", + "type": "string" + }, + "id": { + "description": "主键", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + }, + "total_length": { + "description": "总长度", + "type": "integer" + } + } + }, + "model.TrainWheelDiameter": { + "type": "object", + "properties": { + "axial_position": { + "description": "速度传感器安装轴位,本端车前进方向的第几轴", + "type": "integer" + }, + "diameter": { + "description": "速度传感器安装处车轮的出厂直径(mm)", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "install_direction": { + "description": "速度传感器安装方向,\n\t\t本端车前进方向的左侧或右侧", + "type": "string" + }, + "max_diameter": { + "description": "速度传感器安装处车轮的最大直径(mm)", + "type": "integer" + }, + "min_diameter": { + "description": "速度传感器安装处车轮的最小直径(mm)", + "type": "integer" + }, + "name": { + "description": "名称", + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 1ddd5e5..200ac43 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -2,15 +2,27 @@ basePath: / definitions: dto.AddTrainReqDto: properties: + devicePort: + description: 道岔端口 + type: string headLinkId: description: 车头所在link的索引 type: string headLinkOffset: description: 车头所在link内的偏移量,单位为mm type: integer + headOffset: + description: 车头所在link内的偏移量,单位为mm + type: integer + id: + description: 物理区段、道岔ID + type: string simulationId: description: 仿真id type: string + trainLength: + description: 列车长度 + type: integer up: description: 列车方向,true-上行,false-下行 type: boolean @@ -92,6 +104,32 @@ definitions: - page - size type: object + dto.ProjectLinkRspDto: + properties: + code: + type: string + mapInfoLinks: + items: + $ref: '#/definitions/dto.PublishedGiLinkDto' + type: array + name: + type: string + pid: + type: integer + trainSizeLinks: + items: + $ref: '#/definitions/dto.TrainSizeDto' + type: array + type: object + dto.PublishedGiLinkDto: + properties: + category: + type: string + id: + type: integer + name: + type: string + type: object dto.RegisterUser: properties: id: @@ -163,11 +201,45 @@ definitions: token: type: string type: object + dto.TrainSizeDto: + properties: + carriageLength: + type: integer + description: + type: string + id: + type: integer + name: + type: string + totalLength: + type: integer + type: object + model.Category: + properties: + code: + description: 编码 + type: string + config: + description: 厂家配置 + type: string + created_at: + description: 创建时间 + type: string + id: + description: id + type: integer + name: + description: 厂家名 + type: string + update_at: + description: 修改时间 + type: string + type: object model.Drafting: properties: category: - description: 厂家id - type: integer + description: 厂家编码 + type: string created_at: description: 创建时间 type: string @@ -189,11 +261,29 @@ definitions: description: 修改时间 type: string type: object + model.Project: + properties: + code: + description: 项目编码 + type: string + created_at: + description: 创建时间 + type: string + id: + description: 主键 + type: integer + name: + description: 名称 + type: string + update_at: + description: 更新时间 + type: string + type: object model.PublishedGi: properties: category: description: 厂家信息 - type: integer + type: string id: description: id type: integer @@ -218,6 +308,61 @@ definitions: description: 发布用户id type: integer type: object + model.TrainModel: + properties: + created_at: + description: 创建时间 + type: string + id: + type: integer + name: + description: 组次名称 + type: string + update_at: + description: 更新时间 + type: string + type: object + model.TrainSize: + properties: + carriage_length: + description: 列车车厢长度 + type: integer + description: + description: 其他描述内容 + type: string + id: + description: 主键 + type: integer + name: + description: 名称 + type: string + total_length: + description: 总长度 + type: integer + type: object + model.TrainWheelDiameter: + properties: + axial_position: + description: 速度传感器安装轴位,本端车前进方向的第几轴 + type: integer + diameter: + description: 速度传感器安装处车轮的出厂直径(mm) + type: integer + id: + type: integer + install_direction: + description: "速度传感器安装方向,\n\t\t本端车前进方向的左侧或右侧" + type: string + max_diameter: + description: 速度传感器安装处车轮的最大直径(mm) + type: integer + min_diameter: + description: 速度传感器安装处车轮的最小直径(mm) + type: integer + name: + description: 名称 + type: string + type: object host: localhost:9091 info: contact: {} @@ -225,12 +370,244 @@ 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/category: post: consumes: - application/json description: 创建厂家数据 parameters: + - in: query + name: code + type: string - in: query name: config type: string @@ -311,7 +688,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/model.Drafting' + $ref: '#/definitions/model.Category' "401": description: Unauthorized schema: @@ -339,6 +716,9 @@ paths: name: id required: true type: integer + - in: query + name: code + type: string - in: query name: config type: string @@ -379,18 +759,6 @@ paths: - 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: @@ -468,7 +836,7 @@ paths: parameters: - in: query name: category - type: integer + type: string - in: query name: id type: integer @@ -582,7 +950,7 @@ paths: type: integer - in: query name: category - type: integer + type: string - in: query name: id type: integer @@ -630,7 +998,7 @@ paths: type: integer - in: query name: category - type: integer + type: string - in: query name: id type: integer @@ -744,6 +1112,121 @@ paths: summary: 根据地图数据新生成计算的link信息 tags: - GenerateApi + /api/v1/projectLink: + post: + consumes: + - application/json + description: 保存项目的所有关联信息 + parameters: + - collectionFormat: csv + in: query + items: + type: integer + name: mids + type: array + - in: query + name: pid + type: integer + - collectionFormat: csv + in: query + items: + type: integer + name: sids + type: array + produces: + - application/json + responses: + "200": + description: OK + schema: + type: boolean + "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/info/:id: + 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/dto.ProjectLinkRspDto' + "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/trainSize/:id: + 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/dto.TrainSizeDto' + "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/publishedGi/{id}: delete: consumes: @@ -900,7 +1383,7 @@ paths: parameters: - description: 草稿数据的id in: query - name: draftingId + name: draftId type: integer - description: 发布后的名称 in: query @@ -940,7 +1423,7 @@ paths: type: integer - description: 草稿数据的id in: query - name: draftingId + name: draftId type: integer - description: 发布后的名称 in: query @@ -1193,6 +1676,606 @@ paths: summary: ATS测试仿真-移除列车 tags: - ATS测试仿真Api + /api/v1/trainManage/model: + post: + consumes: + - application/json + description: 创建列车型号数据 + parameters: + - 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/trainManage/model/: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.TrainModel' + "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: 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/trainManage/model/paging: + get: + consumes: + - application/json + description: 可以通过列车型号名称过滤,分页查询列车型号信息列表 + parameters: + - 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/trainManage/size: + post: + consumes: + - application/json + description: 创建列车尺寸数据 + parameters: + - in: query + name: carriageLength + type: integer + - in: query + name: description + type: string + - in: query + name: id + type: integer + - in: query + name: name + type: string + - in: query + name: totalLength + 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 + /api/v1/trainManage/size/: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.TrainSize' + "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: carriageLength + type: integer + - in: query + name: description + type: string + - in: query + name: id + type: integer + - in: query + name: name + type: string + - in: query + name: totalLength + 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 + /api/v1/trainManage/size/paging: + get: + consumes: + - application/json + description: 可以通过列车尺寸名称过滤,分页查询列车尺寸信息列表 + parameters: + - 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/trainManage/wheelDiameter: + post: + consumes: + - application/json + description: 创建列车轮径数据 + parameters: + - in: query + name: AxialPosition + type: integer + - in: query + name: diameter + type: integer + - in: query + name: id + type: integer + - in: query + name: installDirection + type: string + - in: query + name: maxDiameter + type: integer + - in: query + name: minDiameter + 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/trainManage/wheelDiameter/: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.TrainWheelDiameter' + "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: AxialPosition + type: integer + - in: query + name: diameter + type: integer + - in: query + name: id + type: integer + - in: query + name: installDirection + type: string + - in: query + name: maxDiameter + type: integer + - in: query + name: minDiameter + 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/trainManage/wheelDiameter/paging: + get: + consumes: + - application/json + description: 可以通过列车轮径名称过滤,分页查询列车轮径信息列表 + parameters: + - 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/user/current: get: consumes: diff --git a/dto/project.go b/dto/project.go new file mode 100644 index 0000000..6487733 --- /dev/null +++ b/dto/project.go @@ -0,0 +1,17 @@ +package dto + +type ProjectReqDto struct { + Name string `json:"name" form:"name"` + Code string `json:"code" form:"code"` +} + +type ProjectDto struct { + Id int `json:"id" form:"id"` + Name string `json:"name" form:"name"` + Code string `json:"code" form:"code"` +} + +type PageProjectReqDto struct { + PageQueryDto + ProjectReqDto +} diff --git a/dto/projectLink.go b/dto/projectLink.go new file mode 100644 index 0000000..362fc80 --- /dev/null +++ b/dto/projectLink.go @@ -0,0 +1,41 @@ +package dto + +import "joylink.club/bj-rtsts-server/db/model" + +type ProjectLinkRspDto struct { + Pid int32 `json:"pid" form:"pid"` + Name string `json:"name" form:"name"` + Code string `json:"code" form:"code"` + TrainSizeLinks []*TrainSizeDto `json:"trainSizeLinks" form:"trainSizeLinks"` + PublishedGiLinks []*PublishedGiLinkDto `json:"mapInfoLinks" form:"mapInfoLinks"` +} + +type ProjectLinkReqDto struct { + Pid int32 `json:"pid" form:"pid"` + Sids []*int32 `json:"sids" form:"sids"` + Mids []*int32 `json:"mids" form:"mids"` +} + +type PublishedGiLinkDto struct { + Id int32 `json:"id" form:"id"` + Name string `json:"name" form:"name"` + Category string `json:"category" form:"category"` +} + +func ConvertProjectLink(gi *model.Project) *ProjectLinkRspDto { + return &ProjectLinkRspDto{ + Pid: gi.ID, + Name: gi.Name, + Code: gi.Code, + TrainSizeLinks: []*TrainSizeDto{}, + PublishedGiLinks: []*PublishedGiLinkDto{}, + } +} + +func ConvertFromPublishedGiLink(giSlice []*model.PublishedGi) []*PublishedGiLinkDto { + var result []*PublishedGiLinkDto + for _, gi := range giSlice { + result = append(result, &PublishedGiLinkDto{Id: gi.ID, Name: gi.Name, Category: gi.Category}) + } + return result +} diff --git a/dto/simulation.go b/dto/simulation.go index 5cbc050..d04dc7e 100644 --- a/dto/simulation.go +++ b/dto/simulation.go @@ -32,10 +32,8 @@ type AddTrainReqDto struct { DevicePort string `json:"devicePort" form:"devicePort"` //车头所在link内的偏移量,单位为mm HeadOffset int64 `json:"headOffset" form:"headOffset"` - //列车信号ID - TrainModelId int32 `json:"trainModelId" from:"trainModelId"` - //列车车厢数 - CarriageNum int32 `json:"carriageNum" from:"carriageNum"` + //列车长度 + TrainLength int64 `json:"trainLength" from:"trainLength"` } // 为仿真添加测试车请求 diff --git a/dto/trainManage.go b/dto/trainManage.go new file mode 100644 index 0000000..b5bf809 --- /dev/null +++ b/dto/trainManage.go @@ -0,0 +1,49 @@ +package dto + +import "joylink.club/bj-rtsts-server/db/model" + +type PageTrainManageReqDto struct { + PageQueryDto + Name string `json:"name" form:"name"` +} + +type TrainManageReqDto struct { + Name string `json:"name" form:"name"` +} + +type TrainModelDto struct { + Id int32 `json:"id" form:"id"` + Name string `json:"name" form:"name"` +} + +type TrainSizeDto struct { + Id int32 `json:"id" form:"id"` + Name string `json:"name" form:"name"` + CarriageLength int32 `json:"carriageLength" form:"carriageLength"` + TotalLength int32 `json:"totalLength" form:"totalLength"` + Description string `json:"description" form:"description"` +} + +func ConvertFromTrainSizeDto(giSlice []*model.TrainSize) []*TrainSizeDto { + var result []*TrainSizeDto + for _, gi := range giSlice { + result = append(result, &TrainSizeDto{ + Id: gi.ID, + Name: gi.Name, + CarriageLength: gi.CarriageLength, + TotalLength: gi.CarriageLength, + Description: gi.Description, + }) + } + return result +} + +type TrainWheelDiameterDto struct { + Id int32 `json:"id" form:"id"` + Name string `json:"name" form:"name"` + Diameter int32 `json:"diameter" form:"diameter"` + MinDiameter int32 `json:"minDiameter" form:"minDiameter"` + MaxDiameter int32 `json:"maxDiameter" form:"maxDiameter"` + AxialPosition int32 `json:"AxialPosition" form:"AxialPosition"` + InstallDirection string `json:"installDirection" form:"installDirection"` +} diff --git a/dto/trainModel.go b/dto/trainModel.go deleted file mode 100644 index fd477d3..0000000 --- a/dto/trainModel.go +++ /dev/null @@ -1,16 +0,0 @@ -package dto - -type PageTrainModelReqDto struct { - PageQueryDto - Name string `json:"name" form:"name"` -} - -type TrainModelReqDto struct { - Name string `json:"name" form:"name"` -} - -type TrainModelDto struct { - Id int `json:"id" form:"id"` - Name string `json:"name" form:"name"` - CarriageLength int32 `json:"carriageLength" form:"carriageLength"` -} diff --git a/main.go b/main.go index a97fb06..9384062 100644 --- a/main.go +++ b/main.go @@ -35,6 +35,11 @@ func main() { api.InitSimulationRouter(router, authMiddleware) api.InitCategoryRouter(router, authMiddleware) api.InitGenerateGiRouter(router, authMiddleware) + + api.InitProjectRouter(router, authMiddleware) + api.InitTrainManageRouter(router, authMiddleware) + api.InitProjectLinkRouter(router, authMiddleware) + docs.SwaggerInfo.Title = "CBTC测试系统API" engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) diff --git a/service/project.go b/service/project.go new file mode 100644 index 0000000..fae9202 --- /dev/null +++ b/service/project.go @@ -0,0 +1,116 @@ +package service + +import ( + "fmt" + "time" + + "joylink.club/bj-rtsts-server/db/dbquery" + "joylink.club/bj-rtsts-server/db/model" + "joylink.club/bj-rtsts-server/dto" +) + +// 查询项目列表 +func PageProjectQuery(query *dto.PageProjectReqDto) (*dto.PageDto, error) { + d := dbquery.Project + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + if query.Code != "" { + dq = dq.Where(d.Code.Like(fmt.Sprintf("%%%s%%", query.Code))) + } + 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) + } + return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil +} + +// 查询项目列表 +func ListProjectQuery(query *dto.ProjectReqDto) ([]*model.Project, error) { + d := dbquery.Project + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + if query.Code != "" { + dq = dq.Where(d.Code.Like(fmt.Sprintf("%%%s%%", query.Code))) + } + records, err := dq.Debug().Select(d.ID, d.Code, d.Name).Find() + if err != nil { + panic(err) + } + return records, nil +} + +// 创建草稿 +func CreateProject(dto *dto.ProjectDto) (*model.Project, error) { + if err := checkProjectInfo(dto.Code, 0); err != nil { + panic(err) + } + d := model.Project{ + Name: dto.Name, + Code: dto.Code, + CreatedAt: time.Now(), + UpdateAt: time.Now(), + } + p := dbquery.Project + err := p.Save(&d) + if err != nil { + panic(err) + } + return p.Where(p.Name.Eq(dto.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) + } + return data +} + +func UpdateProject(id int32, dto *dto.ProjectDto) bool { + if err := checkProjectInfo(dto.Code, id); err != nil { + panic(err) + } + findOldQuery := dbquery.Project + oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() + if oldD == nil || err != nil { + panic(err) + } + if dto.Code != "" { + oldD.Code = dto.Code + } + if dto.Name != "" { + oldD.Name = dto.Name + } + oldD.UpdateAt = time.Now() + _, error := dbquery.Project.Updates(oldD) + if error != nil { + panic(error) + } + return true +} + +func DeleteProjectById(id int) { + _, _ = dbquery.Project.Debug().Where(dbquery.Project.ID.Eq(int32(id))).Delete() +} + +func checkProjectInfo(code string, id int32) error { + findNameQuery := dbquery.Project + w := findNameQuery.Where() + if id != 0 { + w = w.Where(findNameQuery.ID.Eq(id)) + } + if code != "" { + count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count() + if err != nil { + panic(err) + } + if count > 0 { + panic("编码已存在") + } + } + return nil +} diff --git a/service/projectLink.go b/service/projectLink.go new file mode 100644 index 0000000..f181a9c --- /dev/null +++ b/service/projectLink.go @@ -0,0 +1,70 @@ +package service + +import ( + "joylink.club/bj-rtsts-server/db/dbquery" + "joylink.club/bj-rtsts-server/db/model" + "joylink.club/bj-rtsts-server/dto" +) + +// 获取项目的关联关系 +func QueryProjectLinkInfo(id int32) *dto.ProjectLinkRspDto { + pro, proErr := dbquery.Project.Where(dbquery.Project.ID.Eq(id)).First() + if proErr != nil { + panic(proErr) + } + projectLink := dto.ConvertProjectLink(pro) + // 关联列车尺寸列表 + projectLink.TrainSizeLinks = dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(id)) + // 关联地图列表 + projectLink.PublishedGiLinks = dto.ConvertFromPublishedGiLink(QueryPublishedGi(id)) + return projectLink +} + +// 通过地图ID获取列车尺寸列表 +func QueryTrainSizeByMapId(mid int32) []*dto.TrainSizeDto { + pl, err := dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.Eq(mid)).First() + if err != nil { + panic(err) + } + return dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(pl.Pid)) +} + +// 更新项目关联关系 +func UpdateProjectLink(req *dto.ProjectLinkReqDto) { + // 删除原来信息 + delProjectSizeLink(req.Pid) + delProjectMapLink(req.Pid) + // 保存新关联关系 + saveProjectSize(req.Pid, req.Sids) + saveProjectMapLink(req.Pid, req.Mids) +} + +// 删除项目列车尺寸关联关系 +func delProjectSizeLink(pid int32) { + dbquery.ProjectTrainSizeLink.Where(dbquery.ProjectTrainSizeLink.Pid.Eq(pid)).Delete() +} + +// 删除项目地图关联关系 +func delProjectMapLink(pid int32) { + dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Pid.Eq(pid)).Delete() +} + +// 保存项目尺寸关联关系 +func saveProjectSize(pid int32, sids []*int32) { + for _, sid := range sids { + dbquery.ProjectTrainSizeLink.Save(&model.ProjectTrainSizeLink{ + Pid: pid, + Sid: *sid, + }) + } +} + +// 保存项目地图关联关系 +func saveProjectMapLink(pid int32, mids []*int32) { + for _, mid := range mids { + dbquery.ProjectPublishLink.Save(&model.ProjectPublishLink{ + Pid: pid, + Mid: *mid, + }) + } +} diff --git a/service/publishedGi.go b/service/publishedGi.go index 645559b..6c60424 100644 --- a/service/publishedGi.go +++ b/service/publishedGi.go @@ -114,6 +114,22 @@ func SaveAsDraftingFromPublish(id int32, user *model.User, name string) { } } +func QueryPublishedGi(id int32) []*model.PublishedGi { + // 获取项目关联的发布地图 + dppl := dbquery.ProjectPublishLink + links, _ := dppl.Select(dppl.Mid).Where(dppl.Pid.Eq(id)).Find() + if len(links) > 0 { + mids := []int32{} + for _, m := range links { + mids = append(mids, m.Mid) + } + dp := dbquery.PublishedGi + publishedGis, _ := dp.Select(dp.ID, dp.Name, dp.Category).Where(dp.ID.In(mids...)).Find() + return publishedGis + } + return []*model.PublishedGi{} +} + // 操作地图数据中的link数据 // del 代表是否删除地图中的link数据 func handlerPublishedGiLinkData(data []byte, del bool) []byte { diff --git a/service/trainManage.go b/service/trainManage.go new file mode 100644 index 0000000..7150c7d --- /dev/null +++ b/service/trainManage.go @@ -0,0 +1,285 @@ +package service + +import ( + "fmt" + "time" + + "joylink.club/bj-rtsts-server/db/dbquery" + "joylink.club/bj-rtsts-server/db/model" + "joylink.club/bj-rtsts-server/dto" +) + +// 查询列车型号信息列表 +func PageTrainModelQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto, error) { + d := dbquery.TrainModel + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + records, total, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size) + if err != nil { + panic(err) + } + return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil +} + +// 查询列车型号信息列表 +func ListTrainModelQuery(query *dto.TrainManageReqDto) ([]*model.TrainModel, error) { + d := dbquery.TrainModel + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + records, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).Find() + if err != nil { + panic(err) + } + return records, nil +} + +// 创建列车型号信息 +func CreateTrainModel(dto *dto.TrainModelDto) (*model.TrainModel, error) { + if err := checkTrainModel(dto.Name, 0); err != nil { + panic(err) + } + d := model.TrainModel{ + Name: dto.Name, + CreatedAt: time.Now(), + UpdateAt: time.Now(), + } + dt := dbquery.TrainModel + err := dt.Save(&d) + if err != nil { + panic(err) + } + return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.CreatedAt).Debug().First() +} + +// 查询列车型号信息 +func QueryTrainModel(id int32) *model.TrainModel { + dt := dbquery.TrainModel + data, err := dt.Where(dt.ID.Eq(id)).Debug().First() + if err != nil { + panic(err) + } + return data +} + +// 更新列车型号信息 +func UpdateTrainModel(id int32, dto *dto.TrainModelDto) bool { + if err := checkTrainModel(dto.Name, id); err != nil { + panic(err) + } + findOldQuery := dbquery.TrainModel + oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() + if oldD == nil || err != nil { + panic(err) + } + if len(dto.Name) > 0 { + oldD.Name = dto.Name + } + oldD.UpdateAt = time.Now() + _, error := dbquery.TrainModel.Updates(oldD) + if error != nil { + panic(error) + } + return true +} + +// 删除列车型号 +func DeleteTrainModelById(id int) { + _, _ = dbquery.TrainModel.Debug().Where(dbquery.TrainModel.ID.Eq(int32(id))).Delete() +} + +// 查询列车尺寸信息列表 +func PageTrainSizeQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto, error) { + d := dbquery.TrainSize + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + 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) + } + return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil +} + +// 查询列车尺寸信息列表 +func ListTrainSizeQuery(query *dto.TrainManageReqDto) ([]*model.TrainSize, error) { + d := dbquery.TrainSize + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + records, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.TotalLength, d.Description).Find() + if err != nil { + panic(err) + } + return records, nil +} + +// 创建列车尺寸信息 +func CreateTrainSize(dto *dto.TrainSizeDto) (*model.TrainSize, error) { + d := model.TrainSize{ + Name: dto.Name, + CarriageLength: dto.CarriageLength, + TotalLength: dto.TotalLength, + Description: dto.Description, + } + dt := dbquery.TrainSize + err := dt.Save(&d) + if err != nil { + panic(err) + } + return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.Name).Debug().First() +} + +// 查询列车尺寸信息 +func QueryTrainSize(id int32) *model.TrainSize { + dt := dbquery.TrainSize + data, err := dt.Where(dt.ID.Eq(id)).Debug().First() + if err != nil { + panic(err) + } + return data +} + +// 更新列车尺寸信息 +func UpdateTrainSize(id int32, dto *dto.TrainSizeDto) bool { + findOldQuery := dbquery.TrainSize + oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() + if oldD == nil || err != nil { + panic(err) + } + 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) + } + return true +} + +// 删除列车尺寸 +func DeleteTrainSizeById(id int) { + _, _ = dbquery.TrainSize.Debug().Where(dbquery.TrainSize.ID.Eq(int32(id))).Delete() +} + +func QueryProjectTrainSize(id int32) []*model.TrainSize { + // 获取项目关联的列车尺寸 + ptsl := dbquery.ProjectTrainSizeLink + slinks, _ := ptsl.Select(ptsl.Sid).Where(ptsl.Pid.Eq(id)).Find() + if len(slinks) > 0 { + sids := []int32{} + for _, sid := range slinks { + sids = append(sids, sid.Sid) + } + ts := dbquery.TrainSize + trainSizes, _ := ts.Select(ts.ID, ts.Name).Where(ts.ID.In(sids...)).Find() + return trainSizes + } + return []*model.TrainSize{} +} + +// 查询列车轮径信息列表 +func PageTrainWheelDiameterQuery(query *dto.PageTrainManageReqDto) (*dto.PageDto, error) { + d := dbquery.TrainWheelDiameter + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + 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) + } + return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil +} + +// 查询列车轮径信息列表 +func ListTrainWheelDiameterQuery(query *dto.TrainManageReqDto) ([]*model.TrainWheelDiameter, error) { + d := dbquery.TrainWheelDiameter + dq := d.Where() + if query.Name != "" { + dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) + } + 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) + } + return records, nil +} + +// 创建列车轮径信息 +func CreateTrainWheelDiameter(dto *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, + } + dt := dbquery.TrainWheelDiameter + err := dt.Save(&d) + if err != nil { + panic(err) + } + return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.Name).Debug().First() +} + +// 查询列车轮径信息 +func QueryTrainWheelDiameter(id int32) *model.TrainWheelDiameter { + dt := dbquery.TrainWheelDiameter + data, err := dt.Where(dt.ID.Eq(id)).Debug().First() + if err != nil { + panic(err) + } + return data +} + +// 更新列车轮径信息 +func UpdateTrainWheelDiameter(id int32, dto *dto.TrainWheelDiameterDto) bool { + findOldQuery := dbquery.TrainWheelDiameter + oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() + if oldD == nil || err != nil { + panic(err) + } + 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) + } + return true +} + +// 删除列车轮径 +func DeleteTrainWheelDiameterById(id int) { + _, _ = dbquery.TrainWheelDiameter.Debug().Where(dbquery.TrainWheelDiameter.ID.Eq(int32(id))).Delete() +} + +// 检查列车型号名称 +func checkTrainModel(name string, id int32) error { + findNameQuery := dbquery.TrainModel + w := findNameQuery.Where() + if id != 0 { + w = w.Where(findNameQuery.ID.Eq(id)) + } + if name != "" { + count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count() + if err != nil { + panic(err) + } + if count > 0 { + panic("名称已存在") + } + } + return nil +} diff --git a/service/trainModel.go b/service/trainModel.go deleted file mode 100644 index 00e61b0..0000000 --- a/service/trainModel.go +++ /dev/null @@ -1,122 +0,0 @@ -package service - -import ( - "fmt" - "time" - - "joylink.club/bj-rtsts-server/db/dbquery" - "joylink.club/bj-rtsts-server/db/model" - "joylink.club/bj-rtsts-server/dto" -) - -// 查询列车型号信息列表 -func PageTrainModelQuery(query *dto.PageTrainModelReqDto) (*dto.PageDto, error) { - d := dbquery.TrainModel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, total, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size) - if err != nil { - panic(err) - } - return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, nil -} - -// 查询列车型号信息列表 -func ListTrainModelQuery(query *dto.TrainModelReqDto) ([]*model.TrainModel, error) { - d := dbquery.TrainModel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.UpdateAt, d.CreatedAt).Find() - if err != nil { - panic(err) - } - return records, nil -} - -// 创建列车型号信息 -func CreateTrainModel(dto *dto.TrainModelDto) (*model.TrainModel, error) { - if err := checkTrainModel(dto.Name, 0); err != nil { - panic(err) - } - d := model.TrainModel{ - Name: dto.Name, - CarriageLength: dto.CarriageLength, - CreatedAt: time.Now(), - UpdateAt: time.Now(), - } - dt := dbquery.TrainModel - err := dt.Save(&d) - if err != nil { - panic(err) - } - return dt.Where(dt.Name.Eq(dto.Name)).Order(dt.CreatedAt).Debug().First() -} - -// 查询列车型号信息 -func QueryTrainModel(id int32) *model.TrainModel { - dt := dbquery.TrainModel - data, err := dt.Where(dt.ID.Eq(id)).Debug().First() - if err != nil { - panic(err) - } - return data -} - -// 更新列车型号信息 -func UpdateTrainModel(id int32, dto *dto.TrainModelDto) bool { - if err := checkTrainModel(dto.Name, id); err != nil { - panic(err) - } - findOldQuery := dbquery.TrainModel - oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() - if oldD == nil || err != nil { - panic(err) - } - if len(dto.Name) > 0 { - oldD.Name = dto.Name - } - oldD.UpdateAt = time.Now() - _, error := dbquery.TrainModel.Updates(oldD) - if error != nil { - panic(error) - } - return true -} - -// 删除列车型号 -func DeleteTrainModelById(id int) { - _, _ = dbquery.TrainModel.Debug().Where(dbquery.TrainModel.ID.Eq(int32(id))).Delete() -} - -// 根据列车型号跟车厢数量计算列车长度 -func CalcTrainLenght(id, num int32) int32 { - dt := dbquery.TrainModel - data, err := dt.Select(dt.CarriageLength).Where(dt.ID.Eq(id)).Debug().First() - if err != nil { - panic(err) - } - return data.CarriageLength * num -} - -// 检查列车型号名称 -func checkTrainModel(name string, id int32) error { - findNameQuery := dbquery.TrainModel - w := findNameQuery.Where() - if id != 0 { - w = w.Where(findNameQuery.ID.Eq(id)) - } - if name != "" { - count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count() - if err != nil { - panic(err) - } - if count > 0 { - panic("名称已存在") - } - } - return nil -}