正在显示
6 个修改的文件
包含
26 行增加
和
4 行删除
| @@ -251,6 +251,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ | @@ -251,6 +251,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ | ||
| 251 | CommentAuthor: 0, | 251 | CommentAuthor: 0, |
| 252 | UserId: req.UserId, | 252 | UserId: req.UserId, |
| 253 | ToUserId: articleInfo.AuthorId, | 253 | ToUserId: articleInfo.AuthorId, |
| 254 | + CompanyId: userInfo.CompanyId, | ||
| 254 | } | 255 | } |
| 255 | // 添加点赞标识 | 256 | // 添加点赞标识 |
| 256 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) | 257 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) |
| @@ -341,6 +342,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ | @@ -341,6 +342,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ | ||
| 341 | CommentAuthor: commentInfo.FromUserId, | 342 | CommentAuthor: commentInfo.FromUserId, |
| 342 | UserId: req.UserId, | 343 | UserId: req.UserId, |
| 343 | ToUserId: commentInfo.FromUserId, | 344 | ToUserId: commentInfo.FromUserId, |
| 345 | + CompanyId: userInfo.CompanyId, | ||
| 344 | } | 346 | } |
| 345 | // 设置赞标识 | 347 | // 设置赞标识 |
| 346 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) | 348 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) |
| @@ -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 { |
| @@ -17,6 +17,7 @@ type UserLoveFlag struct { | @@ -17,6 +17,7 @@ type UserLoveFlag struct { | ||
| 17 | CommentAuthor int64 // 评论的填写人 | 17 | CommentAuthor int64 // 评论的填写人 |
| 18 | UserId int64 | 18 | UserId int64 |
| 19 | ToUserId int64 | 19 | ToUserId int64 |
| 20 | + CompanyId int64 | ||
| 20 | CreatedAt int64 | 21 | CreatedAt int64 |
| 21 | UpdatedAt int64 | 22 | UpdatedAt int64 |
| 22 | DeletedAt int64 | 23 | DeletedAt int64 |
| @@ -164,6 +164,7 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo | @@ -164,6 +164,7 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo | ||
| 164 | CommentId: from.CommentId, | 164 | CommentId: from.CommentId, |
| 165 | UserId: from.UserId, | 165 | UserId: from.UserId, |
| 166 | ToUserId: from.ToUserId, | 166 | ToUserId: from.ToUserId, |
| 167 | + CompanyId: from.CompanyId, | ||
| 167 | CreatedAt: from.CreatedAt, | 168 | CreatedAt: from.CreatedAt, |
| 168 | UpdatedAt: from.UpdatedAt, | 169 | UpdatedAt: from.UpdatedAt, |
| 169 | DeletedAt: from.DeletedAt, | 170 | DeletedAt: from.DeletedAt, |
| @@ -182,6 +183,7 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo | @@ -182,6 +183,7 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo | ||
| 182 | CommentAuthor: from.CommentAuthor, | 183 | CommentAuthor: from.CommentAuthor, |
| 183 | UserId: from.UserId, | 184 | UserId: from.UserId, |
| 184 | ToUserId: from.ToUserId, | 185 | ToUserId: from.ToUserId, |
| 186 | + CompanyId: from.CompanyId, | ||
| 185 | CreatedAt: from.CreatedAt, | 187 | CreatedAt: from.CreatedAt, |
| 186 | UpdatedAt: from.UpdatedAt, | 188 | UpdatedAt: from.UpdatedAt, |
| 187 | DeletedAt: from.DeletedAt, | 189 | DeletedAt: from.DeletedAt, |
| @@ -16,6 +16,7 @@ type UserLoveFlag struct { | @@ -16,6 +16,7 @@ type UserLoveFlag struct { | ||
| 16 | CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人 | 16 | CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人 |
| 17 | ToUserId int64 `json:"toUserId"` // 点赞的接受人 | 17 | ToUserId int64 `json:"toUserId"` // 点赞的接受人 |
| 18 | UserId int64 `json:"userId"` // 点赞的人 | 18 | UserId int64 `json:"userId"` // 点赞的人 |
| 19 | + CompanyId int64 `json:"companyId"` // | ||
| 19 | CreatedAt int64 `json:"createdAt,omitempty"` | 20 | CreatedAt int64 `json:"createdAt,omitempty"` |
| 20 | UpdatedAt int64 `json:"updatedAt,omitempty"` | 21 | UpdatedAt int64 `json:"updatedAt,omitempty"` |
| 21 | DeletedAt int64 `json:"deletedAt,omitempty"` | 22 | DeletedAt int64 `json:"deletedAt,omitempty"` |
-
请 注册 或 登录 后发表评论