...
|
...
|
@@ -30,7 +30,10 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi |
|
|
func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) {
|
|
|
// 获取文章内容
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
|
|
|
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("读取公司数据失败", err)
|
|
|
}
|
|
|
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("读取文章内容失败", err)
|
...
|
...
|
@@ -66,6 +69,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( |
|
|
}
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
queryOption := domain.NewQueryOptions().
|
|
|
WithFindOnly().
|
|
|
MustWithKV("articleId", articleInfo.Id)
|
...
|
...
|
@@ -74,6 +78,10 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( |
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("读取文章内容失败", err)
|
|
|
}
|
|
|
|
|
|
//获取作者信息
|
|
|
author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(req.UserId))
|
|
|
|
|
|
var meLoveFlag int
|
|
|
if req.UserId > 0 {
|
|
|
// 获取我对文章的点赞标识
|
...
|
...
|
@@ -120,10 +128,10 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( |
|
|
AuthorId: articleInfo.AuthorId,
|
|
|
Author: types.ArticleAuthor{
|
|
|
Id: articleInfo.Author.Id,
|
|
|
Name: articleInfo.Author.Name,
|
|
|
Avatar: articleInfo.Author.Avatar,
|
|
|
Position: articleInfo.Author.Position,
|
|
|
Company: articleInfo.Author.Company,
|
|
|
Name: "",
|
|
|
Avatar: "",
|
|
|
Position: "",
|
|
|
Company: companyInfo.Name,
|
|
|
},
|
|
|
CreatedAt: articleInfo.CreatedAt,
|
|
|
Section: articleSection,
|
...
|
...
|
@@ -148,7 +156,15 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( |
|
|
if len(backupList) > 0 {
|
|
|
resp.Edit = 1
|
|
|
}
|
|
|
|
|
|
if author != nil {
|
|
|
resp.Author = types.ArticleAuthor{
|
|
|
Id: articleInfo.Author.Id,
|
|
|
Name: author.Name,
|
|
|
Avatar: author.Avatar,
|
|
|
Position: author.Position,
|
|
|
Company: companyInfo.Name,
|
|
|
}
|
|
|
}
|
|
|
for k, v := range articleInfo.MatchUrl {
|
|
|
resp.MatchUrl[k] = v
|
|
|
}
|
...
|
...
|
|