From 3a03d5c4aeca5ed6d44968804208483dc718e2e2 Mon Sep 17 00:00:00 2001 From: waynaqua <1669738430@qq.com> Date: Mon, 27 Jul 2020 19:16:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=89=8D=E5=8F=B0):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 ++ .../mobile/api/controller/HomeController.java | 50 +++++++++++++++++++ .../mobile/api/controller/UserController.java | 1 - 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java diff --git a/pom.xml b/pom.xml index da77f61..91f73f6 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,9 @@ 1.8 + UTF-8 + ${java.version} + ${java.version} 2.2.4.RELEASE 8.0.19 3.1.0 diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java new file mode 100644 index 0000000..c817208 --- /dev/null +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java @@ -0,0 +1,50 @@ +package com.wayn.mobile.api.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.wayn.common.core.domain.shop.Banner; +import com.wayn.common.core.domain.shop.Category; +import com.wayn.common.core.service.shop.IBannerService; +import com.wayn.common.core.service.shop.ICategoryService; +import com.wayn.common.util.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.concurrent.*; + +@RestController +@RequestMapping("home") +public class HomeController { + + @Autowired + private IBannerService iBannerService; + + @Autowired + private ICategoryService iCategoryService; + + @PostMapping("index") + public R getInfo() { + R success = R.success(); + ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(10, 10, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(), r -> new Thread(r,"首页线程")); + Callable> bannerCall = () -> iBannerService.list(new QueryWrapper().eq("status", 0).orderByAsc("sort_order")); + Callable> categoryCall = () -> iCategoryService.list(new QueryWrapper().eq("level", "L1").orderByAsc("sort_order")); + FutureTask> bannerTask = new FutureTask<>(bannerCall); + poolExecutor.submit(bannerTask); + FutureTask> categoryTask = new FutureTask<>(categoryCall); + poolExecutor.submit(categoryTask); + try { + success.add("bannerList", bannerTask.get()); + success.add("categoryList", categoryTask.get()); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } finally { + poolExecutor.shutdown(); + } + return success; + } +} + diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java index 7b1dd67..5b9ce18 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java @@ -1,6 +1,5 @@ package com.wayn.mobile.api.controller; -import com.wayn.common.core.service.shop.IMemberService; import com.wayn.common.util.R; import com.wayn.common.util.ServletUtils; import com.wayn.mobile.framework.security.LoginUserDetail;