shicr 8 лет назад
Родитель
Сommit
8b7f6306c3

+ 12 - 2
donate-service/src/main/java/com/uas/service/donate/controller/indexController.java → donate-service/src/main/java/com/uas/service/donate/controller/IndexController.java

@@ -1,5 +1,6 @@
 package com.uas.service.donate.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.service.donate.model.*;
 import com.uas.service.donate.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,8 +10,10 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 @Controller
-public class indexController {
+public class IndexController {
 
     @Autowired
     private ProjectRecodeService projectRecodeService;
@@ -18,6 +21,9 @@ public class indexController {
     @Autowired
     private ProjectService projectService;
 
+    @Autowired
+    private CarouselService carouselService;
+
 
     @RequestMapping(value = "/",method = RequestMethod.GET)
     public String returnaDefault(){
@@ -32,7 +38,8 @@ public class indexController {
                               @RequestParam(value = "size", defaultValue = "7") int size,
                               @RequestParam(value = "area", defaultValue = "全部") String area,
                               @RequestParam(value = "status", defaultValue = "全部") String status,
-                              @RequestParam(value = "search",required = false)String search) {
+                              @RequestParam(value = "search",required = false)String search,
+                              @RequestParam(value = "useFor",defaultValue ="donate")String useFor) {
 
         PageRequest pageable=new PageRequest(page,size);
 
@@ -40,6 +47,8 @@ public class indexController {
         Long historyPerson = projectRecodeService.historyPerson();
         //得到历史参与总捐款额
         Double totality = projectRecodeService.totality();
+        //得到轮播图
+        List<JSONObject> carouselList=carouselService.getCarousels(useFor);
 
         //展示不同的状态列表
         if (!"全部".equals(status) &&  "全部".equals(area)) {
@@ -74,6 +83,7 @@ public class indexController {
 
         model.addAttribute("historyPerson", historyPerson);
         model.addAttribute("totality", totality);
+        model.addAttribute("carouselList",carouselList);
         return "index";
     }