|
|
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/pkg/xerr"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
|
type MiniGetArticleBackupLogic struct {
|
|
|
logx.Logger
|
|
|
ctx context.Context
|
|
|
svcCtx *svc.ServiceContext
|
|
|
}
|
|
|
|
|
|
func NewMiniGetArticleBackupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleBackupLogic {
|
|
|
return &MiniGetArticleBackupLogic{
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
ctx: ctx,
|
|
|
svcCtx: svcCtx,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (l *MiniGetArticleBackupLogic) MiniGetArticleBackup(req *types.MiniGetArticleBackupRequest) (resp *types.MiniGetArticleBackupResponse, err error) {
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
|
|
|
backupInfo, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.BackupId)
|
|
|
if err != nil {
|
|
|
return &types.MiniGetArticleBackupResponse{}, xerr.NewErrMsgErr("获取编辑记录失败", err)
|
|
|
}
|
|
|
|
|
|
content := strings.Builder{}
|
|
|
for _, val2 := range backupInfo.Section {
|
|
|
content.WriteString(val2.Content)
|
|
|
}
|
|
|
images := []string{}
|
|
|
for _, val2 := range backupInfo.Images {
|
|
|
images = append(images, val2.Url)
|
|
|
}
|
|
|
|
|
|
videos := []types.Video{}
|
|
|
for _, val2 := range backupInfo.Videos {
|
|
|
videos = append(videos, types.Video{
|
|
|
Url: val2.Url,
|
|
|
Cover: val2.Cover,
|
|
|
Width: val2.Width,
|
|
|
Height: val2.Height,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
resp = &types.MiniGetArticleBackupResponse{
|
|
|
Id: backupInfo.Id,
|
|
|
Title: backupInfo.Title,
|
|
|
Content: content.String(),
|
|
|
Images: images,
|
|
|
Videos: videos,
|
|
|
CreatedAt: backupInfo.CreatedAt,
|
|
|
Location: types.Location{
|
|
|
Longitude: backupInfo.Location.Longitude,
|
|
|
Latitude: backupInfo.Location.Latitude,
|
|
|
Descript: backupInfo.Location.Descript,
|
|
|
},
|
|
|
ChangeField: backupInfo.ChangeField,
|
|
|
Action: backupInfo.Action,
|
|
|
Show: int(backupInfo.Show),
|
|
|
}
|
|
|
|
|
|
return
|
|
|
} |
...
|
...
|
|