正在显示
4 个修改的文件
包含
10 行增加
和
10 行删除
@@ -192,9 +192,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -192,9 +192,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
192 | } | 192 | } |
193 | 193 | ||
194 | // 生成 备份数据 | 194 | // 生成 备份数据 |
195 | - backupData := newArticle.MakeBackup(articleAuthor, sectionList) | ||
196 | - backupData.Action = "原始版本" | ||
197 | - | 195 | + backupData := newArticle.MakeBackup(articleAuthor, sectionList, "原始版本") |
198 | _, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, backupData) | 196 | _, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, backupData) |
199 | if err != nil { | 197 | if err != nil { |
200 | return xerr.NewErrMsgErr("创建文章失败", err) | 198 | return xerr.NewErrMsgErr("创建文章失败", err) |
@@ -58,8 +58,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -58,8 +58,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
58 | Avatar: userMe.User.Avatar, | 58 | Avatar: userMe.User.Avatar, |
59 | CompanyId: userToken.CompanyId, | 59 | CompanyId: userToken.CompanyId, |
60 | Company: userMe.CurrentCompany.Name, | 60 | Company: userMe.CurrentCompany.Name, |
61 | - }, sectionList) | ||
62 | - newBackUp.Action = "恢复" | 61 | + }, sectionList, "恢复") |
63 | _ = newBackUp.CheckChangeField(oldBackup) | 62 | _ = newBackUp.CheckChangeField(oldBackup) |
64 | 63 | ||
65 | article.Version = article.Version + 1 | 64 | article.Version = article.Version + 1 |
@@ -75,7 +75,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -75,7 +75,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
75 | if err != nil { | 75 | if err != nil { |
76 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 76 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
77 | } | 77 | } |
78 | - oldBackup := article.MakeBackup(operator, sectionList) | 78 | + oldBackup := article.MakeBackup(operator, sectionList, "编辑") |
79 | // 获取图片的尺寸大小 | 79 | // 获取图片的尺寸大小 |
80 | images, err := l.getImages(req) | 80 | images, err := l.getImages(req) |
81 | if err != nil { | 81 | if err != nil { |
@@ -159,8 +159,8 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -159,8 +159,8 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | - backup := article.MakeBackup(operator, updateSection) | ||
163 | - backup.Action = "编辑" | 162 | + backup := article.MakeBackup(operator, updateSection, "编辑") |
163 | + | ||
164 | if ok := backup.CheckChangeField(oldBackup); ok { | 164 | if ok := backup.CheckChangeField(oldBackup); ok { |
165 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | 165 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) |
166 | if err != nil { | 166 | if err != nil { |
@@ -96,7 +96,7 @@ func (a ArticleShow) Named() string { | @@ -96,7 +96,7 @@ func (a ArticleShow) Named() string { | ||
96 | } | 96 | } |
97 | 97 | ||
98 | // 设置文章的备份数据 | 98 | // 设置文章的备份数据 |
99 | -func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *ArticleBackup { | 99 | +func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection, action string) *ArticleBackup { |
100 | sectionBackup := make([]ArticleSection, len(section)) | 100 | sectionBackup := make([]ArticleSection, len(section)) |
101 | for i := range section { | 101 | for i := range section { |
102 | sectionBackup[i] = *section[i] | 102 | sectionBackup[i] = *section[i] |
@@ -114,7 +114,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -114,7 +114,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
114 | Section: sectionBackup, | 114 | Section: sectionBackup, |
115 | Images: make([]Image, len(m.Images)), | 115 | Images: make([]Image, len(m.Images)), |
116 | Videos: make([]Video, len(m.Videos)), | 116 | Videos: make([]Video, len(m.Videos)), |
117 | - Action: "", | 117 | + Action: action, |
118 | TargetUser: m.TargetUser, | 118 | TargetUser: m.TargetUser, |
119 | WhoRead: m.WhoRead, | 119 | WhoRead: m.WhoRead, |
120 | WhoReview: m.WhoReview, | 120 | WhoReview: m.WhoReview, |
@@ -122,6 +122,9 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -122,6 +122,9 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
122 | MatchUrl: map[string]string{}, | 122 | MatchUrl: map[string]string{}, |
123 | Location: m.Location, | 123 | Location: m.Location, |
124 | } | 124 | } |
125 | + if action == "原始版本" { | ||
126 | + b.ChangeField = append(b.ChangeField, "Section") | ||
127 | + } | ||
125 | copy(b.Videos, m.Videos) | 128 | copy(b.Videos, m.Videos) |
126 | copy(b.Images, m.Images) | 129 | copy(b.Images, m.Images) |
127 | for k, v := range m.MatchUrl { | 130 | for k, v := range m.MatchUrl { |
-
请 注册 或 登录 后发表评论