【发布数据管理逻辑修改】

This commit is contained in:
weizhihong 2023-11-22 17:05:38 +08:00
parent f355453f54
commit 1434fb0f01
14 changed files with 1893 additions and 1737 deletions

View File

@ -24,6 +24,9 @@ func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
authed.DELETE("/:id", deletePublishedGiById) authed.DELETE("/:id", deletePublishedGiById)
authed.POST("/saveAsDrafting/:id", saveAsDraftingFromPublish) authed.POST("/saveAsDrafting/:id", saveAsDraftingFromPublish)
authed.GET("/name", getPublishedGiByName) authed.GET("/name", getPublishedGiByName)
authed.POST("/release", releasePublishedGiById)
authed.POST("/rename", renamePublishedGiById)
authed.GET("/:id/history", historyPublishedGiById)
} }
// 分页查询发布的图形数据 // 分页查询发布的图形数据
@ -61,7 +64,7 @@ func pageQueryPublishedGi(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param publishedListReqDto query dto.PublishedListReqDto true "查询参数" // @Param publishedListReqDto query dto.PublishedListReqDto true "查询参数"
// @Success 200 {object} []model.PublishedGi // @Success 200 {object} []model.Published
// @Failure 401 {object} dto.ErrorDto // @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto // @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/list [get] // @Router /api/v1/publishedGi/list [get]
@ -192,7 +195,7 @@ func saveAsDraftingFromPublish(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param publishedSingleQueryDto query dto.PublishedSingleQueryDto true "查询参数" // @Param publishedSingleQueryDto query dto.PublishedSingleQueryDto true "查询参数"
// @Success 200 {object} []model.PublishedGi // @Success 200 {object} dto.PublishedDto
// @Failure 401 {object} dto.ErrorDto // @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto // @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/name [get] // @Router /api/v1/publishedGi/name [get]
@ -205,3 +208,76 @@ func getPublishedGiByName(c *gin.Context) {
entity := service.GetPublishedGiByName(param) entity := service.GetPublishedGiByName(param)
c.JSON(http.StatusOK, entity) c.JSON(http.StatusOK, entity)
} }
// 上下架发布数据
//
// @Summary 上下架发布数据
//
// @Security JwtAuth
//
// @Description 上下架发布数据
// @Tags 发布的图形数据Api
// @Accept json
// @Produce json
// @Param PublishChangeReqDto query dto.PublishChangeReqDto true "查询参数"
// @Success 200 {object} nil
// @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/release [post]
func releasePublishedGiById(c *gin.Context) {
param := &dto.PublishChangeReqDto{}
if err := c.ShouldBind(param); err != nil {
panic(sys_error.New("操作失败,查询参数格式错误", err))
}
service.ChangePublishStatus(param.Id, param.Release)
c.JSON(http.StatusOK, true)
}
// 修改发布数据名称
//
// @Summary 修改发布数据名称
//
// @Security JwtAuth
//
// @Description 修改发布数据名称
// @Tags 发布的图形数据Api
// @Accept json
// @Produce json
// @Param PublishChangeReqDto query dto.PublishChangeReqDto true "查询参数"
// @Success 200 {object} nil
// @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/rename [post]
func renamePublishedGiById(c *gin.Context) {
param := &dto.PublishChangeReqDto{}
if err := c.ShouldBind(param); err != nil {
panic(sys_error.New("操作失败,查询参数格式错误", err))
}
service.ChangePublishCode(param.Id, param.Name)
c.JSON(http.StatusOK, true)
}
// 查询发布历史版本信息
//
// @Summary 查询发布历史版本信息
//
// @Security JwtAuth
//
// @Description 查询发布历史版本信息
// @Tags 发布的图形数据Api
// @Accept json
// @Produce json
// @Param id path int true "id"
// @Success 200 {object} dto.PublishHistoryDto
// @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/:id/history [get]
func historyPublishedGiById(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.Atoi(idStr)
if err != nil {
panic(sys_error.New("查询发布历史失败,查询参数格式错误", err))
}
mid := int32(id)
c.JSON(http.StatusOK, service.GetPublishHistory(mid))
}

View File

@ -2,11 +2,13 @@ package api
// 列车相关的关系管理 // 列车相关的关系管理
import ( import (
"log/slog"
"net/http" "net/http"
"strconv" "strconv"
jwt "github.com/appleboy/gin-jwt/v2" jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto" "joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/middleware" "joylink.club/bj-rtsts-server/middleware"
"joylink.club/bj-rtsts-server/service" "joylink.club/bj-rtsts-server/service"
@ -44,7 +46,7 @@ func pageQueryTrainInfo(c *gin.Context) {
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("查询失败,参数格式错误", err)) panic(sys_error.New("查询失败,参数格式错误", err))
} }
c.JSON(http.StatusOK, service.PageTrainInfoQuery(&req)) c.JSON(http.StatusOK, service.PageTrainInfoByPublished(&req))
} }
// 查询列车列表 // 查询列车列表
@ -58,7 +60,7 @@ func pageQueryTrainInfo(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param trainInfoReqDto query dto.TrainInfoReqDto true "列车查询条件" // @Param trainInfoReqDto query dto.TrainInfoReqDto true "列车查询条件"
// @Success 200 {object} model.TrainInfo // @Success 200 {object} dto.TrainInfoDto
// @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
@ -68,7 +70,7 @@ func queryTrainInfoList(c *gin.Context) {
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("查询失败,参数格式错误", err)) panic(sys_error.New("查询失败,参数格式错误", err))
} }
c.JSON(http.StatusOK, service.ListTrainInfoQuery(&req)) c.JSON(http.StatusOK, service.ListTrainByProject(&req))
} }
// 创建列车 // 创建列车
@ -92,8 +94,9 @@ func createTrainInfo(c *gin.Context) {
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("保存失败,参数格式错误", err)) panic(sys_error.New("保存失败,参数格式错误", err))
} }
user, _ := c.Get(middleware.IdentityKey)
c.JSON(http.StatusOK, service.CreateTrainInfo(&req)) slog.Debug("发布图形数据", user)
c.JSON(http.StatusOK, service.CreateTrain(&req, user.(*model.User)))
} }
// 查询列车详情 // 查询列车详情
@ -107,7 +110,7 @@ func createTrainInfo(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.TrainModel // @Success 200 {object} dto.TrainInfoDto
// @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
@ -118,7 +121,7 @@ func queryTrainInfo(c *gin.Context) {
panic(sys_error.New("查询失败,缺少主键")) panic(sys_error.New("查询失败,缺少主键"))
} }
int64Id, _ := strconv.ParseInt(id, 10, 64) int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.QueryTrainInfo(int32(int64Id))) c.JSON(http.StatusOK, service.QueryTrain(int32(int64Id)))
} }
// 修改列车信息 // 修改列车信息
@ -148,7 +151,9 @@ func updateTrainInfo(c *gin.Context) {
panic(sys_error.New("更新失败,参数格式错误", err)) panic(sys_error.New("更新失败,参数格式错误", err))
} }
int64Id, _ := strconv.ParseInt(id, 10, 64) int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.UpdateTrainInfo(int32(int64Id), &req)) user, _ := c.Get(middleware.IdentityKey)
slog.Debug("发布图形数据", user)
c.JSON(http.StatusOK, service.UpdateTrain(int32(int64Id), &req, user.(*model.User)))
} }
// 删除列车数据 // 删除列车数据
@ -173,6 +178,6 @@ func deleteTrainInfo(c *gin.Context) {
if err != nil { if err != nil {
panic(sys_error.New("删除失败,缺少主键")) panic(sys_error.New("删除失败,缺少主键"))
} }
service.DeleteTrainInfoById(id) service.DeletePublishedById(int32(id))
c.JSON(http.StatusOK, true) c.JSON(http.StatusOK, true)
} }

View File

@ -16,20 +16,20 @@ import (
) )
var ( var (
Q = new(Query) Q = new(Query)
AuthAPIPath *authAPIPath AuthAPIPath *authAPIPath
AuthRole *authRole AuthRole *authRole
AuthRoleAPIPath *authRoleAPIPath AuthRoleAPIPath *authRoleAPIPath
AuthRoleUser *authRoleUser AuthRoleUser *authRoleUser
Category *category Category *category
Drafting *drafting Drafting *drafting
Project *project Project *project
ProjectPublishLink *projectPublishLink ProjectPublishLink *projectPublishLink
ProjectRunConfig *projectRunConfig ProjectRunConfig *projectRunConfig
Published *published Published *published
PublishedVersion *publishedVersion PublishedVersion *publishedVersion
TrainInfo *trainInfo TrainInfo *trainInfo
User *user User *user
) )
func SetDefault(db *gorm.DB, opts ...gen.DOOption) { func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
@ -51,59 +51,59 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
func Use(db *gorm.DB, opts ...gen.DOOption) *Query { func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{ return &Query{
db: db, db: db,
AuthAPIPath: newAuthAPIPath(db, opts...), AuthAPIPath: newAuthAPIPath(db, opts...),
AuthRole: newAuthRole(db, opts...), AuthRole: newAuthRole(db, opts...),
AuthRoleAPIPath: newAuthRoleAPIPath(db, opts...), AuthRoleAPIPath: newAuthRoleAPIPath(db, opts...),
AuthRoleUser: newAuthRoleUser(db, opts...), AuthRoleUser: newAuthRoleUser(db, opts...),
Category: newCategory(db, opts...), Category: newCategory(db, opts...),
Drafting: newDrafting(db, opts...), Drafting: newDrafting(db, opts...),
Project: newProject(db, opts...), Project: newProject(db, opts...),
ProjectPublishLink: newProjectPublishLink(db, opts...), ProjectPublishLink: newProjectPublishLink(db, opts...),
ProjectRunConfig: newProjectRunConfig(db, opts...), ProjectRunConfig: newProjectRunConfig(db, opts...),
Published: newPublished(db, opts...), Published: newPublished(db, opts...),
PublishedVersion: newPublishedVersion(db, opts...), PublishedVersion: newPublishedVersion(db, opts...),
TrainInfo: newTrainInfo(db, opts...), TrainInfo: newTrainInfo(db, opts...),
User: newUser(db, opts...), User: newUser(db, opts...),
} }
} }
type Query struct { type Query struct {
db *gorm.DB db *gorm.DB
AuthAPIPath authAPIPath AuthAPIPath authAPIPath
AuthRole authRole AuthRole authRole
AuthRoleAPIPath authRoleAPIPath AuthRoleAPIPath authRoleAPIPath
AuthRoleUser authRoleUser AuthRoleUser authRoleUser
Category category Category category
Drafting drafting Drafting drafting
Project project Project project
ProjectPublishLink projectPublishLink ProjectPublishLink projectPublishLink
ProjectRunConfig projectRunConfig ProjectRunConfig projectRunConfig
Published published Published published
PublishedVersion publishedVersion PublishedVersion publishedVersion
TrainInfo trainInfo TrainInfo trainInfo
User user User user
} }
func (q *Query) Available() bool { return q.db != nil } func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query { func (q *Query) clone(db *gorm.DB) *Query {
return &Query{ return &Query{
db: db, db: db,
AuthAPIPath: q.AuthAPIPath.clone(db), AuthAPIPath: q.AuthAPIPath.clone(db),
AuthRole: q.AuthRole.clone(db), AuthRole: q.AuthRole.clone(db),
AuthRoleAPIPath: q.AuthRoleAPIPath.clone(db), AuthRoleAPIPath: q.AuthRoleAPIPath.clone(db),
AuthRoleUser: q.AuthRoleUser.clone(db), AuthRoleUser: q.AuthRoleUser.clone(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), Project: q.Project.clone(db),
ProjectPublishLink: q.ProjectPublishLink.clone(db), ProjectPublishLink: q.ProjectPublishLink.clone(db),
ProjectRunConfig: q.ProjectRunConfig.clone(db), ProjectRunConfig: q.ProjectRunConfig.clone(db),
Published: q.Published.clone(db), Published: q.Published.clone(db),
PublishedVersion: q.PublishedVersion.clone(db), PublishedVersion: q.PublishedVersion.clone(db),
TrainInfo: q.TrainInfo.clone(db), TrainInfo: q.TrainInfo.clone(db),
User: q.User.clone(db), User: q.User.clone(db),
} }
} }
@ -117,54 +117,54 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query { func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{ return &Query{
db: db, db: db,
AuthAPIPath: q.AuthAPIPath.replaceDB(db), AuthAPIPath: q.AuthAPIPath.replaceDB(db),
AuthRole: q.AuthRole.replaceDB(db), AuthRole: q.AuthRole.replaceDB(db),
AuthRoleAPIPath: q.AuthRoleAPIPath.replaceDB(db), AuthRoleAPIPath: q.AuthRoleAPIPath.replaceDB(db),
AuthRoleUser: q.AuthRoleUser.replaceDB(db), AuthRoleUser: q.AuthRoleUser.replaceDB(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), Project: q.Project.replaceDB(db),
ProjectPublishLink: q.ProjectPublishLink.replaceDB(db), ProjectPublishLink: q.ProjectPublishLink.replaceDB(db),
ProjectRunConfig: q.ProjectRunConfig.replaceDB(db), ProjectRunConfig: q.ProjectRunConfig.replaceDB(db),
Published: q.Published.replaceDB(db), Published: q.Published.replaceDB(db),
PublishedVersion: q.PublishedVersion.replaceDB(db), PublishedVersion: q.PublishedVersion.replaceDB(db),
TrainInfo: q.TrainInfo.replaceDB(db), TrainInfo: q.TrainInfo.replaceDB(db),
User: q.User.replaceDB(db), User: q.User.replaceDB(db),
} }
} }
type queryCtx struct { type queryCtx struct {
AuthAPIPath IAuthAPIPathDo AuthAPIPath IAuthAPIPathDo
AuthRole IAuthRoleDo AuthRole IAuthRoleDo
AuthRoleAPIPath IAuthRoleAPIPathDo AuthRoleAPIPath IAuthRoleAPIPathDo
AuthRoleUser IAuthRoleUserDo AuthRoleUser IAuthRoleUserDo
Category ICategoryDo Category ICategoryDo
Drafting IDraftingDo Drafting IDraftingDo
Project IProjectDo Project IProjectDo
ProjectPublishLink IProjectPublishLinkDo ProjectPublishLink IProjectPublishLinkDo
ProjectRunConfig IProjectRunConfigDo ProjectRunConfig IProjectRunConfigDo
Published IPublishedDo Published IPublishedDo
PublishedVersion IPublishedVersionDo PublishedVersion IPublishedVersionDo
TrainInfo ITrainInfoDo TrainInfo ITrainInfoDo
User IUserDo User IUserDo
} }
func (q *Query) WithContext(ctx context.Context) *queryCtx { func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{ return &queryCtx{
AuthAPIPath: q.AuthAPIPath.WithContext(ctx), AuthAPIPath: q.AuthAPIPath.WithContext(ctx),
AuthRole: q.AuthRole.WithContext(ctx), AuthRole: q.AuthRole.WithContext(ctx),
AuthRoleAPIPath: q.AuthRoleAPIPath.WithContext(ctx), AuthRoleAPIPath: q.AuthRoleAPIPath.WithContext(ctx),
AuthRoleUser: q.AuthRoleUser.WithContext(ctx), AuthRoleUser: q.AuthRoleUser.WithContext(ctx),
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), Project: q.Project.WithContext(ctx),
ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx), ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx),
ProjectRunConfig: q.ProjectRunConfig.WithContext(ctx), ProjectRunConfig: q.ProjectRunConfig.WithContext(ctx),
Published: q.Published.WithContext(ctx), Published: q.Published.WithContext(ctx),
PublishedVersion: q.PublishedVersion.WithContext(ctx), PublishedVersion: q.PublishedVersion.WithContext(ctx),
TrainInfo: q.TrainInfo.WithContext(ctx), TrainInfo: q.TrainInfo.WithContext(ctx),
User: q.User.WithContext(ctx), User: q.User.WithContext(ctx),
} }
} }

View File

@ -34,6 +34,9 @@ func newPublishedVersion(db *gorm.DB, opts ...gen.DOOption) publishedVersion {
_publishedVersion.Note = field.NewString(tableName, "note") _publishedVersion.Note = field.NewString(tableName, "note")
_publishedVersion.Version = field.NewInt32(tableName, "version") _publishedVersion.Version = field.NewInt32(tableName, "version")
_publishedVersion.Code = field.NewString(tableName, "code") _publishedVersion.Code = field.NewString(tableName, "code")
_publishedVersion.PublishID = field.NewInt32(tableName, "publish_id")
_publishedVersion.Type = field.NewInt32(tableName, "type")
_publishedVersion.Category = field.NewString(tableName, "category")
_publishedVersion.fillFieldMap() _publishedVersion.fillFieldMap()
@ -50,7 +53,10 @@ type publishedVersion struct {
PublishAt field.Time // 发布时间 PublishAt field.Time // 发布时间
Note field.String // 发布描述 Note field.String // 发布描述
Version field.Int32 // 版本 Version field.Int32 // 版本
Code field.String // 数据名称 Code field.String // 发布草稿数据名称
PublishID field.Int32 // 对应发布图的ID
Type field.Int32
Category field.String
fieldMap map[string]field.Expr fieldMap map[string]field.Expr
} }
@ -74,6 +80,9 @@ func (p *publishedVersion) updateTableName(table string) *publishedVersion {
p.Note = field.NewString(table, "note") p.Note = field.NewString(table, "note")
p.Version = field.NewInt32(table, "version") p.Version = field.NewInt32(table, "version")
p.Code = field.NewString(table, "code") p.Code = field.NewString(table, "code")
p.PublishID = field.NewInt32(table, "publish_id")
p.Type = field.NewInt32(table, "type")
p.Category = field.NewString(table, "category")
p.fillFieldMap() p.fillFieldMap()
@ -90,7 +99,7 @@ func (p *publishedVersion) GetFieldByName(fieldName string) (field.OrderExpr, bo
} }
func (p *publishedVersion) fillFieldMap() { func (p *publishedVersion) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 7) p.fieldMap = make(map[string]field.Expr, 10)
p.fieldMap["id"] = p.ID p.fieldMap["id"] = p.ID
p.fieldMap["proto"] = p.Proto p.fieldMap["proto"] = p.Proto
p.fieldMap["user_id"] = p.UserID p.fieldMap["user_id"] = p.UserID
@ -98,6 +107,9 @@ func (p *publishedVersion) fillFieldMap() {
p.fieldMap["note"] = p.Note p.fieldMap["note"] = p.Note
p.fieldMap["version"] = p.Version p.fieldMap["version"] = p.Version
p.fieldMap["code"] = p.Code p.fieldMap["code"] = p.Code
p.fieldMap["publish_id"] = p.PublishID
p.fieldMap["type"] = p.Type
p.fieldMap["category"] = p.Category
} }
func (p publishedVersion) clone(db *gorm.DB) publishedVersion { func (p publishedVersion) clone(db *gorm.DB) publishedVersion {

View File

@ -18,7 +18,10 @@ type PublishedVersion struct {
PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间 PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间
Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述 Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述
Version int32 `gorm:"column:version;comment:版本" json:"version"` // 版本 Version int32 `gorm:"column:version;comment:版本" json:"version"` // 版本
Code string `gorm:"column:code;comment:数据名称" json:"code"` // 数据名称 Code string `gorm:"column:code;comment:发布草稿数据名称" json:"code"` // 发布草稿数据名称
PublishID int32 `gorm:"column:publish_id;comment:对应发布图的ID" json:"publish_id"` // 对应发布图的ID
Type int32 `gorm:"column:type" json:"type"`
Category string `gorm:"column:category" json:"category"`
} }
// TableName PublishedVersion's table name // TableName PublishedVersion's table name

View File

@ -1236,14 +1236,16 @@ const docTemplate = `{
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -1504,14 +1506,16 @@ const docTemplate = `{
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -1647,14 +1651,16 @@ const docTemplate = `{
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -2079,16 +2085,6 @@ const docTemplate = `{
"type": "integer", "type": "integer",
"name": "pid", "name": "pid",
"in": "query" "in": "query"
},
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"description": "TODO:前端修改完成后删除",
"name": "sids",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -2174,14 +2170,14 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/projectLink/mapInfo/trainSize/{id}": { "/api/v1/publishedGi/:id/history": {
"get": { "get": {
"security": [ "security": [
{ {
"JwtAuth": [] "JwtAuth": []
} }
], ],
"description": "通过地图ID查询项目的关联列车尺寸信息", "description": "查询发布历史版本信息",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@ -2189,13 +2185,13 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"项目关联信息Api" "发布的图形数据Api"
], ],
"summary": "通过地图ID查询项目的关联列车尺寸信息", "summary": "查询发布历史版本信息",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"description": "地图ID", "description": "id",
"name": "id", "name": "id",
"in": "path", "in": "path",
"required": true "required": true
@ -2205,7 +2201,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/dto.TrainSizeDto" "$ref": "#/definitions/dto.PublishHistoryDto"
} }
}, },
"401": { "401": {
@ -2214,67 +2210,6 @@ const docTemplate = `{
"$ref": "#/definitions/dto.ErrorDto" "$ref": "#/definitions/dto.ErrorDto"
} }
}, },
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/projectLink/project/trainSize/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "通过项目ID查询项目的关联列车尺寸信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目关联信息Api"
],
"summary": "通过项目ID查询项目的关联列车尺寸信息",
"parameters": [
{
"type": "integer",
"description": "地图ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.TrainSizeDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
@ -2303,10 +2238,20 @@ const docTemplate = `{
], ],
"summary": "列表查询发布的图形数据", "summary": "列表查询发布的图形数据",
"parameters": [ "parameters": [
{
"type": "string",
"name": "category",
"in": "query"
},
{ {
"type": "string", "type": "string",
"name": "name", "name": "name",
"in": "query" "in": "query"
},
{
"type": "integer",
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -2315,7 +2260,7 @@ const docTemplate = `{
"schema": { "schema": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/model.PublishedGi" "$ref": "#/definitions/model.Published"
} }
} }
}, },
@ -2368,10 +2313,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "array", "$ref": "#/definitions/dto.PublishedDto"
"items": {
"$ref": "#/definitions/model.PublishedGi"
}
} }
}, },
"401": { "401": {
@ -2476,6 +2418,12 @@ const docTemplate = `{
"name": "draftId", "name": "draftId",
"in": "query" "in": "query"
}, },
{
"type": "boolean",
"description": "强制覆盖",
"name": "force",
"in": "query"
},
{ {
"type": "string", "type": "string",
"description": "发布后的名称", "description": "发布后的名称",
@ -2507,6 +2455,114 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/publishedGi/release": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "上下架发布数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "上下架发布数据",
"parameters": [
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "boolean",
"name": "release",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/rename": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改发布数据名称",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "修改发布数据名称",
"parameters": [
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "boolean",
"name": "release",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/saveAsDrafting/{id}": { "/api/v1/publishedGi/saveAsDrafting/{id}": {
"post": { "post": {
"security": [ "security": [
@ -2539,6 +2595,12 @@ const docTemplate = `{
"name": "draftId", "name": "draftId",
"in": "query" "in": "query"
}, },
{
"type": "boolean",
"description": "强制覆盖",
"name": "force",
"in": "query"
},
{ {
"type": "string", "type": "string",
"description": "发布后的名称", "description": "发布后的名称",
@ -4044,7 +4106,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/model.TrainInfo" "$ref": "#/definitions/dto.TrainInfoDto"
} }
}, },
"401": { "401": {
@ -4168,7 +4230,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/model.TrainModel" "$ref": "#/definitions/dto.TrainInfoDto"
} }
}, },
"401": { "401": {
@ -4843,13 +4905,6 @@ const docTemplate = `{
}, },
"pid": { "pid": {
"type": "integer" "type": "integer"
},
"trainSizeLinks": {
"description": "TODO:前端修改完成后删除",
"type": "array",
"items": {
"$ref": "#/definitions/dto.TrainSizeDto"
}
} }
} }
}, },
@ -4901,6 +4956,26 @@ const docTemplate = `{
} }
} }
}, },
"dto.PublishHistoryDto": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"note": {
"type": "string"
},
"publishAt": {
"type": "string"
},
"publisher": {
"type": "string"
},
"version": {
"type": "integer"
}
}
},
"dto.PublishedDto": { "dto.PublishedDto": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5133,7 +5208,7 @@ const docTemplate = `{
} }
} }
}, },
"dto.TrainSizeDto": { "dto.TrainInfoDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"carriage_length": { "carriage_length": {
@ -5145,11 +5220,23 @@ const docTemplate = `{
"id": { "id": {
"type": "integer" "type": "integer"
}, },
"max_diameter": {
"type": "integer"
},
"min_diameter": {
"type": "integer"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
"total_length": { "total_length": {
"type": "integer" "type": "integer"
},
"train_model": {
"type": "integer"
},
"train_sets": {
"type": "string"
} }
} }
}, },
@ -5214,13 +5301,15 @@ const docTemplate = `{
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
] ]
}, },
"model.AuthAPIPath": { "model.AuthAPIPath": {
@ -5338,36 +5427,25 @@ const docTemplate = `{
} }
} }
}, },
"model.PublishedGi": { "model.Published": {
"type": "object", "type": "object",
"properties": { "properties": {
"category": { "category": {
"description": "厂家信息", "description": "厂家信息",
"type": "string" "type": "string"
}, },
"code": {
"description": "发布名称",
"type": "string"
},
"data_id": {
"description": "版本Id",
"type": "integer"
},
"id": { "id": {
"description": "id", "description": "id",
"type": "integer" "type": "integer"
}, },
"name": {
"description": "发布图形界面名称",
"type": "string"
},
"note": {
"description": "发布描述",
"type": "string"
},
"proto": {
"description": "图形界面数据",
"type": "array",
"items": {
"type": "integer"
}
},
"publish_at": {
"description": "发布时间",
"type": "string"
},
"status": { "status": {
"description": "显示状态", "description": "显示状态",
"type": "integer" "type": "integer"
@ -5375,54 +5453,6 @@ const docTemplate = `{
"type": { "type": {
"description": "数据类型", "description": "数据类型",
"type": "integer" "type": "integer"
},
"user_id": {
"description": "发布用户id",
"type": "integer"
}
}
},
"model.TrainInfo": {
"type": "object",
"properties": {
"description": {
"description": "其他描述内容",
"type": "string"
},
"id": {
"description": "id",
"type": "integer"
},
"name": {
"description": "列车信息",
"type": "string"
},
"proto": {
"description": "列车参数信息",
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"model.TrainModel": {
"type": "object",
"properties": {
"created_at": {
"description": "创建时间",
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"description": "组次名称",
"type": "string"
},
"update_at": {
"description": "更新时间",
"type": "string"
} }
} }
}, },

View File

@ -1229,14 +1229,16 @@
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -1497,14 +1499,16 @@
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -1640,14 +1644,16 @@
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"type": "integer", "type": "integer",
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
], ],
"name": "type", "name": "type",
"in": "query" "in": "query"
@ -2072,16 +2078,6 @@
"type": "integer", "type": "integer",
"name": "pid", "name": "pid",
"in": "query" "in": "query"
},
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"description": "TODO:前端修改完成后删除",
"name": "sids",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -2167,14 +2163,14 @@
} }
} }
}, },
"/api/v1/projectLink/mapInfo/trainSize/{id}": { "/api/v1/publishedGi/:id/history": {
"get": { "get": {
"security": [ "security": [
{ {
"JwtAuth": [] "JwtAuth": []
} }
], ],
"description": "通过地图ID查询项目的关联列车尺寸信息", "description": "查询发布历史版本信息",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@ -2182,13 +2178,13 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"项目关联信息Api" "发布的图形数据Api"
], ],
"summary": "通过地图ID查询项目的关联列车尺寸信息", "summary": "查询发布历史版本信息",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"description": "地图ID", "description": "id",
"name": "id", "name": "id",
"in": "path", "in": "path",
"required": true "required": true
@ -2198,7 +2194,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/dto.TrainSizeDto" "$ref": "#/definitions/dto.PublishHistoryDto"
} }
}, },
"401": { "401": {
@ -2207,67 +2203,6 @@
"$ref": "#/definitions/dto.ErrorDto" "$ref": "#/definitions/dto.ErrorDto"
} }
}, },
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/projectLink/project/trainSize/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "通过项目ID查询项目的关联列车尺寸信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"项目关联信息Api"
],
"summary": "通过项目ID查询项目的关联列车尺寸信息",
"parameters": [
{
"type": "integer",
"description": "地图ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.TrainSizeDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": { "500": {
"description": "Internal Server Error", "description": "Internal Server Error",
"schema": { "schema": {
@ -2296,10 +2231,20 @@
], ],
"summary": "列表查询发布的图形数据", "summary": "列表查询发布的图形数据",
"parameters": [ "parameters": [
{
"type": "string",
"name": "category",
"in": "query"
},
{ {
"type": "string", "type": "string",
"name": "name", "name": "name",
"in": "query" "in": "query"
},
{
"type": "integer",
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -2308,7 +2253,7 @@
"schema": { "schema": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/model.PublishedGi" "$ref": "#/definitions/model.Published"
} }
} }
}, },
@ -2361,10 +2306,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "array", "$ref": "#/definitions/dto.PublishedDto"
"items": {
"$ref": "#/definitions/model.PublishedGi"
}
} }
}, },
"401": { "401": {
@ -2469,6 +2411,12 @@
"name": "draftId", "name": "draftId",
"in": "query" "in": "query"
}, },
{
"type": "boolean",
"description": "强制覆盖",
"name": "force",
"in": "query"
},
{ {
"type": "string", "type": "string",
"description": "发布后的名称", "description": "发布后的名称",
@ -2500,6 +2448,114 @@
} }
} }
}, },
"/api/v1/publishedGi/release": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "上下架发布数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "上下架发布数据",
"parameters": [
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "boolean",
"name": "release",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/rename": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "修改发布数据名称",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "修改发布数据名称",
"parameters": [
{
"type": "integer",
"name": "id",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "boolean",
"name": "release",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/saveAsDrafting/{id}": { "/api/v1/publishedGi/saveAsDrafting/{id}": {
"post": { "post": {
"security": [ "security": [
@ -2532,6 +2588,12 @@
"name": "draftId", "name": "draftId",
"in": "query" "in": "query"
}, },
{
"type": "boolean",
"description": "强制覆盖",
"name": "force",
"in": "query"
},
{ {
"type": "string", "type": "string",
"description": "发布后的名称", "description": "发布后的名称",
@ -4037,7 +4099,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/model.TrainInfo" "$ref": "#/definitions/dto.TrainInfoDto"
} }
}, },
"401": { "401": {
@ -4161,7 +4223,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/model.TrainModel" "$ref": "#/definitions/dto.TrainInfoDto"
} }
}, },
"401": { "401": {
@ -4836,13 +4898,6 @@
}, },
"pid": { "pid": {
"type": "integer" "type": "integer"
},
"trainSizeLinks": {
"description": "TODO:前端修改完成后删除",
"type": "array",
"items": {
"$ref": "#/definitions/dto.TrainSizeDto"
}
} }
} }
}, },
@ -4894,6 +4949,26 @@
} }
} }
}, },
"dto.PublishHistoryDto": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"note": {
"type": "string"
},
"publishAt": {
"type": "string"
},
"publisher": {
"type": "string"
},
"version": {
"type": "integer"
}
}
},
"dto.PublishedDto": { "dto.PublishedDto": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5126,7 +5201,7 @@
} }
} }
}, },
"dto.TrainSizeDto": { "dto.TrainInfoDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"carriage_length": { "carriage_length": {
@ -5138,11 +5213,23 @@
"id": { "id": {
"type": "integer" "type": "integer"
}, },
"max_diameter": {
"type": "integer"
},
"min_diameter": {
"type": "integer"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
"total_length": { "total_length": {
"type": "integer" "type": "integer"
},
"train_model": {
"type": "integer"
},
"train_sets": {
"type": "string"
} }
} }
}, },
@ -5207,13 +5294,15 @@
0, 0,
1, 1,
2, 2,
3 3,
4
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"PictureType_StationLayout", "PictureType_StationLayout",
"PictureType_Psl", "PictureType_Psl",
"PictureType_RelayCabinetLayout", "PictureType_RelayCabinetLayout",
"PictureType_IBP" "PictureType_IBP",
"PictureType_TrainData"
] ]
}, },
"model.AuthAPIPath": { "model.AuthAPIPath": {
@ -5331,36 +5420,25 @@
} }
} }
}, },
"model.PublishedGi": { "model.Published": {
"type": "object", "type": "object",
"properties": { "properties": {
"category": { "category": {
"description": "厂家信息", "description": "厂家信息",
"type": "string" "type": "string"
}, },
"code": {
"description": "发布名称",
"type": "string"
},
"data_id": {
"description": "版本Id",
"type": "integer"
},
"id": { "id": {
"description": "id", "description": "id",
"type": "integer" "type": "integer"
}, },
"name": {
"description": "发布图形界面名称",
"type": "string"
},
"note": {
"description": "发布描述",
"type": "string"
},
"proto": {
"description": "图形界面数据",
"type": "array",
"items": {
"type": "integer"
}
},
"publish_at": {
"description": "发布时间",
"type": "string"
},
"status": { "status": {
"description": "显示状态", "description": "显示状态",
"type": "integer" "type": "integer"
@ -5368,54 +5446,6 @@
"type": { "type": {
"description": "数据类型", "description": "数据类型",
"type": "integer" "type": "integer"
},
"user_id": {
"description": "发布用户id",
"type": "integer"
}
}
},
"model.TrainInfo": {
"type": "object",
"properties": {
"description": {
"description": "其他描述内容",
"type": "string"
},
"id": {
"description": "id",
"type": "integer"
},
"name": {
"description": "列车信息",
"type": "string"
},
"proto": {
"description": "列车参数信息",
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"model.TrainModel": {
"type": "object",
"properties": {
"created_at": {
"description": "创建时间",
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"description": "组次名称",
"type": "string"
},
"update_at": {
"description": "更新时间",
"type": "string"
} }
} }
}, },

View File

@ -214,11 +214,6 @@ definitions:
type: string type: string
pid: pid:
type: integer type: integer
trainSizeLinks:
description: TODO:前端修改完成后删除
items:
$ref: '#/definitions/dto.TrainSizeDto'
type: array
type: object type: object
dto.ProjectRunConfigDto: dto.ProjectRunConfigDto:
properties: properties:
@ -252,6 +247,19 @@ definitions:
- mapId - mapId
- simulationId - simulationId
type: object type: object
dto.PublishHistoryDto:
properties:
id:
type: integer
note:
type: string
publishAt:
type: string
publisher:
type: string
version:
type: integer
type: object
dto.PublishedDto: dto.PublishedDto:
properties: properties:
category: category:
@ -408,7 +416,7 @@ definitions:
token: token:
type: string type: string
type: object type: object
dto.TrainSizeDto: dto.TrainInfoDto:
properties: properties:
carriage_length: carriage_length:
type: integer type: integer
@ -416,10 +424,18 @@ definitions:
type: string type: string
id: id:
type: integer type: integer
max_diameter:
type: integer
min_diameter:
type: integer
name: name:
type: string type: string
total_length: total_length:
type: integer type: integer
train_model:
type: integer
train_sets:
type: string
type: object type: object
dto.UpdateTrainReqDto: dto.UpdateTrainReqDto:
properties: properties:
@ -466,12 +482,14 @@ definitions:
- 1 - 1
- 2 - 2
- 3 - 3
- 4
type: integer type: integer
x-enum-varnames: x-enum-varnames:
- PictureType_StationLayout - PictureType_StationLayout
- PictureType_Psl - PictureType_Psl
- PictureType_RelayCabinetLayout - PictureType_RelayCabinetLayout
- PictureType_IBP - PictureType_IBP
- PictureType_TrainData
model.AuthAPIPath: model.AuthAPIPath:
properties: properties:
id: id:
@ -555,68 +573,26 @@ definitions:
description: 更新时间 description: 更新时间
type: string type: string
type: object type: object
model.PublishedGi: model.Published:
properties: properties:
category: category:
description: 厂家信息 description: 厂家信息
type: string type: string
code:
description: 发布名称
type: string
data_id:
description: 版本Id
type: integer
id: id:
description: id description: id
type: integer type: integer
name:
description: 发布图形界面名称
type: string
note:
description: 发布描述
type: string
proto:
description: 图形界面数据
items:
type: integer
type: array
publish_at:
description: 发布时间
type: string
status: status:
description: 显示状态 description: 显示状态
type: integer type: integer
type: type:
description: 数据类型 description: 数据类型
type: integer type: integer
user_id:
description: 发布用户id
type: integer
type: object
model.TrainInfo:
properties:
description:
description: 其他描述内容
type: string
id:
description: id
type: integer
name:
description: 列车信息
type: string
proto:
description: 列车参数信息
items:
type: integer
type: array
type: object
model.TrainModel:
properties:
created_at:
description: 创建时间
type: string
id:
type: integer
name:
description: 组次名称
type: string
update_at:
description: 更新时间
type: string
type: object type: object
request_proto.Psd_Operation: request_proto.Psd_Operation:
enum: enum:
@ -1619,6 +1595,7 @@ paths:
- 1 - 1
- 2 - 2
- 3 - 3
- 4
in: query in: query
name: type name: type
type: integer type: integer
@ -1627,6 +1604,7 @@ paths:
- PictureType_Psl - PictureType_Psl
- PictureType_RelayCabinetLayout - PictureType_RelayCabinetLayout
- PictureType_IBP - PictureType_IBP
- PictureType_TrainData
produces: produces:
- application/json - application/json
responses: responses:
@ -1746,6 +1724,7 @@ paths:
- 1 - 1
- 2 - 2
- 3 - 3
- 4
in: query in: query
name: type name: type
type: integer type: integer
@ -1754,6 +1733,7 @@ paths:
- PictureType_Psl - PictureType_Psl
- PictureType_RelayCabinetLayout - PictureType_RelayCabinetLayout
- PictureType_IBP - PictureType_IBP
- PictureType_TrainData
produces: produces:
- application/json - application/json
responses: responses:
@ -1807,6 +1787,7 @@ paths:
- 1 - 1
- 2 - 2
- 3 - 3
- 4
in: query in: query
name: type name: type
type: integer type: integer
@ -1815,6 +1796,7 @@ paths:
- PictureType_Psl - PictureType_Psl
- PictureType_RelayCabinetLayout - PictureType_RelayCabinetLayout
- PictureType_IBP - PictureType_IBP
- PictureType_TrainData
produces: produces:
- application/json - application/json
responses: responses:
@ -2159,13 +2141,6 @@ paths:
- in: query - in: query
name: pid name: pid
type: integer type: integer
- collectionFormat: csv
description: TODO:前端修改完成后删除
in: query
items:
type: integer
name: sids
type: array
produces: produces:
- application/json - application/json
responses: responses:
@ -2225,13 +2200,13 @@ paths:
summary: 查询项目的所有关联信息 summary: 查询项目的所有关联信息
tags: tags:
- 项目关联信息Api - 项目关联信息Api
/api/v1/projectLink/mapInfo/trainSize/{id}: /api/v1/publishedGi/:id/history:
get: get:
consumes: consumes:
- application/json - application/json
description: 通过地图ID查询项目的关联列车尺寸信息 description: 查询发布历史版本信息
parameters: parameters:
- description: 地图ID - description: id
in: path in: path
name: id name: id
required: true required: true
@ -2242,59 +2217,20 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/dto.TrainSizeDto' $ref: '#/definitions/dto.PublishHistoryDto'
"401": "401":
description: Unauthorized description: Unauthorized
schema: schema:
$ref: '#/definitions/dto.ErrorDto' $ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: '#/definitions/dto.ErrorDto' $ref: '#/definitions/dto.ErrorDto'
security: security:
- JwtAuth: [] - JwtAuth: []
summary: 通过地图ID查询项目的关联列车尺寸信息 summary: 查询发布历史版本信息
tags: tags:
- 项目关联信息Api - 发布的图形数据Api
/api/v1/projectLink/project/trainSize/{id}:
get:
consumes:
- application/json
description: 通过项目ID查询项目的关联列车尺寸信息
parameters:
- description: 地图ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.TrainSizeDto'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 通过项目ID查询项目的关联列车尺寸信息
tags:
- 项目关联信息Api
/api/v1/publishedGi/{id}: /api/v1/publishedGi/{id}:
delete: delete:
consumes: consumes:
@ -2360,9 +2296,15 @@ paths:
- application/json - application/json
description: 可以通过名称过滤 description: 可以通过名称过滤
parameters: parameters:
- in: query
name: category
type: string
- in: query - in: query
name: name name: name
type: string type: string
- in: query
name: type
type: integer
produces: produces:
- application/json - application/json
responses: responses:
@ -2370,7 +2312,7 @@ paths:
description: OK description: OK
schema: schema:
items: items:
$ref: '#/definitions/model.PublishedGi' $ref: '#/definitions/model.Published'
type: array type: array
"401": "401":
description: Unauthorized description: Unauthorized
@ -2403,9 +2345,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
items: $ref: '#/definitions/dto.PublishedDto'
$ref: '#/definitions/model.PublishedGi'
type: array
"401": "401":
description: Unauthorized description: Unauthorized
schema: schema:
@ -2469,6 +2409,10 @@ paths:
in: query in: query
name: draftId name: draftId
type: integer type: integer
- description: 强制覆盖
in: query
name: force
type: boolean
- description: 发布后的名称 - description: 发布后的名称
in: query in: query
name: name name: name
@ -2494,6 +2438,72 @@ paths:
summary: 从草稿发布数据 summary: 从草稿发布数据
tags: tags:
- 发布的图形数据Api - 发布的图形数据Api
/api/v1/publishedGi/release:
post:
consumes:
- application/json
description: 上下架发布数据
parameters:
- in: query
name: id
type: integer
- in: query
name: name
type: string
- in: query
name: release
type: boolean
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 上下架发布数据
tags:
- 发布的图形数据Api
/api/v1/publishedGi/rename:
post:
consumes:
- application/json
description: 修改发布数据名称
parameters:
- in: query
name: id
type: integer
- in: query
name: name
type: string
- in: query
name: release
type: boolean
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 修改发布数据名称
tags:
- 发布的图形数据Api
/api/v1/publishedGi/saveAsDrafting/{id}: /api/v1/publishedGi/saveAsDrafting/{id}:
post: post:
consumes: consumes:
@ -2509,6 +2519,10 @@ paths:
in: query in: query
name: draftId name: draftId
type: integer type: integer
- description: 强制覆盖
in: query
name: force
type: boolean
- description: 发布后的名称 - description: 发布后的名称
in: query in: query
name: name name: name
@ -3439,7 +3453,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/model.TrainModel' $ref: '#/definitions/dto.TrainInfoDto'
"401": "401":
description: Unauthorized description: Unauthorized
schema: schema:
@ -3531,7 +3545,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/model.TrainInfo' $ref: '#/definitions/dto.TrainInfoDto'
"401": "401":
description: Unauthorized description: Unauthorized
schema: schema:

View File

@ -1,50 +1,27 @@
package dto package dto
import "joylink.club/bj-rtsts-server/db/model"
type PagePublishedReqDto struct { type PagePublishedReqDto struct {
PageQueryDto PageQueryDto
Name string `json:"name" form:"name"` Name string `json:"name" form:"name"`
Release bool `json:"release" form:"release"` // 是否只要上架数据
} }
type PublishedListReqDto struct { type PublishedListReqDto struct {
Name string `json:"name" form:"name"` Name string `json:"name" form:"name"`
Type int32 `json:"type" form:"type"`
Category string `json:"category" form:"category"`
} }
type PublishedDto struct { type PublishedDto struct {
ID int32 `json:"id"` ID int32 `json:"id" form:"id"`
Name string `json:"name"` Name string `json:"name" form:"name"`
Proto []byte `json:"proto"` Proto []byte `json:"proto" form:"proto"`
UserID int32 `json:"userID"` UserID int32 `json:"userID" form:"userID"`
Note string `json:"note"` Note string `json:"note" form:"note"`
Type int32 `json:"type"` Type int32 `json:"type" form:"type"`
Category string `json:"category" form:"category"` Category string `json:"category" form:"category"`
PublishAt JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"` PublishAt JsonTime `json:"publishAt" form:"publishAt" time_format:"2006-01-02 15:04:05"`
} Status int32 `json:"status" form:"status"`
func ConvertFromPublisheds(ps []*model.Published, ds []*model.PublishedVersion) []*PublishedDto {
vm := make(map[int32]*model.PublishedVersion)
for _, m := range ds {
vm[m.ID] = m
}
var result []*PublishedDto
for _, p := range ps {
result = append(result, ConvertFromPublished(p, vm[p.DataID]))
}
return result
}
func ConvertFromPublished(gi *model.Published, d *model.PublishedVersion) *PublishedDto {
return &PublishedDto{
ID: gi.ID,
Name: gi.Code,
Category: gi.Category,
Type: gi.Type,
Proto: d.Proto,
UserID: d.UserID,
Note: d.Note,
PublishAt: JsonTime(d.PublishAt),
}
} }
type PublishReqDto struct { type PublishReqDto struct {
@ -53,6 +30,14 @@ type PublishReqDto struct {
//草稿数据的id //草稿数据的id
DraftId int32 `json:"draftId" form:"draftId"` DraftId int32 `json:"draftId" form:"draftId"`
Note string `json:"note" form:"note"` Note string `json:"note" form:"note"`
// 强制覆盖
Force bool `json:"force" form:"force"`
}
type PublishChangeReqDto struct {
Id int32 `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Release bool `json:"release" form:"release"`
} }
// PublishedGiSingleQueryDto 单个查询发布地图数据 // PublishedGiSingleQueryDto 单个查询发布地图数据
@ -60,3 +45,11 @@ type PublishedSingleQueryDto struct {
Name string `json:"name" form:"name"` Name string `json:"name" form:"name"`
Detail bool `json:"detail" form:"detail"` Detail bool `json:"detail" form:"detail"`
} }
type PublishHistoryDto struct {
Id int32 `json:"id" form:"id"`
Publisher string `json:"publisher" form:"publisher"`
PublishAt JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"`
Version int32 `json:"version" form:"version"`
Note string `json:"note" form:"note"`
}

View File

@ -2,7 +2,6 @@ package dto
import ( import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/ts/protos/graphicData" "joylink.club/bj-rtsts-server/ts/protos/graphicData"
) )
@ -13,6 +12,7 @@ type PageTrainInfoReqDto struct {
type TrainInfoReqDto struct { type TrainInfoReqDto struct {
Name string `json:"name" form:"name"` Name string `json:"name" form:"name"`
Pid int32 `json:"pid" form:"pid"`
} }
type TrainInfoDto struct { type TrainInfoDto struct {
@ -27,21 +27,21 @@ type TrainInfoDto struct {
Description string `json:"description" form:"description"` Description string `json:"description" form:"description"`
} }
func ConvertToTrainInfoDto(trailInfos []*model.TrainInfo) []*TrainInfoDto { func ConvertToTrainDto(trailInfos []*PublishedDto) []*TrainInfoDto {
var result []*TrainInfoDto var result []*TrainInfoDto
for _, t := range trailInfos { for _, t := range trailInfos {
result = append(result, ConvertDtoFromTrainInfo(t)) result = append(result, ConvertDtoFromTrain(t))
} }
return result return result
} }
func ConvertDtoFromTrainInfo(t *model.TrainInfo) *TrainInfoDto { func ConvertDtoFromTrain(t *PublishedDto) *TrainInfoDto {
message := &graphicData.Train{} message := &graphicData.Train{}
proto.Unmarshal(t.Proto, message) proto.Unmarshal(t.Proto, message)
return &TrainInfoDto{ return &TrainInfoDto{
Id: t.ID, Id: t.ID,
Name: t.Name, Name: t.Name,
Description: t.Description, Description: t.Note,
TrainModel: int32(message.TrainModel), TrainModel: int32(message.TrainModel),
CarriageLength: message.CarriageLength, CarriageLength: message.CarriageLength,
TotalLength: message.TotalLength, TotalLength: message.TotalLength,
@ -50,18 +50,3 @@ func ConvertDtoFromTrainInfo(t *model.TrainInfo) *TrainInfoDto {
TrainSets: message.TrainSets, TrainSets: message.TrainSets,
} }
} }
func ConvertTrainInfoFromDto(t *TrainInfoDto) *model.TrainInfo {
info := &model.TrainInfo{Name: t.Name, Description: t.Description}
message := &graphicData.Train{
TrainModel: graphicData.Train_TrainModel(t.TrainModel),
CarriageLength: t.CarriageLength,
TotalLength: t.TotalLength,
MinDiameter: t.MinDiameter,
MaxDiameter: t.MaxDiameter,
TrainSets: t.TrainSets,
}
b, _ := proto.Marshal(message)
info.Proto = b
return info
}

View File

@ -5,7 +5,6 @@ import (
"sync" "sync"
"time" "time"
"gorm.io/gorm/clause"
"joylink.club/bj-rtsts-server/db/dbquery" "joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model" "joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto" "joylink.club/bj-rtsts-server/dto"
@ -16,128 +15,157 @@ var publishMapMutex sync.Mutex
// 查找发布地图分页信息 // 查找发布地图分页信息
func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto { func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto {
dp := dbquery.Published p, pv := dbquery.Published, dbquery.PublishedVersion
where := dp.Where(dp.Status.Eq(1)) where := p.Select(p.ID, p.Code.As("name"), p.Type, p.Category, p.Status, pv.Note, pv.PublishAt).
LeftJoin(pv, p.DataID.EqCol(pv.ID)).Order(pv.PublishAt.Desc())
if req.Name != "" { if req.Name != "" {
where = where.Where(dp.Code.Like(fmt.Sprintf("%%%s%%", req.Name))) where = where.Where(p.Code.Like(fmt.Sprintf("%%%s%%", req.Name)))
} }
result, count, err := where.Debug().FindByPage(req.Offset(), req.Size) if req.Release {
where = where.Where(p.Status.Eq(1))
}
var records []*dto.PublishedDto
count, err := where.Debug().ScanByPage(&records, req.Offset(), req.Size)
if err != nil { if err != nil {
panic(sys_error.New("查询发布地图信息失败", err)) panic(sys_error.New("查询发布地图信息失败", err))
} }
var dataIds []int32 // 数据列表 return &dto.PageDto{Total: int(count), PageQueryDto: req.PageQueryDto, Records: records}
for _, r := range result {
dataIds = append(dataIds, r.DataID)
}
pv := dbquery.PublishedVersion
protoDatas, err := pv.Select(pv.ID, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
if err != nil {
panic(sys_error.New("查询发布地图信息失败", err))
}
return &dto.PageDto{
Total: int(count),
PageQueryDto: req.PageQueryDto,
Records: dto.ConvertFromPublisheds(result, protoDatas),
}
} }
// 地图信息列表信息 // 地图信息列表信息
func ListQueryPublished(req *dto.PublishedListReqDto) []*dto.PublishedDto { func ListQueryPublished(req *dto.PublishedListReqDto) []*dto.PublishedDto {
where := dbquery.Published.Where(dbquery.Published.Status.Eq(1)) p := dbquery.Published
where := p.Select(p.ID, p.Code.As("name"), p.Type, p.Category).Where(p.Status.Eq(1))
if req.Name != "" { if req.Name != "" {
where = where.Where(dbquery.Published.Code.Like(fmt.Sprintf("%%%s%%", req.Name))) where = where.Where(dbquery.Published.Code.Like(fmt.Sprintf("%%%s%%", req.Name)))
} }
result, err := where.Debug().Find() if req.Type != 0 {
where = where.Where(dbquery.Published.Type.Eq(req.Type))
}
if req.Category != "" {
where = where.Where(dbquery.Published.Category.Eq(req.Category))
}
var records []*dto.PublishedDto
err := where.Debug().Scan(&records)
if err != nil { if err != nil {
panic(sys_error.New("查询发布地图信息失败", err)) panic(sys_error.New("查询发布地图信息失败", err))
} }
var dataIds []int32 // 数据列表 return records
for _, r := range result {
dataIds = append(dataIds, r.DataID)
}
pv := dbquery.PublishedVersion
protoDatas, err := pv.Select(pv.ID, pv.Proto, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
if err != nil {
panic(sys_error.New("查询发布地图信息失败", err))
}
return dto.ConvertFromPublisheds(result, protoDatas)
} }
// 项目启动时查询发布地图信息 // 项目启动时查询发布地图信息
func ListAllPublished() []*dto.PublishedDto { func ListAllPublished() []*dto.PublishedDto {
p := dbquery.Published p, pv := dbquery.Published, dbquery.PublishedVersion
result, err := p.Select(p.ID, p.Code, p.Type, p.DataID).Where(dbquery.Published.Status.Eq(1)).Debug().Find() where := p.Select(p.ID, p.Code.As("name"), p.Type, p.Category, pv.Proto).
LeftJoin(pv, p.DataID.EqCol(pv.ID)).
Where(p.Status.Eq(1), p.Type.Neq(trainDataType)).Order(pv.PublishAt)
var records []*dto.PublishedDto
err := where.Debug().Scan(&records)
if err != nil { if err != nil {
panic(sys_error.New("查询发布地图信息失败", err)) panic(sys_error.New("查询发布地图信息失败", err))
} }
var dataIds []int32 // 数据列表 return records
for _, r := range result {
dataIds = append(dataIds, r.DataID)
}
pv := dbquery.PublishedVersion
protoDatas, err := pv.Select(pv.ID, pv.Proto, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
if err != nil {
panic(sys_error.New("查询发布地图信息失败", err))
}
return dto.ConvertFromPublisheds(result, protoDatas)
} }
// 查询详细信息 // 查询详细信息
func GetPublishedById(id int32) *dto.PublishedDto { func GetPublishedById(id int32) *dto.PublishedDto {
data, err := dbquery.Published.Where(dbquery.Published.ID.Eq(id)).Debug().First() p, pv := dbquery.Published, dbquery.PublishedVersion
where := p.Select(p.ID, p.Code.As("name"), p.Type, p.Category, pv.Proto).
LeftJoin(pv, p.DataID.EqCol(pv.ID)).
Where(p.ID.Eq(id), p.Status.Eq(1))
var record dto.PublishedDto
err := where.Debug().Scan(&record)
if err != nil { if err != nil {
panic(sys_error.New("查询发布地图信息失败", err)) panic(sys_error.New("查询发布地图信息失败", err))
} }
pv := dbquery.PublishedVersion return &record
protoData, err := pv.Where(pv.ID.Eq(data.DataID)).Debug().First()
if err != nil {
panic(sys_error.New("查询发布地图信息失败", err))
}
return dto.ConvertFromPublished(data, protoData)
} }
// 草稿发布 // 草稿发布
func PublishFormDraft(req *dto.PublishReqDto, user *model.User) { func PublishFormDraft(req *dto.PublishReqDto, user *model.User) {
publishMapMutex.Lock()
defer publishMapMutex.Unlock()
draft := QueryDrafting(req.DraftId) draft := QueryDrafting(req.DraftId)
if draft.Proto == nil || len(draft.Proto) == 0 { if draft.Proto == nil || len(draft.Proto) == 0 {
panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId))) panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)))
} }
// 查询版本信息 publishData(&dto.PublishedDto{
vds, _ := dbquery.PublishedVersion.Select(dbquery.PublishedVersion.Version). Name: req.Name,
Where(dbquery.PublishedVersion.Code.Eq(req.Name)).Order(dbquery.PublishedVersion.Version.Desc()).Find() Proto: draft.Proto,
var version int32 = 1 Type: draft.Type,
if len(vds) > 0 { Category: draft.Category,
version = version + vds[len(vds)-1].Version UserID: user.ID,
} Note: req.Note,
// 存入新版本数据 }, req.Force)
err := dbquery.PublishedVersion.Save(&model.PublishedVersion{
Code: req.Name,
Proto: draft.Proto,
UserID: user.ID,
PublishAt: time.Now(),
Note: req.Note,
Version: version,
})
if err != nil {
panic(sys_error.New("发布草稿数据失败", err))
}
versionData, err := dbquery.PublishedVersion.Select(dbquery.PublishedVersion.ID).
Where(dbquery.PublishedVersion.Code.Eq(req.Name), dbquery.PublishedVersion.Version.Eq(version)).First()
if err != nil {
panic(sys_error.New("发布草稿数据失败", err))
}
// 更新发布数据
dbquery.Published.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: dbquery.Published.Code.ColumnName().String()}},
DoUpdates: clause.AssignmentColumns([]string{dbquery.Published.DataID.ColumnName().String()}),
}).Create(&model.Published{Code: req.Name, Type: draft.Type, Category: draft.Category, DataID: versionData.ID, Status: 1})
} }
// 删除发布图 // 发布数据
func publishData(publishData *dto.PublishedDto, force bool) {
publishMapMutex.Lock()
defer publishMapMutex.Unlock()
p, pv := dbquery.Published, dbquery.PublishedVersion
// 查询发布图数据
oldPs, err1 := p.Where(p.Code.Eq(publishData.Name)).Find()
if err1 != nil {
panic(sys_error.New("发布草稿数据失败", err1))
}
var pid, version int32 = 0, 1
if len(oldPs) > 0 { // 发布图数据不为空
pid = oldPs[0].ID
if oldPs[0].Category != publishData.Category || publishData.Type != oldPs[0].Type {
if !force { // 非强制覆盖
panic(sys_error.New("草稿数据与在线数据类型不一致"))
} else {
p.
Where(p.ID.Eq(pid)).
UpdateColumns(&model.Published{ID: pid, Type: publishData.Type, Category: publishData.Category})
}
}
vds, _ := pv.Select(pv.Version).Where(pv.PublishID.Eq(pid)).Order(pv.Version.Desc()).Find()
if len(vds) > 0 { // 版本号 + 1
version = version + vds[0].Version
}
}
// 存入新版本数据
pvd := &model.PublishedVersion{
Code: publishData.Name,
Proto: publishData.Proto,
UserID: publishData.UserID,
Note: publishData.Note,
Type: publishData.Type,
Category: publishData.Category,
PublishAt: time.Now(),
Version: version,
PublishID: pid,
}
err2 := pv.Create(pvd)
if err2 != nil {
panic(sys_error.New("发布草稿数据失败", err2))
}
// 更新发布数据
if pid == 0 {
pd := &model.Published{
Code: publishData.Name,
Type: publishData.Type,
Category: publishData.Category,
DataID: pvd.ID,
Status: 1,
}
// 保存发布信息
err4 := p.Create(pd)
if err4 != nil {
panic(sys_error.New("发布草稿数据失败", err4))
}
// 更新发布版本信息
pv.Where(pv.ID.Eq(pvd.ID)).UpdateColumn(pv.PublishID, pd.ID)
} else {
// 更新发布信息
p.Where(p.ID.Eq(pid)).UpdateColumn(p.DataID, pvd.ID)
}
}
// 删除发布数据
func DeletePublishedById(id int32) { func DeletePublishedById(id int32) {
dbquery.Published.Debug().Where(dbquery.Published.ID.Eq(id)).UpdateColumn(dbquery.Published.Status, 0) dbquery.Published.Where(dbquery.Published.ID.Eq(id)).Delete()
dbquery.PublishedVersion.Where(dbquery.PublishedVersion.PublishID.Eq(id)).Delete()
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(id)).Delete() dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(id)).Delete()
} }
@ -147,22 +175,21 @@ func SaveAsDraftingFromPublish(id int32, user *model.User, name string) {
if num > 0 { // 处理重名情况 if num > 0 { // 处理重名情况
panic(sys_error.New(fmt.Sprintf("草稿【%s】已存在", name))) panic(sys_error.New(fmt.Sprintf("草稿【%s】已存在", name)))
} }
published, err := dbquery.Published.Where(dbquery.Published.ID.Eq(id)).Debug().First() p, pv := dbquery.Published, dbquery.PublishedVersion
where := p.Select(p.Type, p.Category, pv.Proto).LeftJoin(pv, p.DataID.EqCol(pv.ID)).Where(p.ID.Eq(id), p.Status.Eq(1))
var record dto.PublishedDto
err := where.Debug().Scan(&record)
if err != nil { if err != nil {
panic(sys_error.New("查询发布数据出错", err)) panic(sys_error.New("查询发布地图信息失败", err))
}
versionData, err := dbquery.PublishedVersion.Where(dbquery.PublishedVersion.ID.Eq(published.DataID)).First()
if err != nil {
panic(sys_error.New("查询发布数据出错", err))
} }
err1 := dbquery.Drafting.Save(&model.Drafting{ err1 := dbquery.Drafting.Save(&model.Drafting{
Name: name, Name: name,
Category: published.Category, Category: record.Category,
Proto: versionData.Proto, Proto: record.Proto,
CreatorID: user.ID, CreatorID: user.ID,
CreatedAt: time.Now(), CreatedAt: time.Now(),
UpdateAt: time.Now(), UpdateAt: time.Now(),
Type: published.Type, Type: record.Type,
}) })
if err1 != nil { if err1 != nil {
panic(sys_error.New("保存草稿出错", err1)) panic(sys_error.New("保存草稿出错", err1))
@ -172,37 +199,66 @@ func SaveAsDraftingFromPublish(id int32, user *model.User, name string) {
// 查询项目关联的详细数据 // 查询项目关联的详细数据
func QueryProjectPublished(id int32) []*model.Published { func QueryProjectPublished(id int32) []*model.Published {
// 获取项目关联的发布地图 // 获取项目关联的发布地图
dppl := dbquery.ProjectPublishLink dppl, p := dbquery.ProjectPublishLink, dbquery.Published
links, _ := dppl.Select(dppl.Mid).Where(dppl.Pid.Eq(id)).Find() var publisheds []*model.Published
if len(links) == 0 { err := dppl.Select(p.ID, p.Code, p.Category, p.Type).
return nil LeftJoin(p, p.ID.EqCol(dppl.Mid)).
Where(dppl.Pid.Eq(id), p.Status.Eq(1)).Debug().Order(p.Type, p.Code).Scan(&publisheds)
if err != nil {
panic(sys_error.New("发布草稿数据失败", err))
} }
mids := make([]int32, len(links))
for i, m := range links {
mids[i] = m.Mid
}
dp := dbquery.Published
publisheds, _ := dp.
Select(dp.ID, dp.Code, dp.Category, dp.Type).
Where(dp.ID.In(mids...), dp.Status.Eq(1)).
Order(dp.Type, dp.Code).
Find()
return publisheds return publisheds
} }
// 根据名称获取地图详细信息 // 根据名称获取地图详细信息
func GetPublishedGiByName(param *dto.PublishedSingleQueryDto) *dto.PublishedDto { func GetPublishedGiByName(param *dto.PublishedSingleQueryDto) *dto.PublishedDto {
published, err := dbquery.Published.Where(dbquery.Published.Code.Eq(param.Name), dbquery.Published.Status.Eq(1)).Debug().First() p, pv := dbquery.Published, dbquery.PublishedVersion
where := p.Select(p.ID, p.Code.As("name"), p.Type, p.Category, pv.Proto).
LeftJoin(pv, p.DataID.EqCol(pv.ID)).
Where(p.Code.Eq(param.Name), p.Status.Eq(1))
var record dto.PublishedDto
err := where.Debug().Scan(&record)
if err != nil { if err != nil {
panic(sys_error.New("查询发布数据出错", err)) panic(sys_error.New("查询发布地图信息失败", err))
} }
detailData := &model.PublishedVersion{} return &record
if param.Detail { }
versionData, err := dbquery.PublishedVersion.Where(dbquery.PublishedVersion.ID.Eq(published.DataID)).First()
if err != nil { // 修改发布数据状态
panic(sys_error.New("查询发布数据出错", err)) func ChangePublishStatus(id int32, release bool) {
} var status int
detailData = versionData if release {
} status = 1
return dto.ConvertFromPublished(published, detailData) }
dbquery.Published.Debug().Where(dbquery.Published.ID.Eq(id)).UpdateColumn(dbquery.Published.Status, status)
if !release { // 下架时,删除关联关系
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(id)).Delete()
}
}
// 修改发布Code
func ChangePublishCode(id int32, code string) {
p := dbquery.Published
count, err := p.Where(p.ID.Neq(id), p.Code.Eq(code)).Count()
if err != nil {
panic(sys_error.New("修改发布名称失败", err))
}
if count > 0 {
panic(sys_error.New("修改名称失败:名称已存在"))
}
p.Debug().Where(dbquery.Published.ID.Eq(id)).UpdateColumn(dbquery.Published.Code, code)
}
// 查询发布历史
func GetPublishHistory(id int32) []*dto.PublishHistoryDto {
u, pv := dbquery.User, dbquery.PublishedVersion
var records []*dto.PublishHistoryDto
err := pv.
Select(pv.ID, pv.PublishAt, pv.Note, pv.Version, u.Name.As("publisher")).
LeftJoin(u, u.ID.EqCol(pv.UserID)).
Where(pv.PublishID.Eq(id)).Order(pv.Version.Desc()).Scan(&records)
if err != nil {
panic(sys_error.New("查询发布历史信息失败", err))
}
return records
} }

View File

@ -2,72 +2,127 @@ package service
import ( import (
"fmt" "fmt"
"time"
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/db/dbquery" "joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model" "joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto" "joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/sys_error"
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
) )
// 查询列车信息列表 var trainDataType = int32(graphicData.PictureType_TrainData)
func PageTrainInfoQuery(query *dto.PageTrainInfoReqDto) *dto.PageDto {
d := dbquery.TrainInfo
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.Proto, d.Description).FindByPage(query.Offset(), query.Size)
if err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToTrainInfoDto(records)}
}
// 查询列车信息列表 // 查询列车信息列表
func ListTrainInfoQuery(query *dto.TrainInfoReqDto) []*model.TrainInfo { func PageTrainInfoByPublished(query *dto.PageTrainInfoReqDto) *dto.PageDto {
d := dbquery.TrainInfo d, dv := dbquery.Published, dbquery.PublishedVersion
dq := d.Where() dq := d.Select(d.ID, d.Code.As("name"), dv.Note, dv.Proto).
LeftJoin(dv, d.DataID.EqCol(dv.ID)).
Where(d.Type.Eq(trainDataType), d.Status.Eq(1)).
Order(dv.PublishAt)
if query.Name != "" { if query.Name != "" {
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) dq = dq.Where(d.Code.Like(fmt.Sprintf("%%%s%%", query.Name)))
} }
records, err := dq.Debug().Select(d.ID, d.Name, d.Proto).Find() var records []*dto.PublishedDto
total, err := dq.Debug().ScanByPage(&records, query.Offset(), query.Size)
if err != nil { if err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) panic(sys_error.New("列车信息查询错误", err))
} }
return records return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToTrainDto(records)}
} }
// 创建列车信息 // 根据项目Id查询列车信息
func CreateTrainInfo(td *dto.TrainInfoDto) bool { func ListTrainByProject(query *dto.TrainInfoReqDto) []*dto.TrainInfoDto {
d := dto.ConvertTrainInfoFromDto(td) ppl, p, pv := dbquery.ProjectPublishLink, dbquery.Published, dbquery.PublishedVersion
err := dbquery.TrainInfo.Save(d) where := ppl.Select(p.ID, p.Code.As("name"), pv.Note, pv.Proto).
if err != nil { LeftJoin(p, ppl.Mid.EqCol(p.ID)).
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) LeftJoin(pv, p.DataID.EqCol(pv.ID))
if query.Name != "" {
where = where.Where(p.Code.Like(fmt.Sprintf("%%%s%%", query.Name)))
} }
if query.Pid != 0 {
where = where.Where(ppl.Pid.Eq(query.Pid))
}
var records []*dto.PublishedDto
err := where.Where(p.Type.Eq(trainDataType), p.Status.Eq(1)).Order(pv.PublishAt).Scan(&records)
if err != nil {
panic(sys_error.New("列车信息查询错误", err))
}
return dto.ConvertToTrainDto(records)
}
// 发布列车信息
func CreateTrain(td *dto.TrainInfoDto, user *model.User) bool {
publishData(&dto.PublishedDto{
Name: td.Name,
Proto: convertTrainProto(td),
Type: trainDataType,
UserID: user.ID,
Note: td.Description,
}, true)
return true return true
} }
// 转成列车proto
func convertTrainProto(t *dto.TrainInfoDto) []byte {
message := &graphicData.Train{
TrainModel: graphicData.Train_TrainModel(t.TrainModel),
CarriageLength: t.CarriageLength,
TotalLength: t.TotalLength,
MinDiameter: t.MinDiameter,
MaxDiameter: t.MaxDiameter,
TrainSets: t.TrainSets,
}
b, _ := proto.Marshal(message)
return b
}
// 查询列车信息 // 查询列车信息
func QueryTrainInfo(id int32) *dto.TrainInfoDto { func QueryTrain(id int32) *dto.TrainInfoDto {
dt := dbquery.TrainInfo d, dv := dbquery.Published, dbquery.PublishedVersion
data, err := dt.Where(dt.ID.Eq(id)).Debug().First() var record dto.PublishedDto
err := d.Select(d.ID, d.Code.As("name"), dv.Note, dv.Proto).
LeftJoin(dv, d.DataID.EqCol(dv.ID)).
Where(d.Type.Eq(trainDataType), d.ID.Eq(id)).
Scan(&record)
if err != nil { if err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) panic(sys_error.New("列车信息查询错误", err))
} }
return dto.ConvertDtoFromTrainInfo(data) return dto.ConvertDtoFromTrain(&record)
} }
// 更新列车信息 // 更新列车信息
func UpdateTrainInfo(id int32, td *dto.TrainInfoDto) bool { func UpdateTrain(id int32, td *dto.TrainInfoDto, user *model.User) bool {
d := dto.ConvertTrainInfoFromDto(td) p, pv := dbquery.Published, dbquery.PublishedVersion
d.ID = id pd, err := p.Select(p.ID, p.Code, p.DataID).Where(p.ID.Eq(id)).First()
_, err2 := dbquery.TrainInfo.Updates(d) if err != nil {
panic(sys_error.New("更新列车信息错误", err))
}
if td.Name != pd.Code {
ChangePublishCode(id, td.Name)
}
pvd, err := pv.Select(pv.Version).Where(pv.ID.Eq(pd.DataID)).First()
if err != nil {
panic(sys_error.New("更新列车信息错误", err))
}
pvdn := &model.PublishedVersion{
Proto: convertTrainProto(td),
UserID: user.ID,
PublishAt: time.Now(),
Note: td.Description,
Version: pvd.Version + 1,
Code: td.Name,
PublishID: id,
Type: trainDataType,
}
err2 := pv.Create(pvdn)
if err2 != nil { if err2 != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()}) panic(sys_error.New("更新列车信息错误", err2))
}
_, err3 := p.Where(p.ID.Eq(id)).UpdateColumn(p.DataID, pvdn.ID)
if err3 != nil {
panic(sys_error.New("更新列车信息错误", err3))
} }
return true return true
} }
// 删除列车信息
func DeleteTrainInfoById(id int) {
_, _ = dbquery.TrainInfo.Debug().Where(dbquery.TrainInfo.ID.Eq(int32(id))).Delete()
}

View File

@ -31,6 +31,8 @@ const (
PictureType_RelayCabinetLayout PictureType = 2 PictureType_RelayCabinetLayout PictureType = 2
// * IBP盘 // * IBP盘
PictureType_IBP PictureType = 3 PictureType_IBP PictureType = 3
// * 列车数据
PictureType_TrainData PictureType = 4
) )
// Enum value maps for PictureType. // Enum value maps for PictureType.
@ -40,12 +42,14 @@ var (
1: "Psl", 1: "Psl",
2: "RelayCabinetLayout", 2: "RelayCabinetLayout",
3: "IBP", 3: "IBP",
4: "TrainData",
} }
PictureType_value = map[string]int32{ PictureType_value = map[string]int32{
"StationLayout": 0, "StationLayout": 0,
"Psl": 1, "Psl": 1,
"RelayCabinetLayout": 2, "RelayCabinetLayout": 2,
"IBP": 3, "IBP": 3,
"TrainData": 4,
} }
) )
@ -80,13 +84,14 @@ var File_picture_proto protoreflect.FileDescriptor
var file_picture_proto_rawDesc = []byte{ var file_picture_proto_rawDesc = []byte{
0x0a, 0x0d, 0x70, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 0x0a, 0x0d, 0x70, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a,
0x4a, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11, 0x59, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11,
0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x10, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x73, 0x6c, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x65, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x73, 0x6c, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x65,
0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74,
0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x49, 0x42, 0x50, 0x10, 0x03, 0x42, 0x19, 0x5a, 0x17, 0x2e, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x49, 0x42, 0x50, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x54,
0x2f, 0x74, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x72, 0x61, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x10, 0x04, 0x42, 0x19, 0x5a, 0x17, 0x2e, 0x2f,
0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x74, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69,
0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

File diff suppressed because it is too large Load Diff