|
|
@@ -1,13 +1,17 @@
|
|
|
package com.uas.service.donate.controller;
|
|
|
|
|
|
import com.uas.service.donate.model.Activity;
|
|
|
+import com.uas.service.donate.model.Award;
|
|
|
import com.uas.service.donate.service.ActivityService;
|
|
|
+import com.uas.service.donate.service.AwardService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@@ -23,29 +27,19 @@ public class ActivityController {
|
|
|
@Autowired
|
|
|
private ActivityService activityService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AwardService awardService;
|
|
|
+
|
|
|
/**
|
|
|
* 展示进行中和已结束的活动列表
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/getActivities")
|
|
|
- public Page<Activity> getActivities(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "7")Integer size){
|
|
|
- Pageable pageable=pageSort(page,size);
|
|
|
- return activityService.findAll(pageable);
|
|
|
+ public List<Activity> getActivities(){
|
|
|
+ return activityService.findAll();
|
|
|
}
|
|
|
|
|
|
- /*优先级倒序,时间倒序排序的方式*/
|
|
|
- private Pageable pageSort(Integer page,Integer size){
|
|
|
- Sort.Order prioritySort=new Sort.Order(Sort.Direction.DESC,"priority");
|
|
|
- Sort.Order timeSort=new Sort.Order(Sort.Direction.DESC,"submitTime");
|
|
|
- List<Sort.Order> list=new ArrayList<Sort.Order>();
|
|
|
- list.add(prioritySort);
|
|
|
- list.add(timeSort);
|
|
|
- Sort sort = new Sort(list);
|
|
|
- Pageable pageable=new PageRequest(page,size,sort);
|
|
|
- return pageable;
|
|
|
- }
|
|
|
/**
|
|
|
* 展示某具体活动
|
|
|
*/
|
|
|
@@ -60,23 +54,18 @@ public class ActivityController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/inprocessActivities")
|
|
|
- public Page<Activity> findInProcess(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "7")Integer size,
|
|
|
- Pageable pageable){
|
|
|
- return activityService.findInProcess(pageable);
|
|
|
+ public List<Activity> findInProcess(){
|
|
|
+ return activityService.findInProcess();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索出所有已结束的活动,当前时间大于活动结束时间
|
|
|
- * @param pageable
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/endActivities")
|
|
|
- public Page<Activity> findEndActivities(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "7")Integer size,
|
|
|
- Pageable pageable){
|
|
|
- return activityService.findEndActivities(pageable);
|
|
|
+ public List<Activity> findEndActivities(){
|
|
|
+ return activityService.findEndActivities();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -85,8 +74,10 @@ public class ActivityController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequestMapping("/sumMoney")
|
|
|
- public Double sumMoney(Long id){
|
|
|
- return activityService.sumMoney(id);
|
|
|
+ @RequestMapping("/sumMoney/{id}")
|
|
|
+ public ModelMap sumMoney(@PathVariable("id") Long id) {
|
|
|
+
|
|
|
+ return new ModelMap("sum",activityService.sumMoney(id));
|
|
|
+
|
|
|
}
|
|
|
}
|