|
|
@@ -1,5 +1,8 @@
|
|
|
package org.springblade.gateway.active_gateway.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
|
import org.springblade.gateway.active_gateway.constant.ActiveProductConstant;
|
|
|
import org.springblade.gateway.active_gateway.service.ProductSortService;
|
|
|
@@ -11,6 +14,7 @@ import org.springblade.sing.user.entity.LoginUser;
|
|
|
import org.springblade.sing.user.service.ILoginUserService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.ZSetOperations;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -75,4 +79,25 @@ public class ProductSortServiceImpl implements ProductSortService {
|
|
|
throw new IllegalAccessException("非法操作");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage sortListQuery(ProductSortVO productSortVO, Query query) throws IllegalAccessException {
|
|
|
+ //将sql的页码转换为redis zSet的页码
|
|
|
+ long current = query.getCurrent() == null ? 1 : query.getCurrent();
|
|
|
+ long size = query.getSize()==null ? 10 : query.getSize();
|
|
|
+ long start = (current - 1) * size;
|
|
|
+ long end = current * size - 1;
|
|
|
+ productSortVO.setStart(start);
|
|
|
+ productSortVO.setEnd(end);
|
|
|
+ List<ActiveProductRecordVO> productRecordVOS = this.sortList(productSortVO);
|
|
|
+ //page对象
|
|
|
+ String key = ActiveProductConstant.PRODUCT_SORT_CACHE_KEY;
|
|
|
+ Long total = bladeRedis.getZSetOps().zCard(key.concat(":").concat(productSortVO.getActiveId().toString()));
|
|
|
+ IPage page = new Page();
|
|
|
+ page.setRecords(productRecordVOS);
|
|
|
+ page.setCurrent(current);
|
|
|
+ page.setSize(size);
|
|
|
+ page.setTotal(total);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
}
|