作者 tangxvhui

调整文章备份数据的处理方式

... ... @@ -192,9 +192,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
// 生成 备份数据
backupData := newArticle.MakeBackup(articleAuthor, sectionList)
backupData.Action = "原始版本"
backupData := newArticle.MakeBackup(articleAuthor, sectionList, "原始版本")
_, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, backupData)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
... ...
... ... @@ -58,8 +58,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
Avatar: userMe.User.Avatar,
CompanyId: userToken.CompanyId,
Company: userMe.CurrentCompany.Name,
}, sectionList)
newBackUp.Action = "恢复"
}, sectionList, "恢复")
_ = newBackUp.CheckChangeField(oldBackup)
article.Version = article.Version + 1
... ...
... ... @@ -75,7 +75,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
oldBackup := article.MakeBackup(operator, sectionList)
oldBackup := article.MakeBackup(operator, sectionList, "编辑")
// 获取图片的尺寸大小
images, err := l.getImages(req)
if err != nil {
... ... @@ -159,8 +159,8 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
}
}
backup := article.MakeBackup(operator, updateSection)
backup.Action = "编辑"
backup := article.MakeBackup(operator, updateSection, "编辑")
if ok := backup.CheckChangeField(oldBackup); ok {
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup)
if err != nil {
... ...
... ... @@ -96,7 +96,7 @@ func (a ArticleShow) Named() string {
}
// 设置文章的备份数据
func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *ArticleBackup {
func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection, action string) *ArticleBackup {
sectionBackup := make([]ArticleSection, len(section))
for i := range section {
sectionBackup[i] = *section[i]
... ... @@ -114,7 +114,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
Section: sectionBackup,
Images: make([]Image, len(m.Images)),
Videos: make([]Video, len(m.Videos)),
Action: "",
Action: action,
TargetUser: m.TargetUser,
WhoRead: m.WhoRead,
WhoReview: m.WhoReview,
... ... @@ -122,6 +122,9 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
MatchUrl: map[string]string{},
Location: m.Location,
}
if action == "原始版本" {
b.ChangeField = append(b.ChangeField, "Section")
}
copy(b.Videos, m.Videos)
copy(b.Images, m.Images)
for k, v := range m.MatchUrl {
... ...