Search in sources :

Example 11 with R

use of com.wayn.common.util.R 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;
}
Also used : R(com.wayn.common.util.R) Category(com.wayn.common.core.domain.shop.Category) Goods(com.wayn.common.core.domain.shop.Goods) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 12 with R

use of com.wayn.common.util.R 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;
}
Also used : R(com.wayn.common.util.R) Category(com.wayn.common.core.domain.shop.Category) FutureTask(java.util.concurrent.FutureTask) List(java.util.List) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 13 with R

use of com.wayn.common.util.R 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;
}
Also used : VanTreeSelectVo(com.wayn.common.core.domain.vo.VanTreeSelectVo) R(com.wayn.common.util.R) Category(com.wayn.common.core.domain.shop.Category) FutureTask(java.util.concurrent.FutureTask) List(java.util.List) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 14 with R

use of com.wayn.common.util.R in project waynboot-mall by wayn111.

the class SearchController method hotKeywords.

@GetMapping("hotKeywords")
public R hotKeywords() {
    List<Keyword> hotKeywords = iKeywordService.list(new QueryWrapper<Keyword>().eq("is_hot", true).orderByAsc("sort"));
    List<String> hotStrings = hotKeywords.stream().map(Keyword::getKeyword).collect(Collectors.toList());
    List<Keyword> defaultKeyword = iKeywordService.list(new QueryWrapper<Keyword>().eq("is_default", true).orderByAsc("sort"));
    List<String> defaultStrings = defaultKeyword.stream().map(Keyword::getKeyword).collect(Collectors.toList());
    R r = R.success();
    if (CollectionUtils.isNotEmpty(hotStrings)) {
        r.add("data", hotStrings);
    }
    r.add("data", hotStrings);
    if (CollectionUtils.isNotEmpty(defaultStrings)) {
        r.add("default", defaultStrings.get(0));
    }
    return r;
}
Also used : R(com.wayn.common.util.R) Keyword(com.wayn.common.core.domain.shop.Keyword) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 15 with R

use of com.wayn.common.util.R in project waynboot-mall by wayn111.

the class LoginController method getRouters.

@GetMapping("/getRouters")
public R getRouters(HttpServletRequest request) {
    R success = R.success();
    LoginUserDetail loginUser = tokenService.getLoginUser(request);
    // 用户信息
    User user = loginUser.getUser();
    List<Menu> menus = iMenuService.selectMenuTreeByUserId(user.getUserId());
    return success.add("routers", iMenuService.buildMenus(menus));
}
Also used : R(com.wayn.common.util.R) User(com.wayn.common.core.domain.system.User) LoginUserDetail(com.wayn.common.core.model.LoginUserDetail) Menu(com.wayn.common.core.domain.system.Menu)

Aggregations

R (com.wayn.common.util.R)18 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)5 Goods (com.wayn.common.core.domain.shop.Goods)5 List (java.util.List)5 IPage (com.baomidou.mybatisplus.core.metadata.IPage)4 LoginUserDetail (com.wayn.common.core.model.LoginUserDetail)4 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)3 Category (com.wayn.common.core.domain.shop.Category)3 IGoodsService (com.wayn.common.core.service.shop.IGoodsService)3 MobileSecurityUtils (com.wayn.mobile.framework.security.util.MobileSecurityUtils)3 LocalDateTime (java.time.LocalDateTime)3 Collectors (java.util.stream.Collectors)3 CollectionUtils (org.apache.commons.collections4.CollectionUtils)3 JSONObject (com.alibaba.fastjson.JSONObject)2 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)2 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)2 BaseController (com.wayn.common.base.controller.BaseController)2 User (com.wayn.common.core.domain.system.User)2 IOException (java.io.IOException)2