作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -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"` // 谁可评论
... ... @@ -374,7 +385,7 @@ type (
SystemArticleSearchRequest {
CompanyId int64 `json:"companyId,optional"`
Title string `json:"title,optional"` //标题
Author string `json:"author,optional"` //发布人
Author int64 `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Tags []int64 `json:"tags,optional"` //标签
... ... @@ -389,11 +400,12 @@ type (
SystemArticleSearch {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
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分发给指定的人]
... ... @@ -409,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分发给指定的人]
... ... @@ -422,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"` //标签
... ... @@ -463,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"` // 谁可评论
... ...
... ... @@ -258,7 +258,7 @@ type (
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
Author string `json:"author,optional"` // 用户
Author int64 `json:"author,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
... ...
... ... @@ -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
}
... ...
... ... @@ -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 {
... ...
... ... @@ -30,7 +30,8 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("title", req.Title).
WithKV("author", req.Author).
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)
... ... @@ -41,23 +42,49 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
Total: int(total),
List: make([]types.SystemArticleSearch, 0),
}
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,
Author: item.Author.Name,
AuthorId: item.AuthorId,
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),
})
})
return resp, nil
return
}
... ...
... ... @@ -2,7 +2,6 @@ package comment
import (
"context"
"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"
... ... @@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo
// 小程序端人人员删除评论
func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
if err != nil {
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
}
if commetInfo.FromUserId != req.UserId {
if commentInfo.FromUserId != req.UserId {
return nil, xerr.NewErrMsg("没有操作权限")
}
if commetInfo.Show == domain.CommentShowDisable {
if commentInfo.Show == domain.CommentShowDisable {
resp = &types.MiniDeleteArticleCommentResponse{
Id: commetInfo.Id,
Id: commentInfo.Id,
}
return resp, nil
}
commetInfo.Show = domain.CommentShowDisable
commentInfo.Show = domain.CommentShowDisable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
if err != nil {
return err
}
// 减少上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
if commentInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
if err != nil {
return err
}
}
// 减少最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
if err != nil {
return err
}
}
//减少加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
if commentInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
}
//// 评论被隐藏消息
//var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
//err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
//if err != nil {
// return err
//}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
}
resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id}
resp = &types.MiniDeleteArticleCommentResponse{Id: commentInfo.Id}
return resp, nil
}
... ...
... ... @@ -35,9 +35,11 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types.
WithKV("articleId", req.ArticleId).
WithKV("topId", req.TopId).
WithKV("show", req.Show).
WithKV("fromUserName", req.Author).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
if req.Author > 0 {
queryOptions = queryOptions.WithKV("fromUserId", req.Author)
}
total, comments, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章评论失败", err)
... ... @@ -46,6 +48,7 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types.
Total: total,
List: make([]types.SystemArticleCommentSearchItem, 0),
}
authorIds := make([]int64, 0)
lo.ForEach(comments, func(item *domain.ArticleComment, index int) {
resp.List = append(resp.List, types.SystemArticleCommentSearchItem{
Id: item.Id,
... ... @@ -68,6 +71,22 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types.
Content: item.Content,
Show: int(item.Show),
})
authorIds = append(authorIds, item.FromUserId)
})
//查询用户数据,重新赋值更新用户名称
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
lo.ForEach(resp.List, func(item types.SystemArticleCommentSearchItem, index int) {
for _, user := range users {
if user.Id == item.FromUserId {
resp.List[index].FromUser = types.CommentAuthor{
Id: user.Id,
Name: user.Name,
Avatar: user.Avatar,
Position: user.Position,
Company: item.FromUser.Company,
}
}
}
})
return
}
... ...
... ... @@ -2,6 +2,7 @@ package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -61,49 +62,57 @@ func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *type
func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error {
var conn = l.svcCtx.DefaultDBConn()
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId)
commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId)
if err != nil {
return xerr.NewErrMsgErr("删除评论信息失败", err)
}
if commetInfo.CompanyId != companyId {
if commentInfo.CompanyId != companyId {
return xerr.NewErrMsg("没有操作权限")
}
if commetInfo.Show == domain.CommentShowDisable {
if commentInfo.Show == domain.CommentShowDisable {
return nil
}
commetInfo.Show = domain.CommentShowDisable
commentInfo.Show = domain.CommentShowDisable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
if err != nil {
return err
}
// 减少上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
if commentInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
if err != nil {
return err
}
}
// 减少最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
if err != nil {
return err
}
}
//减少加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
if commentInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
}
// 评论被隐藏消息
var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
if err != nil {
return err
}
return nil
}, true)
... ...
... ... @@ -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)
... ...
... ... @@ -169,7 +169,7 @@ type SystemArticleCommentSearchRequest struct {
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
Author string `json:"author,optional"` // 用户
Author int64 `json:"author,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
... ... @@ -825,6 +825,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 +869,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 +1148,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"` // 谁可评论
... ... @@ -1156,7 +1165,7 @@ type SystemArticleGetResponse struct {
type SystemArticleSearchRequest struct {
CompanyId int64 `json:"companyId,optional"`
Title string `json:"title,optional"` //标题
Author string `json:"author,optional"` //发布人
Author int64 `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Tags []int64 `json:"tags,optional"` //标签
... ... @@ -1172,11 +1181,12 @@ type SystemArticleSearchResponse struct {
type SystemArticleSearch struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
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分发给指定的人]
... ... @@ -1189,6 +1199,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分发给指定的人]
... ... @@ -1203,6 +1214,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"` //标签
... ... @@ -1242,6 +1254,7 @@ type SystemArticleGetHistoryResponse struct {
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"` // 谁可评论
... ...
... ... @@ -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"
... ... @@ -127,9 +128,6 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
if v, ok := queryOptions["title"]; ok && v.(string) != "" {
tx = tx.Where("title like ?", "%"+v.(string)+"%")
}
if v, ok := queryOptions["author"]; ok && v.(string) != "" {
tx = tx.Where(`author #>> '{"name"}' like ?`, "%"+v.(string)+"%")
}
if v, ok := queryOptions["beginCreatedAt"]; ok {
tx = tx.Where("created_at >= ?", v)
}
... ... @@ -139,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
}
... ...
... ... @@ -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 // 评论回复数量变动
... ...
... ... @@ -74,3 +74,19 @@ 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);
-- 迁移准备
-- 修改起始的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
... ...