|
@@ -108,10 +108,15 @@ func SortPrev(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
Query: repo.Map{"_id": id},
|
|
|
})
|
|
|
currentSort := result["sort"].(int32)
|
|
|
+ currentType := result["type"].(string)
|
|
|
+ query := repo.Map{"sort": repo.Map{"$gt": int(currentSort)}}
|
|
|
+ if len(currentType) > 0 {
|
|
|
+ query["type"] = currentType
|
|
|
+ }
|
|
|
// 获取当前数据的上一条数据的sort
|
|
|
out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: ClickType,
|
|
|
- Query: repo.Map{"sort": repo.Map{"$gt": int(currentSort)}},
|
|
|
+ Query: query,
|
|
|
Page: 1,
|
|
|
Size: 1,
|
|
|
// 升序,越小的在前面
|
|
@@ -155,10 +160,15 @@ func SortNext(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
Query: repo.Map{"_id": id},
|
|
|
})
|
|
|
currentSort := result["sort"].(int32)
|
|
|
+ currentType := result["type"].(string)
|
|
|
+ query := repo.Map{"sort": repo.Map{"$gt": int(currentSort)}}
|
|
|
+ if len(currentType) > 0 {
|
|
|
+ query["type"] = currentType
|
|
|
+ }
|
|
|
// 获取当前数据的上一条数据的sort
|
|
|
out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: ClickType,
|
|
|
- Query: repo.Map{"sort": repo.Map{"$lt": int(currentSort)}},
|
|
|
+ Query: query,
|
|
|
Page: 1,
|
|
|
Size: 1,
|
|
|
// 降序,越大的在前面
|