|
|
package article
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
|
type MiniArticleMarkListLogic struct {
|
|
|
logx.Logger
|
|
|
ctx context.Context
|
|
|
svcCtx *svc.ServiceContext
|
|
|
}
|
|
|
|
|
|
func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic {
|
|
|
return &MiniArticleMarkListLogic{
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
ctx: ctx,
|
|
|
svcCtx: svcCtx,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMarkListRequest) (resp *types.MiniArticleMarkListResponse, err error) {
|
|
|
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
|
|
|
|
|
|
total, list, err := l.svcCtx.UserReadArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions().
|
|
|
WithOffsetLimit(req.Page, req.Size).
|
|
|
WithKV("userId", userToken.UserId))
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
resp = &types.MiniArticleMarkListResponse{}
|
|
|
resp.Total = total
|
|
|
resp.List = make([]types.MiniArticleMarkItem, 0)
|
|
|
for _, item := range list {
|
|
|
to := types.MiniArticleMarkItem{
|
|
|
Id: item.Id,
|
|
|
CompanyId: item.CompanyId,
|
|
|
ArticleId: item.ArticleId,
|
|
|
Title: item.Title,
|
|
|
Author: types.SimpleUser{
|
|
|
Id: item.Author.Id,
|
|
|
CompanyId: item.Author.CompanyId,
|
|
|
CompanyName: item.Author.Company,
|
|
|
Name: item.Author.Name,
|
|
|
Avatar: item.Author.Avatar,
|
|
|
Position: item.Author.Position,
|
|
|
},
|
|
|
UpdatedAt: item.UpdatedAt,
|
|
|
}
|
|
|
resp.List = append(resp.List, to)
|
|
|
}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|