作者 郑周

Merge remote-tracking branch 'origin/dev' into dev

... ... @@ -7,6 +7,15 @@ type Location {
Descript string `json:"descript,optional"` //地点描述
}
type Video {
Url string `json:"url"` //视频文件的地址
Cover string `json:"cover"` //封面
Width int `json:"width"` //封面图片宽
Height int `json:"height"` //封面图片长
}
// 人员的简单展示信息
type ArticleAuthor {
Id int64 `json:"id"` // 人员id
... ... @@ -48,6 +57,7 @@ type (
CreatedAt int64 `json:"createdAt"` //文章的发布时间
Section []ArticleSection `json:"section"` //文章的文本内容
Images []string `json:"images"` //图片
Videos []Video `json:"videos"` //视频
WhoRead []int64 `json:"whoRead"` //谁可查看
WhoReview []int64 `json:"whoReview"` //谁可评论
Location Location `json:"location"` //定位坐标
... ... @@ -355,6 +365,7 @@ type (
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
... ... @@ -389,12 +400,12 @@ type (
SystemArticleSearch {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"author"` //发布人ID
AuthorId int64 `json:"authorId"` //发布人ID
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
... ... @@ -410,6 +421,7 @@ type (
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
Videos []Video `json:"video"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
... ... @@ -423,6 +435,7 @@ type (
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
Videos []Video `json:"video"` // 视频
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []int64 `json:"tags"` //标签
... ... @@ -464,6 +477,7 @@ type (
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
Videos []Video `json:"video"`
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
... ... @@ -530,6 +544,7 @@ type (
MiniSearchArticleItem{
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
AuthorId int64 `json:"authorId"`
Author string `json:"author"` // 发布人
Avatar string `json:"avatar"`// 发布人的头像
Images []string `json:"images"`
... ...
... ... @@ -254,14 +254,14 @@ type (
// 文章里的评论列表
type (
SystemArticleCommentSearchRequest {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
Author int64 `json:"author,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
Author int64 `json:"author,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleCommentSearchResponse {
Total int64 `json:"total"`
... ... @@ -362,10 +362,11 @@ type (
// 管理后台变更评论
type (
SystemEditCommentRequest {
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
CountAdminLove int `json:"countAdminLove,optional"`
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
Content string `json:"content,optional"`
CountAdminLove int `json:"countAdminLove,optional"`
}
SystemEditCommentResponse {
... ...
... ... @@ -3,8 +3,10 @@ package article
import (
"context"
"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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -14,15 +16,17 @@ import (
type MiniArticleMarkListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
ctx context.Context
svcCtx *svc.ServiceContext
userCache map[int64]*domain.User
}
func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic {
return &MiniArticleMarkListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
userCache: make(map[int64]*domain.User, 0),
}
}
... ... @@ -36,10 +40,16 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
if err != nil {
return nil, err
}
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.svcCtx.DefaultDBConn(), userToken.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章信息失败", err)
}
resp = &types.MiniArticleMarkListResponse{}
resp.Total = total
resp.List = make([]types.MiniArticleMarkItem, 0)
var author domain.User
for _, item := range list {
author = l.getAuthor(l.svcCtx.DefaultDBConn(), item.Author.Id)
to := types.MiniArticleMarkItem{
Id: item.Id,
CompanyId: item.CompanyId,
... ... @@ -48,10 +58,10 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
Author: types.SimpleUser{
Id: item.Author.Id,
CompanyId: item.Author.CompanyId,
CompanyName: item.Author.Company,
Name: item.Author.Name,
Avatar: item.Author.Avatar,
Position: item.Author.Position,
CompanyName: companyInfo.Name,
Name: author.Name,
Avatar: author.Avatar,
Position: author.Position,
},
UpdatedAt: item.UpdatedAt,
}
... ... @@ -59,3 +69,15 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
}
return resp, nil
}
func (l *MiniArticleMarkListLogic) getAuthor(conn transaction.Conn, userid int64) domain.User {
if u, ok := l.userCache[userid]; ok {
return *u
}
toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
if err == nil {
l.userCache[toUser.Id] = toUser
return *toUser
}
return domain.User{}
}
... ...
... ... @@ -41,25 +41,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
if articleInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有查看权限")
}
if len(articleInfo.WhoRead) > 0 {
inWhoRead := false
for _, val := range articleInfo.WhoRead {
if req.UserId == int(val) {
inWhoRead = true
if articleInfo.AuthorId != int64(req.UserId) {
if len(articleInfo.WhoRead) > 0 {
inWhoRead := false
for _, val := range articleInfo.WhoRead {
if req.UserId == int(val) {
inWhoRead = true
}
}
}
if !inWhoRead {
// 文章内容不显示
resp = &types.MiniArticleGetResponse{
Id: articleInfo.Id,
Title: articleInfo.Title,
Show: int(domain.ArticleShowDisable),
if !inWhoRead {
// 文章内容不显示
resp = &types.MiniArticleGetResponse{
Id: articleInfo.Id,
Title: articleInfo.Title,
Show: int(domain.ArticleShowDisable),
}
return resp, nil
}
return resp, nil
}
}
if articleInfo.Show == domain.ArticleShowDisable {
// 文章内容不显示
resp = &types.MiniArticleGetResponse{
... ... @@ -80,7 +80,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
}
//获取作者信息
author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(req.UserId))
author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(articleInfo.AuthorId))
var meLoveFlag int
if req.UserId > 0 {
... ... @@ -152,6 +152,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
MeFollowFlag: 0,
Tags: tags,
MatchUrl: map[string]string{},
Videos: []types.Video{},
}
if len(backupList) > 0 {
resp.Edit = 1
... ... @@ -171,6 +172,16 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
for _, val := range articleInfo.Images {
resp.Images = append(resp.Images, val.Url)
}
for _, val := range articleInfo.Videos {
resp.Videos = append(resp.Videos, types.Video{
Url: val.Url,
Cover: val.Cover,
Width: val.Width,
Height: val.Height,
})
}
if follow != nil {
resp.MeFollowFlag = 1
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
... ... @@ -13,15 +14,17 @@ import (
type MiniSearchArticlePageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
ctx context.Context
svcCtx *svc.ServiceContext
userCache map[int64]*domain.User
}
func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic {
return &MiniSearchArticlePageLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
userCache: make(map[int64]*domain.User),
}
}
... ... @@ -63,11 +66,13 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
}
for i, val := range articleList {
author := l.getAuthor(conn, val.AuthorId)
item := types.MiniSearchArticleItem{
ArticleId: val.Id,
Title: val.Title,
Author: val.Author.Name,
Avatar: val.Author.Avatar,
AuthorId: val.AuthorId,
Author: author.Name,
Avatar: author.Avatar,
Images: []string{},
CreatedAt: val.CreatedAt,
MeReadFlag: 0,
... ... @@ -84,3 +89,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
return resp, nil
}
func (l *MiniSearchArticlePageLogic) getAuthor(conn transaction.Conn, userid int64) domain.User {
if u, ok := l.userCache[userid]; ok {
return *u
}
toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
if err == nil {
l.userCache[toUser.Id] = toUser
return *toUser
}
return domain.User{}
}
... ...
... ... @@ -52,7 +52,9 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System
},
TargetUser: int(backup.TargetUser),
Tags: backup.Tags,
Videos: make([]types.Video, 0),
}
//文章段落内容
lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) {
resp.Section = append(resp.Section, types.ArticleSection{
... ... @@ -66,6 +68,16 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System
lo.ForEach(backup.Images, func(item domain.Image, index int) {
resp.Images = append(resp.Images, item.Url)
})
// 视频
for _, val := range backup.Videos {
resp.Videos = append(resp.Videos, types.Video{
Url: val.Url,
Cover: val.Cover,
Width: val.Width,
Height: val.Height,
})
}
//用户
userIds := lo.Union(resp.WhoRead, resp.WhoReview)
if len(userIds) > 0 {
... ...
... ... @@ -62,6 +62,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
article.Version = article.Version + 1
article.Images = backup.Images
article.Videos = backup.Videos
article.Title = backup.Title
article.MatchUrl = backup.MatchUrl
articleSections := make([]domain.ArticleSection, 0)
... ...
... ... @@ -66,6 +66,16 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
Show: int(article.Show),
Tags: make([]types.ArticleTagItem, 0),
TargetUser: int(article.TargetUser),
Videos: make([]types.Video, 0),
}
for _, val := range article.Videos {
resp.Videos = append(resp.Videos, types.Video{
Url: val.Url,
Cover: val.Cover,
Width: val.Width,
Height: val.Height,
})
}
//标签
if len(article.Tags) > 0 {
... ...
... ... @@ -31,6 +31,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
WithOffsetLimit(req.Page, req.Size).
WithKV("title", req.Title).
WithKV("authorId", req.Author).
WithKV("tags", req.Tags).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
... ... @@ -43,33 +44,47 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
}
authorIds := make([]int64, 0)
lo.ForEach(articles, func(item *domain.Article, index int) {
authorIds = append(authorIds, item.AuthorId)
})
//查询用户数据,重新赋值更新用户名称
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
//获取标签
_, tags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions())
lo.ForEach(articles, func(item *domain.Article, index int) {
//图片
images := make([]string, 0)
lo.ForEach(item.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//发布人
author := item.Author.Name
for _, user := range users {
if user.Id == item.AuthorId {
author = user.Name
}
}
//标签
articleTags := make([]string, 0)
lo.ForEach(item.Tags, func(tagId int64, index int) {
for _, t := range tags {
if t.Id == tagId {
articleTags = append(articleTags, t.Name)
}
}
})
resp.List = append(resp.List, types.SystemArticleSearch{
Id: item.Id,
Title: item.Title,
AuthorId: item.AuthorId,
Author: item.Author.Name,
Author: author,
Images: images,
CreatedAt: item.CreatedAt,
CountLove: item.CountLove,
CountComment: item.CountComment,
Show: int(item.Show),
Tags: nil,
Tags: articleTags,
TargetUser: int(item.TargetUser),
})
authorIds = append(authorIds, item.AuthorId)
})
//查询用户数据,重新赋值更新用户名称
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
lo.ForEach(resp.List, func(item types.SystemArticleSearch, index int) {
for _, user := range users {
if user.Id == item.AuthorId {
resp.List[index].Author = user.Name
}
}
})
return resp, nil
return
}
... ...
... ... @@ -90,6 +90,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
Height: h,
})
}
//检查文章可被哪些人查看
whoRead := []int64{}
if len(req.WhoRead) > 0 {
... ...
... ... @@ -37,6 +37,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
return nil, xerr.NewErrMsg("没有操作权限")
}
commetInfo.CountAdminLove = req.CountAdminLove
commetInfo.Content = req.Content
var increaseCount int
switch req.Show {
case 1:
... ... @@ -52,7 +53,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
increaseCount = -1
}
}
commetInfo.Show = domain.CommentShowEnable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
... ...
... ... @@ -49,6 +49,9 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini
return nil, xerr.NewErrMsgErr("申请失败", err)
}
if user != nil {
if user.Enable != domain.UserEnable {
return nil, xerr.NewErrMsgErr("账号不可用", err)
}
token, err = generateToken(l.svcCtx, user)
if err != nil {
return nil, xerr.NewErrMsgErr("登录失败", err)
... ...
... ... @@ -44,6 +44,8 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
)
if req.AuthorId > 0 {
users = []int64{req.AuthorId}
} else {
users = append(users, user.Id)
}
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
... ...
... ... @@ -265,10 +265,11 @@ type SystemEditCommentShowResponse struct {
}
type SystemEditCommentRequest struct {
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
CountAdminLove int `json:"countAdminLove,optional"`
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
Content string `json:"content,optional"`
CountAdminLove int `json:"countAdminLove,optional"`
}
type SystemEditCommentResponse struct {
... ... @@ -825,6 +826,13 @@ type Location struct {
Descript string `json:"descript,optional"` //地点描述
}
type Video struct {
Url string `json:"url"` //视频文件的地址
Cover string `json:"cover"` //封面
Width int `json:"width"` //封面图片宽
Height int `json:"height"` //封面图片长
}
type ArticleAuthor struct {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
... ... @@ -862,6 +870,7 @@ type MiniArticleGetResponse struct {
CreatedAt int64 `json:"createdAt"` //文章的发布时间
Section []ArticleSection `json:"section"` //文章的文本内容
Images []string `json:"images"` //图片
Videos []Video `json:"videos"` //视频
WhoRead []int64 `json:"whoRead"` //谁可查看
WhoReview []int64 `json:"whoReview"` //谁可评论
Location Location `json:"location"` //定位坐标
... ... @@ -1140,6 +1149,7 @@ type SystemArticleGetResponse struct {
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
... ... @@ -1172,12 +1182,12 @@ type SystemArticleSearchResponse struct {
type SystemArticleSearch struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"author"` //发布人ID
AuthorId int64 `json:"authorId"` //发布人ID
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
... ... @@ -1190,6 +1200,7 @@ type SystemArticleUpdateRequest struct {
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
Videos []Video `json:"video"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
... ... @@ -1204,6 +1215,7 @@ type SystemArticleUpdateResponse struct {
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
Videos []Video `json:"video"` // 视频
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []int64 `json:"tags"` //标签
... ... @@ -1237,12 +1249,13 @@ type SystemArticleGetHistoryRequest struct {
}
type SystemArticleGetHistoryResponse struct {
Id int64 `json:"id"` // id
ArticleId int64 `json:"articleId"` // 文章ID
Title string `json:"title"` // 标题
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
Id int64 `json:"id"` // id
ArticleId int64 `json:"articleId"` // 文章ID
Title string `json:"title"` // 标题
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
Videos []Video `json:"video"`
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
... ... @@ -1303,6 +1316,7 @@ type MiniSearchArticleResponse struct {
type MiniSearchArticleItem struct {
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
AuthorId int64 `json:"authorId"`
Author string `json:"author"` // 发布人
Avatar string `json:"avatar"` // 发布人的头像
Images []string `json:"images"`
... ...
... ... @@ -22,6 +22,7 @@ type ArticleBackup struct {
Title string // 标题
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频
Action string // 操作
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
... ...
... ... @@ -175,6 +175,7 @@ func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.Artic
WhoReview: from.WhoReview,
Tags: from.Tags,
MatchUrl: from.MatchUrl,
Videos: from.Videos,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -201,6 +202,7 @@ func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.Artic
Location: from.Location,
TargetUser: int(from.TargetUser),
MatchUrl: from.MatchUrl,
Videos: from.Videos,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -136,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
if v, ok := queryOptions["authorId"]; ok {
tx = tx.Where("author_id=?", v)
}
if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 {
values := make([]string, 0)
for _, item := range v.([]int64) {
values = append(values, fmt.Sprintf("%v", item))
}
tx = tx.Where("tags @> ?", "["+strings.Join(values, ",")+"]")
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ... @@ -168,7 +176,7 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).
Where("company_id=?", companyId).
Where("author_id in (?)", append(authors, whoRead)). // 包含自己的文章
Where("author_id in (?)", authors). // 包含自己的文章
Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)).
Where("show = 1")
if lastId > 0 {
... ...
... ... @@ -49,6 +49,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
... ...
... ... @@ -110,7 +110,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
ArticleId: m.Id,
Title: m.Title,
Section: sectionBackup,
Images: m.Images,
Images: make([]Image, len(m.Images)),
Videos: make([]Video, len(m.Videos)),
Action: "",
TargetUser: m.TargetUser,
WhoRead: m.WhoRead,
... ... @@ -118,7 +119,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
Tags: m.Tags,
MatchUrl: map[string]string{},
}
copy(b.Videos, m.Videos)
copy(b.Images, m.Images)
for k, v := range m.MatchUrl {
b.MatchUrl[k] = v
}
... ...
... ... @@ -19,6 +19,7 @@ type ArticleBackup struct {
Title string `json:"title"` // 标题
Section []ArticleSection `json:"section"` // 分段内容
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
Action string `json:"action"` // 操作
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
Location Location `json:"location"` // 定位坐标
... ...
... ... @@ -70,7 +70,9 @@ type ArticleCommentRepository interface {
Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleComment, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleComment, error)
IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动
IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动
... ...
... ... @@ -73,4 +73,20 @@ CREATE INDEX IF NOT EXISTS idx_message_system_company_id ON "public"."message_sy
-- 业务消息表
-- (公司ID)索引
CREATE INDEX IF NOT EXISTS idx_message_business_company_id ON "public"."message_business" USING btree(company_id);
\ No newline at end of file
CREATE INDEX IF NOT EXISTS idx_message_business_company_id ON "public"."message_business" USING btree(company_id);
-- 迁移准备
-- 修改起始的id序号
select setval('user_id_seq',10000);
select setval('department_id_seq',10000);
select setval('role_id_seq',10000);
select setval('company_id_seq',10000);
select setval('article_id_seq',100000);
select setval('article_and_tag_id_seq',100000);
select setval('article_backup_id_seq',100000);
select setval('article_comment_id_seq',100000);
select setval('article_draft_id_seq',100000);
select setval('article_section_id_seq',100000);
select setval('article_tag_id_seq',100000);
\ No newline at end of file
... ...