作者 yangfu

fix: 草稿箱修改

... ... @@ -258,7 +258,7 @@ type (
MiniArticleDraftCreateRequest {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 5、演绎式 3、归纳式 10、其他业务类型模板
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
... ... @@ -319,6 +319,7 @@ type (
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`//
MatchUrl map[string]string `json:"matchUrl"` //匹配内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
)
... ... @@ -340,6 +341,7 @@ type (
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` //
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
)
... ... @@ -681,6 +683,7 @@ type (
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
SystemArticleDraftCreateResponse {
Id int64 `json:"id"` //ID
... ... @@ -712,6 +715,7 @@ type (
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
SystemArticleDraftUpdateResponse {
Id int64 `json:"id"` //ID
... ... @@ -794,6 +798,7 @@ type (
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
)
... ...
... ... @@ -2,6 +2,9 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -37,10 +40,22 @@ func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticl
return nil, xerr.NewErrMsg("获取草稿失败")
}
}
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(draftInfo.Section, func(p *domain.ArticleSection, index int) {
paragraphs = append(paragraphs, core.NewTypesParagraph(p.ParagraphTemplate))
})
if len(paragraphs) == 0 && len(draftInfo.Content) > 0 {
lo.ForEach(draftInfo.Content, func(item string, index int) {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(item))
})
}
resp = &types.MiniArticleDraftGetMeResponse{
Id: draftInfo.Id,
Template: draftInfo.Template,
Section: draftInfo.Content,
//Section: draftInfo.Content,
Title: draftInfo.Title,
Images: []string{},
WhoRead: draftInfo.WhoRead,
... ... @@ -51,6 +66,7 @@ func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticl
Descript: draftInfo.Location.Descript,
},
MatchUrl: map[string]string{},
Paragraphs: paragraphs,
}
for k, v := range draftInfo.MatchUrl {
resp.MatchUrl[k] = v
... ...
... ... @@ -2,6 +2,8 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -45,6 +47,18 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
}
for i := range draftList {
draftInfo := draftList[i]
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(draftInfo.Section, func(p *domain.ArticleSection, index int) {
paragraphs = append(paragraphs, core.NewTypesParagraph(p.ParagraphTemplate))
})
if len(paragraphs) == 0 && len(draftInfo.Content) > 0 {
lo.ForEach(draftInfo.Content, func(item string, index int) {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(item))
})
}
images := []string{}
for _, val := range draftList[i].Images {
images = append(images, val.Url)
... ... @@ -52,11 +66,12 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
resp.List[i] = types.MiniArticleDraftItem{
Id: draftList[i].Id,
Template: draftList[i].Template,
Section: draftList[i].Content,
//Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
CreatedAt: draftList[i].CreatedAt,
MatchUrl: draftList[i].MatchUrl,
Paragraphs: paragraphs,
}
}
return resp, nil
... ...
... ... @@ -75,6 +75,7 @@ func (l *SystemCreateArticleDraftLogic) SystemCreateArticleDraft(req *types.Syst
Name: userMe.User.NickName,
},
Tags: req.Tags,
Section: NewArticleSectionFromParagraphs(req.Paragraphs, companyInfo.Id, 0),
}
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Insert(ctx, conn, articleDraft)
... ...
... ... @@ -3,6 +3,7 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"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"
... ... @@ -57,6 +58,15 @@ func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArti
Height: video.Height,
})
})
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(articleDraft.Section, func(p *domain.ArticleSection, index int) {
paragraphs = append(paragraphs, core.NewTypesParagraph(p.ParagraphTemplate))
})
if len(paragraphs) == 0 && len(articleDraft.Content) > 0 {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(articleDraft.Content))
}
resp = &types.SystemArticleDraftGetResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
... ...
... ... @@ -68,6 +68,7 @@ func (l *SystemUpdateArticleDraftLogic) SystemUpdateArticleDraft(req *types.Syst
Id: userToken.UserId,
Name: userMe.User.NickName,
}
articleDraft.Section = NewArticleSectionFromParagraphs(req.Paragraphs, articleDraft.CompanyId, 0)
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Update(ctx, conn, articleDraft)
if err != nil {
... ...
... ... @@ -30,3 +30,14 @@ func NewTypesParagraph(item domain.Paragraph) types.Paragraph {
Type: item.Type,
}
}
func NewNoneTypesParagraph(item string) types.Paragraph {
return types.Paragraph{
ID: "",
Title: "",
Prompt: "",
Required: false,
Type: 0,
Text: item,
}
}
... ...
... ... @@ -1162,7 +1162,7 @@ type MiniArticleMarkUserReadResponse struct {
type MiniArticleDraftCreateRequest struct {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 5、演绎式 3、归纳式 10、其他业务类型模板
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
... ... @@ -1216,6 +1216,7 @@ type MiniArticleDraftItem struct {
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"` //
MatchUrl map[string]string `json:"matchUrl"` //匹配内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
type MiniArticleDraftGetMeRequest struct {
... ... @@ -1234,6 +1235,7 @@ type MiniArticleDraftGetMeResponse struct {
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` //
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
type MiniArticleDraftDeleteMeRequest struct {
... ... @@ -1547,6 +1549,7 @@ type SystemArticleDraftCreateRequest struct {
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
type SystemArticleDraftCreateResponse struct {
... ... @@ -1576,6 +1579,7 @@ type SystemArticleDraftUpdateRequest struct {
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
type SystemArticleDraftUpdateResponse struct {
... ... @@ -1654,6 +1658,7 @@ type SystemArticleDraftGetResponse struct {
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
type SystemArticleSearchDeletedRequest struct {
... ...
... ... @@ -27,7 +27,7 @@ type ArticleDraft struct {
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"`
Section []*domain.ArticleSection `gorm:"type:jsonb;serializer:json"`
}
func (m *ArticleDraft) TableName() string {
... ...
... ... @@ -29,6 +29,8 @@ type ArticleDraftOperation struct {
UpdatedAt int64 `gorm:"comment:编辑时间"` // 编辑时间
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` // 删除标记
DeletedAt int64 `gorm:"comment:删除时间"` // 删除时间
Section []*domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容
}
func (m *ArticleDraftOperation) TableName() string {
... ...
... ... @@ -161,6 +161,7 @@ func (repository *ArticleDraftRepository) ModelToDomainModel(from *models.Articl
WhoReview: from.WhoReview,
Location: from.Location,
MatchUrl: from.MatchUrl,
Section: from.Section,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -183,6 +184,7 @@ func (repository *ArticleDraftRepository) DomainModelToModel(from *domain.Articl
WhoReview: from.WhoReview,
Location: from.Location,
MatchUrl: from.MatchUrl,
Section: from.Section,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -27,6 +27,7 @@ type ArticleDraftOperation struct {
UpdatedAt int64 `json:"updatedAt,omitempty"` // 编辑时间
IsDel soft_delete.DeletedAt `json:"isDel,omitempty"` // 删除标记
DeletedAt int64 `json:"deletedAt,omitempty"` // 删除时间
Section []*ArticleSection `json:"section"` // 分段内容
}
type ArticleDraftOperationRepository interface {
... ...
... ... @@ -8,19 +8,19 @@ import (
// 文章段落内容
type ArticleSection struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
Id int64 `json:"id,omitempty"`
CompanyId int64 `json:"companyId,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
ArticleId int64 `json:"articleId"` // 文章id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Images []string `json:"images"` // 照片列表
ParagraphType int `json:"paragraphType"` // 段落类型 1:文本 2:图片
ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板
ArticleId int64 `json:"articleId,omitempty"` // 文章id
Content string `json:"content,omitempty"` // 文本内容
SortBy int `json:"sortBy,omitempty"` // 排序
TotalComment int `json:"totalComment,omitempty"` // 评论的数量
Images []string `json:"images,omitempty"` // 照片列表
ParagraphType int `json:"paragraphType,omitempty"` // 段落类型 1:文本 2:图片
ParagraphTemplate Paragraph `json:"paragraphTemplate,omitempty"` // 段落模板
}
type ArticleSectionRepository interface {
... ...
... ... @@ -4,3 +4,5 @@ alter table article_section add column paragraph_template jsonb;
alter table article_section add column paragraph_type int8;
alter table article_section add column images jsonb;
update article_section set paragraph_type = 0;
alter table article_draft_operation add column section jsonb;
\ No newline at end of file
... ...