【发布地图时修改原有的关联信息】

This commit is contained in:
weizhihong 2023-09-13 11:23:52 +08:00
parent 20dd4e942f
commit 232d1cd0f4
1 changed files with 9 additions and 2 deletions

View File

@ -57,10 +57,13 @@ func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
}
//需要删除的同名数据
oldData, _ := dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Name.Eq(req.Name)).Find()
if len(oldData) > 0 {
oldDataLen := len(oldData)
mids := make([]int32, oldDataLen)
if oldDataLen > 0 {
// 逻辑删除
dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Name.Eq(req.Name)).UpdateColumn(dbquery.PublishedGi.Status, 0)
for _, v := range oldData {
for i, v := range oldData {
mids[i] = v.ID
memory.DeleteMapVerifyStructure(v.ID) // 移除内存中的发布信息
}
}
@ -81,6 +84,10 @@ func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
newData, _ := dbquery.PublishedGi.
Where(dbquery.PublishedGi.Name.Eq(req.Name), dbquery.PublishedGi.Status.Eq(1)).
Order(dbquery.PublishedGi.PublishAt.Desc()).First()
// 对项目关联的地图进行修改
if oldDataLen > 0 {
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(mids...)).UpdateColumn(dbquery.ProjectPublishLink.Mid, newData.ID)
}
// 地图信息更新到缓存
if newData != nil {
memory.PublishMapVerifyStructure(newData)