...
|
...
|
@@ -2,9 +2,12 @@ package article |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"strings"
|
|
|
|
|
|
"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/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
...
|
...
|
@@ -23,8 +26,44 @@ func NewMiniArticleBackupSearchLogic(ctx context.Context, svcCtx *svc.ServiceCon |
|
|
}
|
|
|
}
|
|
|
|
|
|
func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
|
|
|
// todo: add your logic here and delete this line
|
|
|
func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniArticleBackupSearchRequest) (resp *types.MiniArticleBackupSearchResponse, err error) {
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
|
|
|
return
|
|
|
queryOption := domain.NewQueryOptions().
|
|
|
WithOffsetLimit(req.Page, req.Size).
|
|
|
MustWithKV("article_id", req.ArticleId).
|
|
|
MustWithKV("company_id", req.CompanyId)
|
|
|
|
|
|
cnt, backupList, err := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
return &types.MiniArticleBackupSearchResponse{}, xerr.NewErrMsgErr("获取编辑记录列表失败", err)
|
|
|
}
|
|
|
|
|
|
resp = &types.MiniArticleBackupSearchResponse{
|
|
|
Total: cnt,
|
|
|
List: make([]types.MiniArticleBackupItem, len(backupList)),
|
|
|
}
|
|
|
for i := range backupList {
|
|
|
content := strings.Builder{}
|
|
|
for _, val2 := range backupList[i].Section {
|
|
|
content.WriteString(val2.Content)
|
|
|
}
|
|
|
images := []string{}
|
|
|
for _, val2 := range backupList[i].Images {
|
|
|
images = append(images, val2.Url)
|
|
|
}
|
|
|
resp.List[i] = types.MiniArticleBackupItem{
|
|
|
Id: backupList[i].Id,
|
|
|
Title: backupList[i].Title,
|
|
|
Content: content.String(),
|
|
|
Images: images,
|
|
|
CreatedAt: backupList[i].CreatedAt,
|
|
|
Location: types.Location{
|
|
|
Longitude: backupList[i].Location.Longitude,
|
|
|
Latitude: backupList[i].Location.Latitude,
|
|
|
Descript: backupList[i].Location.Descript,
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|