use of com.wayn.common.core.domain.shop.Category in project waynboot-mall by wayn111.
the class CategoryController method firstCateGoods.
@GetMapping("firstCategoryGoods")
public R firstCateGoods(@RequestParam(defaultValue = "0") Long cateId) {
Page<Goods> page = getPage();
List<Category> categoryList = iCategoryService.list(new QueryWrapper<Category>().select("id").eq("pid", cateId));
List<Long> cateList = categoryList.stream().map(Category::getId).collect(Collectors.toList());
R success = iGoodsService.selectListPageByCateIds(page, cateList);
success.add("category", iCategoryService.getById(cateId));
return success;
}
use of com.wayn.common.core.domain.shop.Category in project waynboot-mall by wayn111.
the class CategoryController method content.
@GetMapping("content")
public R content(Long id) {
long begin = System.currentTimeMillis();
R success = R.success();
Callable<Category> currentCategoryCallable = () -> iCategoryService.getById(id);
Callable<List<VanTreeSelectVo>> subCategoryListCallable = () -> iCategoryService.selectCategoryByPid(id);
FutureTask<Category> currentCategoryTask = new FutureTask<>(currentCategoryCallable);
FutureTask<List<VanTreeSelectVo>> subCategoryListTask = new FutureTask<>(subCategoryListCallable);
categoryThreadPoolTaskExecutor.submit(currentCategoryTask);
categoryThreadPoolTaskExecutor.submit(subCategoryListTask);
try {
success.add("currentCategory", currentCategoryTask.get());
success.add("subCategoryList", subCategoryListTask.get());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
long end = System.currentTimeMillis();
log.info("content time:{}", end - begin);
return success;
}
use of com.wayn.common.core.domain.shop.Category in project waynboot-mall by wayn111.
the class CategoryController method index.
@GetMapping("index")
public R index(@RequestParam(required = false) Long id) {
R success = R.success();
List<VanTreeSelectVo> categoryList = iCategoryService.selectL1Category();
Callable<Category> currentCategoryCallable;
Callable<List<VanTreeSelectVo>> subCategoryListCallable;
if (Objects.isNull(id) && CollectionUtils.isNotEmpty(categoryList)) {
currentCategoryCallable = () -> iCategoryService.getById(categoryList.get(0).getId());
subCategoryListCallable = () -> iCategoryService.selectCategoryByPid(categoryList.get(0).getId());
} else {
currentCategoryCallable = () -> iCategoryService.getById(id);
subCategoryListCallable = () -> iCategoryService.selectCategoryByPid(id);
}
FutureTask<Category> currentCategoryTask = new FutureTask<>(currentCategoryCallable);
FutureTask<List<VanTreeSelectVo>> subCategoryListTask = new FutureTask<>(subCategoryListCallable);
categoryThreadPoolTaskExecutor.submit(currentCategoryTask);
categoryThreadPoolTaskExecutor.submit(subCategoryListTask);
try {
success.add("categoryList", categoryList);
success.add("currentCategory", currentCategoryTask.get());
success.add("subCategoryList", subCategoryListTask.get());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return success;
}
Aggregations