...
|
...
|
@@ -5,6 +5,8 @@ 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/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
...
|
...
|
@@ -23,8 +25,36 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext |
|
|
}
|
|
|
}
|
|
|
|
|
|
// MiniArticleSearchMe 获取我发布的文章
|
|
|
func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
|
|
|
// todo: add your logic here and delete this line
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
queryOptions := domain.NewQueryOptions().
|
|
|
WithOffsetLimit(req.Page, req.Size).
|
|
|
MustWithKV("authorId", req.AuthorId)
|
|
|
|
|
|
cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
|
|
|
if err != nil {
|
|
|
return &types.MiniArticleSearchMeResponse{}, xerr.NewErrMsgErr("获取文章列表失败", err)
|
|
|
}
|
|
|
|
|
|
resp = &types.MiniArticleSearchMeResponse{
|
|
|
Total: int(cnt),
|
|
|
List: make([]types.ArticleSearchMe, len(articleList)),
|
|
|
}
|
|
|
for i := range articleList {
|
|
|
images := []string{}
|
|
|
for _, val2 := range articleList[i].Images {
|
|
|
images = append(images, val2.Url)
|
|
|
}
|
|
|
resp.List[i] = types.ArticleSearchMe{
|
|
|
Id: articleList[i].Id,
|
|
|
Title: articleList[i].Title,
|
|
|
Images: images,
|
|
|
CreatedAt: articleList[i].CreatedAt,
|
|
|
CountLove: articleList[i].CountLove,
|
|
|
CountComment: articleList[i].CountComment,
|
|
|
Show: int(articleList[i].Show),
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|