作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -154,7 +154,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
WhoRead: whoRead,
WhoReview: whoReview,
Location: domain.Location{
Longitude: req.Location.Latitude,
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
},
... ...
... ... @@ -251,6 +251,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
CommentAuthor: 0,
UserId: req.UserId,
ToUserId: articleInfo.AuthorId,
CompanyId: userInfo.CompanyId,
}
// 添加点赞标识
_, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo)
... ... @@ -341,6 +342,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
CommentAuthor: commentInfo.FromUserId,
UserId: req.UserId,
ToUserId: commentInfo.FromUserId,
CompanyId: userInfo.CompanyId,
}
// 设置赞标识
_, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo)
... ...
... ... @@ -197,7 +197,11 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
// 创建回复消息
var atAllIds = make([]int64, 0)
atAllIds = append(atAllIds, newComment.ToUserId)
if pComment != nil {
atAllIds = append(atAllIds, newComment.ToUserId)
} else {
atAllIds = append(atAllIds, articleInfo.AuthorId)
}
atAllIds = append(atAllIds, atWhoIds...)
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
if pComment != nil {
... ...
... ... @@ -45,30 +45,35 @@ func (l *MiniMyBeLikedLogic) MiniMyBeLiked(req *types.MiniBeLikedRequest) (resp
return resp, nil
}
var companyMap = make(map[int64]*domain.Company)
var userMap = make(map[int64]*domain.User)
var articleMap = make(map[int64]*domain.Article)
var commentMap = make(map[int64]*domain.ArticleComment)
lo.ForEach(list, func(item *domain.UserLoveFlag, index int) {
var (
company *domain.Company
user *domain.User
article *domain.Article
comment *domain.ArticleComment
)
user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.UserId, l.svcCtx.UserRepository.FindOne)
if user != nil {
company, _ = domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne)
}
article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne)
// 点赞评论
if item.CommentId != 0 {
comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne)
}
resp.List = append(resp.List, l.NewItemSimple(item, user, article, comment))
resp.List = append(resp.List, l.NewItemSimple(item, company, user, article, comment))
})
return resp, nil
}
func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem {
func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem {
item := types.MyBeLikedItem{
UserId: love.UserId,
ArticleId: love.ArticleId,
... ... @@ -84,6 +89,9 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, user *doma
Avatar: user.Avatar,
Position: user.Position,
}
if company != nil {
item.User.CompanyName = company.Name
}
}
if article != nil {
... ...
... ... @@ -45,30 +45,35 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types.
return resp, nil
}
var companyMap = make(map[int64]*domain.Company)
var userMap = make(map[int64]*domain.User)
var articleMap = make(map[int64]*domain.Article)
var commentMap = make(map[int64]*domain.ArticleComment)
lo.ForEach(list, func(item *domain.UserLoveFlag, index int) {
var (
company *domain.Company
user *domain.User
article *domain.Article
comment *domain.ArticleComment
)
user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ToUserId, l.svcCtx.UserRepository.FindOne)
if user != nil {
company, _ = domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne)
}
article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne)
// 点赞评论
if item.CommentId != 0 {
comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne)
}
resp.List = append(resp.List, l.NewItemSimple(item, user, article, comment))
resp.List = append(resp.List, l.NewItemSimple(item, company, user, article, comment))
})
return resp, nil
}
func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem {
func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem {
item := types.MyLikeItem{
UserId: love.ToUserId,
ArticleId: love.ArticleId,
... ... @@ -84,6 +89,9 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, user *domain.
Avatar: user.Avatar,
Position: user.Position,
}
if company != nil {
item.User.CompanyName = company.Name
}
}
if article != nil {
... ...
... ... @@ -17,6 +17,7 @@ type UserLoveFlag struct {
CommentAuthor int64 // 评论的填写人
UserId int64
ToUserId int64
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
... ...
... ... @@ -164,6 +164,7 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo
CommentId: from.CommentId,
UserId: from.UserId,
ToUserId: from.ToUserId,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
... ... @@ -182,6 +183,7 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo
CommentAuthor: from.CommentAuthor,
UserId: from.UserId,
ToUserId: from.ToUserId,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
... ...
... ... @@ -16,6 +16,7 @@ type UserLoveFlag struct {
CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人
ToUserId int64 `json:"toUserId"` // 点赞的接受人
UserId int64 `json:"userId"` // 点赞的人
CompanyId int64 `json:"companyId"` //
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
... ...