【解决发布重复问题】

This commit is contained in:
weizhihong 2023-10-20 14:27:13 +08:00
parent 3648e51863
commit 1ca573c054

View File

@ -2,6 +2,7 @@ package service
import ( import (
"fmt" "fmt"
"sync"
"time" "time"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory" "joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
@ -11,6 +12,8 @@ import (
"joylink.club/bj-rtsts-server/dto/publishedGi" "joylink.club/bj-rtsts-server/dto/publishedGi"
) )
var publishMapMutex sync.Mutex
func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto { func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto {
dp := dbquery.PublishedGi dp := dbquery.PublishedGi
where := dp.Where(dp.Status.Eq(1)) where := dp.Where(dp.Status.Eq(1))
@ -55,6 +58,8 @@ func GetPublishedGiById(id int) (*model.PublishedGi, error) {
} }
func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) { func PublishFormDraft(req *publishedGi.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(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)) panic(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId))