|
@@ -50,8 +50,19 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
@@ -50,8 +50,19 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
50
|
if err != nil {
|
50
|
if err != nil {
|
51
|
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
|
51
|
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
|
52
|
}
|
52
|
}
|
|
|
53
|
+ author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, articleData.AuthorId)
|
|
|
54
|
+ company, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
|
53
|
if len(markRecord) > 0 {
|
55
|
if len(markRecord) > 0 {
|
54
|
- markRecord[0].Author = articleData.Author
|
56
|
+ if author != nil {
|
|
|
57
|
+ markRecord[0].Author = domain.UserSimple{
|
|
|
58
|
+ Id: author.Id,
|
|
|
59
|
+ Name: author.Name,
|
|
|
60
|
+ Avatar: author.Avatar,
|
|
|
61
|
+ Position: author.Position,
|
|
|
62
|
+ Company: company.Name,
|
|
|
63
|
+ CompanyId: company.Id,
|
|
|
64
|
+ }
|
|
|
65
|
+ }
|
55
|
markRecord[0].Title = articleData.Title
|
66
|
markRecord[0].Title = articleData.Title
|
56
|
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
|
67
|
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
|
57
|
if err != nil {
|
68
|
if err != nil {
|
|
@@ -61,14 +72,6 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
@@ -61,14 +72,6 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
61
|
return resp, nil
|
72
|
return resp, nil
|
62
|
}
|
73
|
}
|
63
|
// 新建一个标记
|
74
|
// 新建一个标记
|
64
|
-
|
|
|
65
|
- articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
|
|
|
66
|
- if err != nil {
|
|
|
67
|
- return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
|
|
|
68
|
- }
|
|
|
69
|
- if articleInfo.CompanyId != req.CompanyId {
|
|
|
70
|
- return nil, xerr.NewErrMsg("标记浏览记录失败")
|
|
|
71
|
- }
|
|
|
72
|
newMark := domain.UserReadArticle{
|
75
|
newMark := domain.UserReadArticle{
|
73
|
Id: 0,
|
76
|
Id: 0,
|
74
|
CompanyId: req.CompanyId,
|
77
|
CompanyId: req.CompanyId,
|
|
@@ -81,13 +84,23 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
|
@@ -81,13 +84,23 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr |
81
|
DeletedAt: 0,
|
84
|
DeletedAt: 0,
|
82
|
Version: 0,
|
85
|
Version: 0,
|
83
|
}
|
86
|
}
|
|
|
87
|
+ if author != nil {
|
|
|
88
|
+ newMark.Author = domain.UserSimple{
|
|
|
89
|
+ Id: author.Id,
|
|
|
90
|
+ Name: author.Name,
|
|
|
91
|
+ Avatar: author.Avatar,
|
|
|
92
|
+ Position: author.Position,
|
|
|
93
|
+ Company: company.Name,
|
|
|
94
|
+ CompanyId: company.Id,
|
|
|
95
|
+ }
|
|
|
96
|
+ }
|
84
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
97
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
85
|
_, err = l.svcCtx.UserReadArticleRepository.Insert(ctx, c, &newMark)
|
98
|
_, err = l.svcCtx.UserReadArticleRepository.Insert(ctx, c, &newMark)
|
86
|
if err != nil {
|
99
|
if err != nil {
|
87
|
return err
|
100
|
return err
|
88
|
}
|
101
|
}
|
89
|
//增加浏览计数
|
102
|
//增加浏览计数
|
90
|
- err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo.Id)
|
103
|
+ err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleData.Id)
|
91
|
return err
|
104
|
return err
|
92
|
}, true)
|
105
|
}, true)
|
93
|
if err != nil {
|
106
|
if err != nil {
|