正在显示
2 个修改的文件
包含
20 行增加
和
4 行删除
@@ -45,30 +45,35 @@ func (l *MiniMyBeLikedLogic) MiniMyBeLiked(req *types.MiniBeLikedRequest) (resp | @@ -45,30 +45,35 @@ func (l *MiniMyBeLikedLogic) MiniMyBeLiked(req *types.MiniBeLikedRequest) (resp | ||
45 | return resp, nil | 45 | return resp, nil |
46 | } | 46 | } |
47 | 47 | ||
48 | + var companyMap = make(map[int64]*domain.Company) | ||
48 | var userMap = make(map[int64]*domain.User) | 49 | var userMap = make(map[int64]*domain.User) |
49 | var articleMap = make(map[int64]*domain.Article) | 50 | var articleMap = make(map[int64]*domain.Article) |
50 | var commentMap = make(map[int64]*domain.ArticleComment) | 51 | var commentMap = make(map[int64]*domain.ArticleComment) |
51 | 52 | ||
52 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { | 53 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { |
53 | var ( | 54 | var ( |
55 | + company *domain.Company | ||
54 | user *domain.User | 56 | user *domain.User |
55 | article *domain.Article | 57 | article *domain.Article |
56 | comment *domain.ArticleComment | 58 | comment *domain.ArticleComment |
57 | ) | 59 | ) |
58 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.UserId, l.svcCtx.UserRepository.FindOne) | 60 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.UserId, l.svcCtx.UserRepository.FindOne) |
61 | + if user != nil { | ||
62 | + company, _ = domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne) | ||
63 | + } | ||
59 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) | 64 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) |
60 | // 点赞评论 | 65 | // 点赞评论 |
61 | if item.CommentId != 0 { | 66 | if item.CommentId != 0 { |
62 | comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne) | 67 | comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne) |
63 | } | 68 | } |
64 | 69 | ||
65 | - resp.List = append(resp.List, l.NewItemSimple(item, user, article, comment)) | 70 | + resp.List = append(resp.List, l.NewItemSimple(item, company, user, article, comment)) |
66 | }) | 71 | }) |
67 | 72 | ||
68 | return resp, nil | 73 | return resp, nil |
69 | } | 74 | } |
70 | 75 | ||
71 | -func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem { | 76 | +func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem { |
72 | item := types.MyBeLikedItem{ | 77 | item := types.MyBeLikedItem{ |
73 | UserId: love.UserId, | 78 | UserId: love.UserId, |
74 | ArticleId: love.ArticleId, | 79 | ArticleId: love.ArticleId, |
@@ -84,6 +89,9 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, user *doma | @@ -84,6 +89,9 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, user *doma | ||
84 | Avatar: user.Avatar, | 89 | Avatar: user.Avatar, |
85 | Position: user.Position, | 90 | Position: user.Position, |
86 | } | 91 | } |
92 | + if company != nil { | ||
93 | + item.User.CompanyName = company.Name | ||
94 | + } | ||
87 | } | 95 | } |
88 | 96 | ||
89 | if article != nil { | 97 | if article != nil { |
@@ -45,30 +45,35 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | @@ -45,30 +45,35 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | ||
45 | return resp, nil | 45 | return resp, nil |
46 | } | 46 | } |
47 | 47 | ||
48 | + var companyMap = make(map[int64]*domain.Company) | ||
48 | var userMap = make(map[int64]*domain.User) | 49 | var userMap = make(map[int64]*domain.User) |
49 | var articleMap = make(map[int64]*domain.Article) | 50 | var articleMap = make(map[int64]*domain.Article) |
50 | var commentMap = make(map[int64]*domain.ArticleComment) | 51 | var commentMap = make(map[int64]*domain.ArticleComment) |
51 | 52 | ||
52 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { | 53 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { |
53 | var ( | 54 | var ( |
55 | + company *domain.Company | ||
54 | user *domain.User | 56 | user *domain.User |
55 | article *domain.Article | 57 | article *domain.Article |
56 | comment *domain.ArticleComment | 58 | comment *domain.ArticleComment |
57 | ) | 59 | ) |
58 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ToUserId, l.svcCtx.UserRepository.FindOne) | 60 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ToUserId, l.svcCtx.UserRepository.FindOne) |
61 | + if user != nil { | ||
62 | + company, _ = domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne) | ||
63 | + } | ||
59 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) | 64 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) |
60 | // 点赞评论 | 65 | // 点赞评论 |
61 | if item.CommentId != 0 { | 66 | if item.CommentId != 0 { |
62 | comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne) | 67 | comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne) |
63 | } | 68 | } |
64 | 69 | ||
65 | - resp.List = append(resp.List, l.NewItemSimple(item, user, article, comment)) | 70 | + resp.List = append(resp.List, l.NewItemSimple(item, company, user, article, comment)) |
66 | }) | 71 | }) |
67 | 72 | ||
68 | return resp, nil | 73 | return resp, nil |
69 | } | 74 | } |
70 | 75 | ||
71 | -func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem { | 76 | +func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem { |
72 | item := types.MyLikeItem{ | 77 | item := types.MyLikeItem{ |
73 | UserId: love.ToUserId, | 78 | UserId: love.ToUserId, |
74 | ArticleId: love.ArticleId, | 79 | ArticleId: love.ArticleId, |
@@ -84,6 +89,9 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain. | @@ -84,6 +89,9 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain. | ||
84 | Avatar: user.Avatar, | 89 | Avatar: user.Avatar, |
85 | Position: user.Position, | 90 | Position: user.Position, |
86 | } | 91 | } |
92 | + if company != nil { | ||
93 | + item.User.CompanyName = company.Name | ||
94 | + } | ||
87 | } | 95 | } |
88 | 96 | ||
89 | if article != nil { | 97 | if article != nil { |
-
请 注册 或 登录 后发表评论