【项目信息、列车尺寸、列车轮径管理接口】

【半实物信息解析BUG】
This commit is contained in:
weizhihong 2023-08-25 10:41:13 +08:00
parent 945ae4a43b
commit 6b5e4c7cc3
36 changed files with 8549 additions and 468 deletions

View File

@ -127,7 +127,7 @@ func createCategory(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param id path int true "厂家ID" // @Param id path int true "厂家ID"
// @Success 200 {object} model.Drafting // @Success 200 {object} model.Category
// @Failure 401 {object} dto.ErrorDto // @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto // @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto // @Failure 500 {object} dto.ErrorDto

210
api/project.go Normal file
View File

@ -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)
}

100
api/projectLink.go Normal file
View File

@ -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)
}

View File

@ -199,7 +199,7 @@ func addTrain(c *gin.Context) {
HeadOffset: req.HeadOffset, HeadOffset: req.HeadOffset,
DevicePort: req.DevicePort, DevicePort: req.DevicePort,
RunDirection: req.RunDirection, RunDirection: req.RunDirection,
//TrainLength: int64(service.CalcTrainLenght(req.TrainModelId, req.CarriageNum)), TrainLength: req.TrainLength,
} }
memory.AddTrainState(simulation, rsp) memory.AddTrainState(simulation, rsp)
c.JSON(http.StatusOK, &rsp) c.JSON(http.StatusOK, &rsp)

497
api/trainManage.go Normal file
View File

@ -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)
}

View File

@ -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)
}

View File

@ -287,31 +287,31 @@ func decoderVobcTrainState(buf []byte) *state.TrainVobcState {
trainVobcInfo := &state.TrainVobcState{} trainVobcInfo := &state.TrainVobcState{}
trainVobcInfo.LifeSignal = int32(binary.BigEndian.Uint16(buf[0:2])) trainVobcInfo.LifeSignal = int32(binary.BigEndian.Uint16(buf[0:2]))
b2 := buf[2] b2 := buf[2]
trainVobcInfo.Tc1Active = (b2 & (1 << 7)) != 0 trainVobcInfo.Tc1Active = (b2 & 1) != 0
trainVobcInfo.Tc2Active = (b2 & (1 << 6)) != 0 trainVobcInfo.Tc2Active = (b2 & (1 << 1)) != 0
trainVobcInfo.DirectionForward = (b2 & (1 << 5)) != 0 trainVobcInfo.DirectionForward = (b2 & (1 << 2)) != 0
trainVobcInfo.DirectionBackward = (b2 & (1 << 4)) != 0 trainVobcInfo.DirectionBackward = (b2 & (1 << 3)) != 0
trainVobcInfo.TractionStatus = (b2 & (1 << 3)) != 0 trainVobcInfo.TractionStatus = (b2 & (1 << 4)) != 0
trainVobcInfo.BrakingStatus = (b2 & (1 << 2)) != 0 trainVobcInfo.BrakingStatus = (b2 & (1 << 5)) != 0
trainVobcInfo.EmergencyBrakingStatus = (b2 & (1 << 1)) != 0 trainVobcInfo.EmergencyBrakingStatus = (b2 & (1 << 6)) != 0
trainVobcInfo.TurnbackStatus = (b2 & 1) != 0 trainVobcInfo.TurnbackStatus = (b2 & 7) != 0
b3 := buf[3] b3 := buf[3]
trainVobcInfo.JumpStatus = (b3 & (1 << 7)) != 0 trainVobcInfo.JumpStatus = (b3 & 1) != 0
trainVobcInfo.Ato = (b3 & (1 << 6)) != 0 trainVobcInfo.Ato = (b3 & (1 << 1)) != 0
trainVobcInfo.Fam = (b3 & (1 << 5)) != 0 trainVobcInfo.Fam = (b3 & (1 << 2)) != 0
trainVobcInfo.Cam = (b3 & (1 << 4)) != 0 trainVobcInfo.Cam = (b3 & (1 << 3)) != 0
trainVobcInfo.TractionSafetyCircuit = (b3 & (1 << 3)) != 0 trainVobcInfo.TractionSafetyCircuit = (b3 & (1 << 4)) != 0
trainVobcInfo.ParkingBrakeStatus = (b3 & (1 << 2)) != 0 trainVobcInfo.ParkingBrakeStatus = (b3 & (1 << 5)) != 0
trainVobcInfo.MaintainBrakeStatus = (b3 & (1 << 1)) != 0 trainVobcInfo.MaintainBrakeStatus = (b3 & (1 << 6)) != 0
trainVobcInfo.TractionForce = int64(binary.BigEndian.Uint16(buf[4:6])) trainVobcInfo.TractionForce = int64(binary.BigEndian.Uint16(buf[4:6]))
trainVobcInfo.BrakeForce = int64(binary.BigEndian.Uint16(buf[6:8])) trainVobcInfo.BrakeForce = int64(binary.BigEndian.Uint16(buf[6:8]))
trainVobcInfo.TrainLoad = int64(binary.BigEndian.Uint16(buf[8:10])) trainVobcInfo.TrainLoad = int64(binary.BigEndian.Uint16(buf[8:10]))
b4 := buf[15] b4 := buf[15]
trainVobcInfo.LeftDoorOpenCommand = (b4 & (1 << 7)) != 0 trainVobcInfo.LeftDoorOpenCommand = (b4 & 1) != 0
trainVobcInfo.RightDoorOpenCommand = (b4 & (1 << 6)) != 0 trainVobcInfo.RightDoorOpenCommand = (b4 & (1 << 1)) != 0
trainVobcInfo.LeftDoorCloseCommand = (b4 & (1 << 5)) != 0 trainVobcInfo.LeftDoorCloseCommand = (b4 & (1 << 2)) != 0
trainVobcInfo.RightDoorCloseCommand = (b4 & (1 << 4)) != 0 trainVobcInfo.RightDoorCloseCommand = (b4 & (1 << 3)) != 0
trainVobcInfo.AllDoorClose = (b4 & (1 << 3)) != 0 trainVobcInfo.AllDoorClose = (b4 & (1 << 4)) != 0
return trainVobcInfo return trainVobcInfo
} }

View File

@ -19,8 +19,13 @@ var (
Q = new(Query) Q = new(Query)
Category *category Category *category
Drafting *drafting Drafting *drafting
Project *project
ProjectPublishLink *projectPublishLink
ProjectTrainSizeLink *projectTrainSizeLink
PublishedGi *publishedGi PublishedGi *publishedGi
TrainModel *trainModel TrainModel *trainModel
TrainSize *trainSize
TrainWheelDiameter *trainWheelDiameter
User *user User *user
) )
@ -28,8 +33,13 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...) *Q = *Use(db, opts...)
Category = &Q.Category Category = &Q.Category
Drafting = &Q.Drafting Drafting = &Q.Drafting
Project = &Q.Project
ProjectPublishLink = &Q.ProjectPublishLink
ProjectTrainSizeLink = &Q.ProjectTrainSizeLink
PublishedGi = &Q.PublishedGi PublishedGi = &Q.PublishedGi
TrainModel = &Q.TrainModel TrainModel = &Q.TrainModel
TrainSize = &Q.TrainSize
TrainWheelDiameter = &Q.TrainWheelDiameter
User = &Q.User User = &Q.User
} }
@ -38,8 +48,13 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
db: db, db: db,
Category: newCategory(db, opts...), Category: newCategory(db, opts...),
Drafting: newDrafting(db, opts...), Drafting: newDrafting(db, opts...),
Project: newProject(db, opts...),
ProjectPublishLink: newProjectPublishLink(db, opts...),
ProjectTrainSizeLink: newProjectTrainSizeLink(db, opts...),
PublishedGi: newPublishedGi(db, opts...), PublishedGi: newPublishedGi(db, opts...),
TrainModel: newTrainModel(db, opts...), TrainModel: newTrainModel(db, opts...),
TrainSize: newTrainSize(db, opts...),
TrainWheelDiameter: newTrainWheelDiameter(db, opts...),
User: newUser(db, opts...), User: newUser(db, opts...),
} }
} }
@ -49,8 +64,13 @@ type Query struct {
Category category Category category
Drafting drafting Drafting drafting
Project project
ProjectPublishLink projectPublishLink
ProjectTrainSizeLink projectTrainSizeLink
PublishedGi publishedGi PublishedGi publishedGi
TrainModel trainModel TrainModel trainModel
TrainSize trainSize
TrainWheelDiameter trainWheelDiameter
User user User user
} }
@ -61,8 +81,13 @@ func (q *Query) clone(db *gorm.DB) *Query {
db: db, db: db,
Category: q.Category.clone(db), Category: q.Category.clone(db),
Drafting: q.Drafting.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), PublishedGi: q.PublishedGi.clone(db),
TrainModel: q.TrainModel.clone(db), TrainModel: q.TrainModel.clone(db),
TrainSize: q.TrainSize.clone(db),
TrainWheelDiameter: q.TrainWheelDiameter.clone(db),
User: q.User.clone(db), User: q.User.clone(db),
} }
} }
@ -80,8 +105,13 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
db: db, db: db,
Category: q.Category.replaceDB(db), Category: q.Category.replaceDB(db),
Drafting: q.Drafting.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), PublishedGi: q.PublishedGi.replaceDB(db),
TrainModel: q.TrainModel.replaceDB(db), TrainModel: q.TrainModel.replaceDB(db),
TrainSize: q.TrainSize.replaceDB(db),
TrainWheelDiameter: q.TrainWheelDiameter.replaceDB(db),
User: q.User.replaceDB(db), User: q.User.replaceDB(db),
} }
} }
@ -89,8 +119,13 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
type queryCtx struct { type queryCtx struct {
Category ICategoryDo Category ICategoryDo
Drafting IDraftingDo Drafting IDraftingDo
Project IProjectDo
ProjectPublishLink IProjectPublishLinkDo
ProjectTrainSizeLink IProjectTrainSizeLinkDo
PublishedGi IPublishedGiDo PublishedGi IPublishedGiDo
TrainModel ITrainModelDo TrainModel ITrainModelDo
TrainSize ITrainSizeDo
TrainWheelDiameter ITrainWheelDiameterDo
User IUserDo User IUserDo
} }
@ -98,8 +133,13 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{ return &queryCtx{
Category: q.Category.WithContext(ctx), Category: q.Category.WithContext(ctx),
Drafting: q.Drafting.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), PublishedGi: q.PublishedGi.WithContext(ctx),
TrainModel: q.TrainModel.WithContext(ctx), TrainModel: q.TrainModel.WithContext(ctx),
TrainSize: q.TrainSize.WithContext(ctx),
TrainWheelDiameter: q.TrainWheelDiameter.WithContext(ctx),
User: q.User.WithContext(ctx), User: q.User.WithContext(ctx),
} }
} }

396
db/dbquery/project.gen.go Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -29,7 +29,6 @@ func newTrainModel(db *gorm.DB, opts ...gen.DOOption) trainModel {
_trainModel.ALL = field.NewAsterisk(tableName) _trainModel.ALL = field.NewAsterisk(tableName)
_trainModel.ID = field.NewInt32(tableName, "id") _trainModel.ID = field.NewInt32(tableName, "id")
_trainModel.Name = field.NewString(tableName, "name") _trainModel.Name = field.NewString(tableName, "name")
_trainModel.CarriageLength = field.NewInt32(tableName, "carriage_length")
_trainModel.CreatedAt = field.NewTime(tableName, "created_at") _trainModel.CreatedAt = field.NewTime(tableName, "created_at")
_trainModel.UpdateAt = field.NewTime(tableName, "update_at") _trainModel.UpdateAt = field.NewTime(tableName, "update_at")
@ -44,7 +43,6 @@ type trainModel struct {
ALL field.Asterisk ALL field.Asterisk
ID field.Int32 ID field.Int32
Name field.String // 组次名称 Name field.String // 组次名称
CarriageLength field.Int32 // 单个车厢长度
CreatedAt field.Time // 创建时间 CreatedAt field.Time // 创建时间
UpdateAt field.Time // 更新时间 UpdateAt field.Time // 更新时间
@ -65,7 +63,6 @@ func (t *trainModel) updateTableName(table string) *trainModel {
t.ALL = field.NewAsterisk(table) t.ALL = field.NewAsterisk(table)
t.ID = field.NewInt32(table, "id") t.ID = field.NewInt32(table, "id")
t.Name = field.NewString(table, "name") t.Name = field.NewString(table, "name")
t.CarriageLength = field.NewInt32(table, "carriage_length")
t.CreatedAt = field.NewTime(table, "created_at") t.CreatedAt = field.NewTime(table, "created_at")
t.UpdateAt = field.NewTime(table, "update_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() { 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["id"] = t.ID
t.fieldMap["name"] = t.Name t.fieldMap["name"] = t.Name
t.fieldMap["carriage_length"] = t.CarriageLength
t.fieldMap["created_at"] = t.CreatedAt t.fieldMap["created_at"] = t.CreatedAt
t.fieldMap["update_at"] = t.UpdateAt t.fieldMap["update_at"] = t.UpdateAt
} }

View File

@ -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
}

View File

@ -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
}

25
db/model/project.gen.go Normal file
View File

@ -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 <project>
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
}

View File

@ -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 <project_publish_link>
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
}

View File

@ -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 <project_train_size>
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
}

View File

@ -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 <project_train_size_link>
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
}

View File

@ -14,7 +14,6 @@ const TableNameTrainModel = "train_model"
type TrainModel struct { type TrainModel struct {
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Name string `gorm:"column:name;comment:组次名称" json:"name"` // 组次名称 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"` // 创建时间 CreatedAt time.Time `gorm:"column:created_at;comment:创建时间" json:"created_at"` // 创建时间
UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间 UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间
} }

View File

@ -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 <train_size>
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
}

View File

@ -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 <train_wheel_diameter>
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
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

17
dto/project.go Normal file
View File

@ -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
}

41
dto/projectLink.go Normal file
View File

@ -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
}

View File

@ -32,10 +32,8 @@ type AddTrainReqDto struct {
DevicePort string `json:"devicePort" form:"devicePort"` DevicePort string `json:"devicePort" form:"devicePort"`
//车头所在link内的偏移量单位为mm //车头所在link内的偏移量单位为mm
HeadOffset int64 `json:"headOffset" form:"headOffset"` HeadOffset int64 `json:"headOffset" form:"headOffset"`
//列车信号ID //列车长度
TrainModelId int32 `json:"trainModelId" from:"trainModelId"` TrainLength int64 `json:"trainLength" from:"trainLength"`
//列车车厢数
CarriageNum int32 `json:"carriageNum" from:"carriageNum"`
} }
// 为仿真添加测试车请求 // 为仿真添加测试车请求

49
dto/trainManage.go Normal file
View File

@ -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"`
}

View File

@ -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"`
}

View File

@ -35,6 +35,11 @@ func main() {
api.InitSimulationRouter(router, authMiddleware) api.InitSimulationRouter(router, authMiddleware)
api.InitCategoryRouter(router, authMiddleware) api.InitCategoryRouter(router, authMiddleware)
api.InitGenerateGiRouter(router, authMiddleware) api.InitGenerateGiRouter(router, authMiddleware)
api.InitProjectRouter(router, authMiddleware)
api.InitTrainManageRouter(router, authMiddleware)
api.InitProjectLinkRouter(router, authMiddleware)
docs.SwaggerInfo.Title = "CBTC测试系统API" docs.SwaggerInfo.Title = "CBTC测试系统API"
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

116
service/project.go Normal file
View File

@ -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
}

70
service/projectLink.go Normal file
View File

@ -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,
})
}
}

View File

@ -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数据 // 操作地图数据中的link数据
// del 代表是否删除地图中的link数据 // del 代表是否删除地图中的link数据
func handlerPublishedGiLinkData(data []byte, del bool) []byte { func handlerPublishedGiLinkData(data []byte, del bool) []byte {

285
service/trainManage.go Normal file
View File

@ -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
}

View File

@ -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
}