...
|
...
|
@@ -50,8 +50,19 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
|
|
|
}
|
|
|
author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, articleData.AuthorId)
|
|
|
company, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
|
|
|
if len(markRecord) > 0 {
|
|
|
markRecord[0].Author = articleData.Author
|
|
|
if author != nil {
|
|
|
markRecord[0].Author = domain.UserSimple{
|
|
|
Id: author.Id,
|
|
|
Name: author.Name,
|
|
|
Avatar: author.Avatar,
|
|
|
Position: author.Position,
|
|
|
Company: company.Name,
|
|
|
CompanyId: company.Id,
|
|
|
}
|
|
|
}
|
|
|
markRecord[0].Title = articleData.Title
|
|
|
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
|
|
|
if err != nil {
|
...
|
...
|
@@ -61,14 +72,6 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
|
return resp, nil
|
|
|
}
|
|
|
// 新建一个标记
|
|
|
|
|
|
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
|
|
|
}
|
|
|
if articleInfo.CompanyId != req.CompanyId {
|
|
|
return nil, xerr.NewErrMsg("标记浏览记录失败")
|
|
|
}
|
|
|
newMark := domain.UserReadArticle{
|
|
|
Id: 0,
|
|
|
CompanyId: req.CompanyId,
|
...
|
...
|
@@ -81,13 +84,23 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
|
DeletedAt: 0,
|
|
|
Version: 0,
|
|
|
}
|
|
|
if author != nil {
|
|
|
newMark.Author = domain.UserSimple{
|
|
|
Id: author.Id,
|
|
|
Name: author.Name,
|
|
|
Avatar: author.Avatar,
|
|
|
Position: author.Position,
|
|
|
Company: company.Name,
|
|
|
CompanyId: company.Id,
|
|
|
}
|
|
|
}
|
|
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
|
|
_, err = l.svcCtx.UserReadArticleRepository.Insert(ctx, c, &newMark)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//增加浏览计数
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo.Id)
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleData.Id)
|
|
|
return err
|
|
|
}, true)
|
|
|
if err != nil {
|
...
|
...
|
|