|
|
@@ -1,6 +1,7 @@
|
|
|
package com.finikes.oc.vote.controller;
|
|
|
|
|
|
import com.finikes.oc.common.ApiResponse;
|
|
|
+import com.finikes.oc.vote.dao.ChoiceDao;
|
|
|
import com.finikes.oc.vote.dao.VoteActivityDao;
|
|
|
import com.finikes.oc.vote.dto.*;
|
|
|
import com.finikes.oc.vote.service.VoteService;
|
|
|
@@ -19,6 +20,9 @@ public class VoteController {
|
|
|
|
|
|
private final VoteService voteService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ChoiceDao choiceDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private VoteActivityDao voteActivityDao;
|
|
|
|
|
|
@@ -161,6 +165,22 @@ public class VoteController {
|
|
|
return ApiResponse.successful(dto);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/suggestion/s")
|
|
|
+ public ApiResponse<OptionSuggestions> suggestions(@RequestParam("voteId") Integer voteId, @RequestParam("page") Integer page, @RequestParam("pageCapacity") Integer pageCapacity) {
|
|
|
+ int offset = (page - 1) * pageCapacity;
|
|
|
+ List<OptionSuggestion> suggestions = choiceDao.getSuggestionSectionByVote(voteId, offset, pageCapacity);
|
|
|
+ OptionSuggestions optionSuggestions = new OptionSuggestions();
|
|
|
+ optionSuggestions.setSuggestions(suggestions);
|
|
|
+ int suggestionNum = choiceDao.getSuggestionNumByVote(voteId);
|
|
|
+ int pageQuantity = suggestionNum / pageCapacity;
|
|
|
+ if (suggestionNum % pageCapacity > 0) {
|
|
|
+ pageQuantity++;
|
|
|
+ }
|
|
|
+ optionSuggestions.setPageQuantity(String.valueOf(pageQuantity));
|
|
|
+
|
|
|
+ return ApiResponse.successful(optionSuggestions);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 异常处理器
|