作者 yangfu

修改排序

... ... @@ -144,7 +144,9 @@ type(
AuthorId int64 `json:"authorId"` // 特定作者ID
LastArticleId int64 `json:"lastArticleId,optional"`// 最后文章ID
Size int `json:"size"` // 数量
OrderByHotScore string `json:"orderByHotScore,options=asc|desc,optional,default=desc"` // 热度排序 升序 asc 降序 desc
//OrderByHotScore string `json:"orderByHotScore,options=asc|desc,optional,default=desc"` // 热度排序 升序 asc 降序 desc
OrderByKey string `json:"orderByKey,options=HotScore|All|Time,optional,default=desc"` // 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)
OrderByValue string `json:"orderByValue,options=asc||desc,optional"` // 排序值 升序 asc 降序 desc
Keywords string `json:"keywords,optional"` // 关键字
BeginTime int64 `json:"beginTime,optional"`// 开始时间
EndTime int64 `json:"endTime,optional"`// 结束时间
... ...
... ... @@ -50,9 +50,17 @@ func (l *MiniHomepageUserNewsLogic) MiniHomepageUserNews(req *types.MiniHomepage
queryOptions := domain.IndexCompanyId(userToken.CompanyId)().
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime).
WithKV("keywords", req.Keywords).
WithKV("orderByHotScore", req.OrderByHotScore)
WithKV("keywords", req.Keywords)
if len(req.OrderByKey) > 0 && len(req.OrderByValue) > 0 {
switch req.OrderByKey {
case "HotScore":
queryOptions.WithKV("orderByHotScore", req.OrderByValue)
case "All":
queryOptions.WithKV("orderByAll", req.OrderByValue)
case "Time":
queryOptions.WithKV("orderByAll", req.OrderByValue)
}
}
var users = []int64{req.AuthorId}
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, currentUser.Id, req.LastArticleId, req.Size, queryOptions.Copy().WithFindOnly()); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
... ...
... ... @@ -64,6 +64,7 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest)
Name: item.Name,
PinYinName: item.PinYinName,
Avatar: item.Avatar,
Position: item.Position,
})
})
return map[string]interface{}{
... ...
... ... @@ -488,7 +488,8 @@ type MiniHomepageUserNewsRequest struct {
AuthorId int64 `json:"authorId"` // 特定作者ID
LastArticleId int64 `json:"lastArticleId,optional"` // 最后文章ID
Size int `json:"size"` // 数量
OrderByHotScore string `json:"orderByHotScore,options=asc|desc,optional,default=desc"` // 热度排序 升序 asc 降序 desc
OrderByKey string `json:"orderByKey,options=HotScore|All|Time,optional,default=desc"` // 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)
OrderByValue string `json:"orderByValue,options=asc||desc,optional"`
Keywords string `json:"keywords,optional"` // 关键字
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
... ...
... ... @@ -234,6 +234,8 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
}
if v, ok := queryOptions["orderByHotScore"]; ok {
tx.Order(fmt.Sprintf("(count_comment+count_love) %v", v))
} else if v, ok := queryOptions["orderByAll"]; ok {
tx.Order(fmt.Sprintf("id %v", v))
} else {
tx.Order("id desc")
}
... ...