feat(前台): 添加首页接口

master
waynaqua 4 years ago
parent 5dad439561
commit 3a03d5c4ae

@ -17,6 +17,9 @@
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>2.2.4.RELEASE</spring-boot.version>
<mysql.connector.java.version>8.0.19</mysql.connector.java.version>
<jedis.version>3.1.0</jedis.version>

@ -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<List<Banner>> bannerCall = () -> iBannerService.list(new QueryWrapper<Banner>().eq("status", 0).orderByAsc("sort_order"));
Callable<List<Category>> categoryCall = () -> iCategoryService.list(new QueryWrapper<Category>().eq("level", "L1").orderByAsc("sort_order"));
FutureTask<List<Banner>> bannerTask = new FutureTask<>(bannerCall);
poolExecutor.submit(bannerTask);
FutureTask<List<Category>> 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;
}
}

@ -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;

Loading…
Cancel
Save