作者 yangfu
正在显示 41 个修改的文件 包含 199 行增加27 行删除
... ... @@ -49,6 +49,7 @@ type (
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other,optional"`
SortBy int `json:"sortBy,optional"` //排序
}
TagCreateResponse {
... ... @@ -66,6 +67,7 @@ type (
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other,optional"`
SortBy int `json:"sortBy,optional"` // 排序
}
TagEditResponse {
... ... @@ -86,6 +88,7 @@ type (
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
Other string `json:"other"`
SortBy int `json:"sortBy,optional"` // 排序
}
)
... ... @@ -110,6 +113,7 @@ type (
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
SortBy int `json:"sortBy,optional"` // 排序
}
)
... ...
... ... @@ -26,6 +26,7 @@ type (
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
Location Location `json:"location,optional"` //定位坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
MiniArticleCreateResponse {
Id int64 `json:"id"`
... ... @@ -58,6 +59,7 @@ type (
MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
MeFollowFlag int `json:"meFollowFlag"` // 当前人员对作者的关注标识 (0 没有关注 1有关注)
Tags []string `json:"tags"` // 文章的标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
ArticleSection {
Id int64 `json:"id"` //段落id
... ... @@ -189,6 +191,7 @@ type (
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
MiniArticleDraftCreateResponse {
... ... @@ -209,6 +212,7 @@ type (
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
MiniArticleDraftUpdateResponse {
... ... @@ -235,7 +239,8 @@ type (
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`
CreatedAt int64 `json:"createdAt"`//
MatchUrl map[string]string `json:"matchUrl"` //匹配内容中的url文本
}
)
... ... @@ -256,6 +261,7 @@ type (
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` //
}
)
... ... @@ -325,6 +331,7 @@ type (
Category string `json:"category"`
Name string `json:"name"`
Image string `json:"image"`
SortBy int `json:"sortBy"`
}
)
... ... @@ -496,6 +503,7 @@ type (
TagRemark string `json:"tagRemark"` // 标签备注
TotalArticle int `json:"totalArticle"` // 总的文章数量
ReadArticle int `json:"readArticle"` // 已读的标签数量
SortBy int `json:"sortBy"` // 排序
}
)
... ...
... ... @@ -90,9 +90,10 @@ type (
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
CompanyId int64 `json:",optional"` // 服务端自动获取
Pid int64 `json:"pid"` // 回复那个评论的id
Pid int64 `json:"pid,optional"` // 回复那个评论的id
Content string `json:"content"` // 评论的内容
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
AtWho []CommentAtWho `json:"atWho,optional"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl,optional"` // 评论内容中的url文本
}
CommentAtWho {
... ... @@ -115,6 +116,7 @@ type (
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CreatedAt int64 `json:"createdAt"` //
}
)
... ... @@ -155,6 +157,7 @@ type (
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CreatedAt int64 `json:"createdAt"` //
MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
Content string `json:"content"` // 评论的内容
... ... @@ -253,6 +256,8 @@ type (
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
CreatedAt int64 `json:"createdAt"` // 评论时间
Content string `json:"content"` // 评论的内容
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
Show int `json:"show"` // 显示状态
}
)
... ...
... ... @@ -42,6 +42,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
Category: val.Category,
Name: val.Name,
Image: val.Image.Url,
SortBy: int(val.SortBy),
})
tagMap[val.Category] = m
} else {
... ... @@ -52,6 +53,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
Category: val.Category,
Name: val.Name,
Image: val.Image.Url,
SortBy: int(val.SortBy),
},
}
}
... ...
... ... @@ -50,8 +50,19 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
if err != nil {
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
}
author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, articleData.AuthorId)
company, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
if len(markRecord) > 0 {
markRecord[0].Author = articleData.Author
if author != nil {
markRecord[0].Author = domain.UserSimple{
Id: author.Id,
Name: author.Name,
Avatar: author.Avatar,
Position: author.Position,
Company: company.Name,
CompanyId: company.Id,
}
}
markRecord[0].Title = articleData.Title
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
if err != nil {
... ... @@ -61,14 +72,6 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
return resp, nil
}
// 新建一个标记
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
}
if articleInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("标记浏览记录失败")
}
newMark := domain.UserReadArticle{
Id: 0,
CompanyId: req.CompanyId,
... ... @@ -81,13 +84,23 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
DeletedAt: 0,
Version: 0,
}
if author != nil {
newMark.Author = domain.UserSimple{
Id: author.Id,
Name: author.Name,
Avatar: author.Avatar,
Position: author.Position,
Company: company.Name,
CompanyId: company.Id,
}
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.UserReadArticleRepository.Insert(ctx, c, &newMark)
if err != nil {
return err
}
//增加浏览计数
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo.Id)
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleData.Id)
return err
}, true)
if err != nil {
... ...
... ... @@ -53,6 +53,7 @@ func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArti
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
},
MatchUrl: map[string]string{},
}
for _, val := range req.Images {
newDraft.Images = append(newDraft.Images, domain.Image{
... ... @@ -60,6 +61,10 @@ func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArti
})
}
for k, v := range req.MatchUrl {
newDraft.MatchUrl[k] = v
}
_, err = l.svcCtx.ArticleDraftRepository.Insert(l.ctx, conn, &newDraft)
if err != nil {
return nil, xerr.NewErrMsgErr("保存草稿失败", err)
... ...
... ... @@ -164,10 +164,14 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
CountRead: 0,
Show: domain.ArticleShowEnable,
Tags: []int64{},
MatchUrl: map[string]string{},
}
if len(whoRead) > 0 {
newArticle.TargetUser = domain.ArticleTargetLimit
}
for k, v := range req.MatchUrl {
newArticle.MatchUrl[k] = v
}
//设置内容概要
if len(sectionList) > 0 {
// 截取内容 50个字
... ...
... ... @@ -50,6 +50,10 @@ func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticl
Latitude: draftInfo.Location.Latitude,
Descript: draftInfo.Location.Descript,
},
MatchUrl: map[string]string{},
}
for k, v := range draftInfo.MatchUrl {
resp.MatchUrl[k] = v
}
for _, val := range draftInfo.Images {
resp.Images = append(resp.Images, val.Url)
... ...
... ... @@ -122,10 +122,15 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
MeLoveFlag: meLoveFlag,
MeFollowFlag: 0,
Tags: tags,
MatchUrl: map[string]string{},
}
if articleInfo.CreatedAt != articleInfo.UpdatedAt {
resp.Edit = 1
}
for k, v := range articleInfo.MatchUrl {
resp.MatchUrl[k] = v
}
for _, val := range articleInfo.Images {
resp.Images = append(resp.Images, val.Url)
}
... ...
... ... @@ -54,6 +54,7 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
Title: draftList[i].Title,
Images: images,
CreatedAt: draftList[i].CreatedAt,
MatchUrl: draftList[i].MatchUrl,
}
}
return resp, nil
... ...
... ... @@ -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)
... ...
... ... @@ -56,6 +56,7 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest)
TagRemark: val.Remark,
TotalArticle: 0,
ReadArticle: 0,
SortBy: int(val.SortBy),
}
if count, ok := countDataMap[val.Id]; ok {
m.TotalArticle = count.TotalArticle
... ...
... ... @@ -58,6 +58,10 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti
Url: val,
})
}
draftInfo.MatchUrl = make(map[string]string)
for k, v := range req.MatchUrl {
draftInfo.MatchUrl[k] = v
}
_, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo)
if err != nil {
return nil, xerr.NewErrMsgErr("更新草稿失败", err)
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
... ... @@ -42,6 +43,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
article.Version = article.Version + 1
article.Images = backup.Images
article.Title = backup.Title
article.MatchUrl = backup.MatchUrl
articleSections := make([]domain.ArticleSection, 0)
lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) {
articleSections = append(articleSections, domain.ArticleSection{
... ...
... ... @@ -132,6 +132,11 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
CountAdminLove: 0,
Show: domain.CommentShowEnable,
AtWho: []domain.UserSimple{},
MatchUrl: map[string]string{},
}
for k, v := range req.MatchUrl {
newComment.MatchUrl[k] = v
}
if selctionInfo != nil {
... ... @@ -238,6 +243,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
CountUserLove: 0,
CountAdminLove: 0,
AtWho: []types.CommentAtWho{},
MatchUrl: newComment.MatchUrl,
CreatedAt: newComment.CreatedAt,
}
... ...
... ... @@ -89,12 +89,17 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt
CountUserLove: commentInfo.CountUserLove,
CountAdminLove: commentInfo.CountAdminLove,
AtWho: []types.CommentAtWho{},
MatchUrl: map[string]string{},
CreatedAt: commentInfo.CreatedAt,
MeLoveFlag: 0,
Content: commentInfo.Content,
}
if _, ok := flagMap[commentInfo.Id]; ok {
commentResp.MeLoveFlag = 1
}
for k, v := range commentInfo.MatchUrl {
commentResp.MatchUrl[k] = v
}
for _, val := range commentInfo.AtWho {
commentResp.AtWho = append(commentResp.AtWho, types.CommentAtWho{
Id: val.Id,
... ... @@ -131,12 +136,16 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
MatchUrl: map[string]string{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
}
if _, ok := flagMap[val.Id]; ok {
reply.MeLoveFlag = 1
}
for key, url := range val.MatchUrl {
reply.MatchUrl[key] = url
}
for _, val2 := range val.AtWho {
reply.AtWho = append(reply.AtWho, types.CommentAtWho{
Id: val2.Id,
... ...
... ... @@ -37,10 +37,12 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
WithOffsetLimit(req.Page, req.Size).
MustWithKV("topId", 0).
MustWithKV("articleId", req.ArticleId).
MustWithKV("sectionId", req.SectionId).
MustWithKV("show", domain.CommentShowEnable).
MustWithKV("show", int(domain.CommentShowEnable)).
MustWithKV("companyId", req.CompanyId)
if req.SectionId > 0 {
//专门获取段落评论
queryOption.MustWithKV("sectionId", req.SectionId)
}
cnt, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
... ... @@ -100,6 +102,7 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
MatchUrl: map[string]string{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
Content: val.Content,
... ... @@ -111,7 +114,9 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
if _, ok := flagMap[val.Id]; ok {
item.Comment.MeLoveFlag = 1
}
for key2, val2 := range val.MatchUrl {
item.Comment.MatchUrl[key2] = val2
}
for _, val2 := range val.AtWho {
item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{
Id: val2.Id,
... ... @@ -174,6 +179,7 @@ func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlag
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
MatchUrl: map[string]string{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
Content: val.Content,
... ... @@ -182,6 +188,9 @@ func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlag
if _, ok := loveFlagMap[val.Id]; ok {
item.MeLoveFlag = 1
}
for key2, val2 := range val.MatchUrl {
item.MatchUrl[key2] = val2
}
for _, val2 := range val.AtWho {
item.AtWho = append(item.AtWho, types.CommentAtWho{
Id: val2.Id,
... ...
... ... @@ -56,6 +56,9 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5
if _, ok := flagMap[val.Id]; ok {
item.MeLoveFlag = 1
}
for key, url := range val.MatchUrl {
item.MatchUrl[key] = url
}
for _, val2 := range val.AtWho {
item.AtWho = append(item.AtWho, types.CommentAtWho{
Id: val2.Id,
... ... @@ -95,6 +98,7 @@ func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
MatchUrl: map[string]string{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
Content: val.Content,
... ...
... ... @@ -56,6 +56,11 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
SortBy: int64(req.SortBy),
}
err = newTag.SetCategory(req.Category)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
}
if len(req.Image) > 0 {
//获取图片的尺寸大小
... ...
... ... @@ -70,6 +70,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
oldTag.Name = req.Name
oldTag.Remark = req.Remark
oldTag.Other = req.Other
oldTag.SortBy = int64(req.SortBy)
err = oldTag.SetCategory(req.Category)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
}
oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
... ...
... ... @@ -41,6 +41,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
Category: oldTag.Category,
Remark: oldTag.Remark,
Other: oldTag.Other,
SortBy: int(oldTag.SortBy),
}
return
}
... ...
... ... @@ -53,6 +53,7 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
Category: tagList[i].Category,
Remark: tagList[i].Remark,
CreatedAt: tagList[i].CreatedAt,
SortBy: int(tagList[i].SortBy),
}
}
return resp, 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 {
... ...
... ... @@ -21,9 +21,10 @@ type MiniCreateArticleCommentRequest struct {
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
CompanyId int64 `json:",optional"` // 服务端自动获取
Pid int64 `json:"pid"` // 回复那个评论的id
Pid int64 `json:"pid,optional"` // 回复那个评论的id
Content string `json:"content"` // 评论的内容
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
AtWho []CommentAtWho `json:"atWho,optional"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl,optional"` // 评论内容中的url文本
}
type CommentAtWho struct {
... ... @@ -47,6 +48,7 @@ type MiniCreateArticleCommentResponse struct {
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CreatedAt int64 `json:"createdAt"` //
}
... ... @@ -85,6 +87,7 @@ type ArticleCommentItem struct {
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CreatedAt int64 `json:"createdAt"` //
MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
Content string `json:"content"` // 评论的内容
... ... @@ -172,6 +175,8 @@ type SystemArticleCommentSearchItem struct {
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
CreatedAt int64 `json:"createdAt"` // 评论时间
Content string `json:"content"` // 评论的内容
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
Show int `json:"show"` // 显示状态
}
... ... @@ -318,6 +323,7 @@ type TagCreateRequest struct {
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other,optional"`
SortBy int `json:"sortBy,optional"` //排序
}
type TagCreateResponse struct {
... ... @@ -332,6 +338,7 @@ type TagEditRequest struct {
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other,optional"`
SortBy int `json:"sortBy,optional"` // 排序
}
type TagEditResponse struct {
... ... @@ -350,6 +357,7 @@ type TagGetResponse struct {
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
Other string `json:"other"`
SortBy int `json:"sortBy,optional"` // 排序
}
type TagListRequest struct {
... ... @@ -373,6 +381,7 @@ type TagItem struct {
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
SortBy int `json:"sortBy,optional"` // 排序
}
type TagDeleteRequest struct {
... ... @@ -799,6 +808,7 @@ type MiniArticleCreateRequest struct {
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
Location Location `json:"location,optional"` //定位坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type MiniArticleCreateResponse struct {
... ... @@ -830,6 +840,7 @@ type MiniArticleGetResponse struct {
MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
MeFollowFlag int `json:"meFollowFlag"` // 当前人员对作者的关注标识 (0 没有关注 1有关注)
Tags []string `json:"tags"` // 文章的标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type ArticleSection struct {
... ... @@ -950,6 +961,7 @@ type MiniArticleDraftCreateRequest struct {
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type MiniArticleDraftCreateResponse struct {
... ... @@ -967,6 +979,7 @@ type MiniArticleDraftUpdateRequest struct {
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type MiniArticleDraftUpdateResponse struct {
... ... @@ -991,7 +1004,8 @@ type MiniArticleDraftItem struct {
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`
CreatedAt int64 `json:"createdAt"` //
MatchUrl map[string]string `json:"matchUrl"` //匹配内容中的url文本
}
type MiniArticleDraftGetMeRequest struct {
... ... @@ -1009,6 +1023,7 @@ type MiniArticleDraftGetMeResponse struct {
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` //
}
type MiniArticleDraftDeleteMeRequest struct {
... ... @@ -1071,6 +1086,7 @@ type ArticleTagItem struct {
Category string `json:"category"`
Name string `json:"name"`
Image string `json:"image"`
SortBy int `json:"sortBy"`
}
type SystemArticleGetRequest struct {
... ... @@ -1230,6 +1246,7 @@ type ArticleTagCount struct {
TagRemark string `json:"tagRemark"` // 标签备注
TotalArticle int `json:"totalArticle"` // 总的文章数量
ReadArticle int `json:"readArticle"` // 已读的标签数量
SortBy int `json:"sortBy"` // 排序
}
type MiniSearchArticleRequest struct {
... ...
... ... @@ -31,6 +31,7 @@ type Article struct {
Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签
Show int // 评论的展示状态(0显示、1不显示)
Summary string // 内容概要
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
}
func (m *Article) TableName() string {
... ...
... ... @@ -28,6 +28,7 @@ type ArticleBackup struct {
Tags []int64 `gorm:"type:jsonb;serializer:json"` // 标签
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
}
func (m *ArticleBackup) TableName() string {
... ...
... ... @@ -27,11 +27,13 @@ type ArticleComment struct {
ToUserId int64 // 回复谁的评论
ToUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 回复谁的评论
AtWho []domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 填写评论@的人
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 评论内容中出现的url. 用于页面上进行匹配文本后进行特殊显示处理
Content string // 评论内容
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
CountAdminLove int // 运营点赞数量
Show int // 评论的展示状态(0显示、1不显示)
}
func (m *ArticleComment) TableName() string {
... ...
... ... @@ -25,6 +25,7 @@ type ArticleDraft struct {
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
}
func (m *ArticleDraft) TableName() string {
... ...
... ... @@ -17,6 +17,7 @@ type UserLoveFlag struct {
CommentAuthor int64 // 评论的填写人
UserId int64
ToUserId int64
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
... ...
... ... @@ -171,6 +171,7 @@ func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.Artic
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Tags: from.Tags,
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -193,9 +194,10 @@ func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.Artic
Action: from.Action,
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Location: from.Location,
Tags: from.Tags,
Location: from.Location,
TargetUser: int(from.TargetUser),
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -199,6 +199,7 @@ func (repository *ArticleCommentRepository) ModelToDomainModel(from *models.Arti
CountAdminLove: from.CountAdminLove,
Show: domain.CommentShow(from.Show),
AtWho: from.AtWho,
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -228,6 +229,7 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti
CountUserLove: from.CountUserLove,
CountAdminLove: from.CountAdminLove,
Show: int(from.Show),
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -156,6 +156,7 @@ func (repository *ArticleDraftRepository) ModelToDomainModel(from *models.Articl
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Location: from.Location,
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -177,6 +178,7 @@ func (repository *ArticleDraftRepository) DomainModelToModel(from *domain.Articl
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Location: from.Location,
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -304,6 +304,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*
Show: domain.ArticleShow(from.Show),
Tags: from.Tags,
Summary: from.Summary,
MatchUrl: from.MatchUrl,
}
return to, nil
}
... ... @@ -328,9 +329,10 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*
CountLove: from.CountLove,
CountRead: from.CountRead,
CountComment: from.CountComment,
Show: int(from.Show),
Tags: from.Tags,
Show: int(from.Show),
Summary: from.Summary,
MatchUrl: from.MatchUrl,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -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,
... ...
... ... @@ -28,6 +28,7 @@ type Article struct {
Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)
Tags []int64 `json:"tags"` // 定性标签
Summary string `json:"summary"` // 内容概要
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
// ...more
}
... ... @@ -110,6 +111,11 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art
WhoRead: m.WhoRead,
WhoReview: m.WhoReview,
Tags: m.Tags,
MatchUrl: map[string]string{},
}
for k, v := range m.MatchUrl {
b.MatchUrl[k] = v
}
return &b
}
... ...
... ... @@ -25,6 +25,7 @@ type ArticleBackup struct {
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Tags []int64 `json:"tags"` // 标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type ArticleBackupRepository interface {
... ...
... ... @@ -28,7 +28,8 @@ type ArticleComment struct {
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
Show CommentShow `json:"showState"` // 评论的展示状态(1显示、2不显示)
AtWho []UserSimple `json:"atWho"` // 填写评论时@的人
AtWho []UserSimple `json:"atWho"` // 填写评论时@的人. 评论内容中出现的@人,用于页面上进行匹配文本后进行特殊显示处理
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中出现的url. 用于页面上进行匹配文本后进行特殊显示处理
// ...more
}
... ...
... ... @@ -23,6 +23,7 @@ type ArticleDraft struct {
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type ArticleDraftRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
... ...
... ... @@ -2,6 +2,7 @@ package domain
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
... ... @@ -22,6 +23,7 @@ type ArticleTag struct {
SortBy int64 `json:"sortBy"` // 顺序
Other string `json:"other"` //
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
CreateInBatches(ctx context.Context, conn transaction.Conn, dm []*ArticleTag) error
... ... @@ -31,3 +33,14 @@ type ArticleTagRepository interface {
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTag, error)
Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*ArticleTag, error)
}
func (m *ArticleTag) SetCategory(str string) error {
var err error
switch str {
case "紧急重要", "机会风险":
m.Category = str
default:
err = fmt.Errorf("ArticleTag.Category error")
}
return err
}
... ...
... ... @@ -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"`
... ...