|
@@ -27,8 +27,8 @@ public class VoteController {
|
|
|
* @param dto 投票活动创建数据传输对象
|
|
* @param dto 投票活动创建数据传输对象
|
|
|
* @return 接口返回对象
|
|
* @return 接口返回对象
|
|
|
*/
|
|
*/
|
|
|
- @PutMapping("vote_activity")
|
|
|
|
|
- public ApiResponse<Integer> createVoteActivity(@RequestBody VoteActivityCreateDto dto) {
|
|
|
|
|
|
|
+ @PutMapping("vote_activity/")
|
|
|
|
|
+ public ApiResponse<Integer> createVoteActivity(@RequestBody @Valid VoteActivityCreateDto dto) {
|
|
|
int voteActivityId = voteService.createVoteActivity(dto);
|
|
int voteActivityId = voteService.createVoteActivity(dto);
|
|
|
return ApiResponse.successful(voteActivityId);
|
|
return ApiResponse.successful(voteActivityId);
|
|
|
}
|
|
}
|
|
@@ -39,8 +39,8 @@ public class VoteController {
|
|
|
* @param dto 投票活动创建数据传输对象
|
|
* @param dto 投票活动创建数据传输对象
|
|
|
* @return 接口返回对象
|
|
* @return 接口返回对象
|
|
|
*/
|
|
*/
|
|
|
- @PostMapping("vote_activity")
|
|
|
|
|
- public ApiResponse<Integer> updateVoteActivity(@RequestBody VoteActivityUpdateDto dto) {
|
|
|
|
|
|
|
+ @PostMapping("vote_activity/")
|
|
|
|
|
+ public ApiResponse<Integer> updateVoteActivity(@RequestBody @Valid VoteActivityUpdateDto dto) {
|
|
|
voteService.updateVoteActivity(dto);
|
|
voteService.updateVoteActivity(dto);
|
|
|
return ApiResponse.successful();
|
|
return ApiResponse.successful();
|
|
|
}
|
|
}
|
|
@@ -55,7 +55,7 @@ public class VoteController {
|
|
|
* @param endTime 结束时间
|
|
* @param endTime 结束时间
|
|
|
* @return 接口返回对象
|
|
* @return 接口返回对象
|
|
|
*/
|
|
*/
|
|
|
- @GetMapping("vote_activities/section")
|
|
|
|
|
|
|
+ @GetMapping("vote_activities/section/")
|
|
|
public ApiResponse<List<VoteActivityViewDto>> searchVoteActivity(
|
|
public ApiResponse<List<VoteActivityViewDto>> searchVoteActivity(
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
@RequestParam(value = "pageCapacity", defaultValue = "10") int pageCapacity,
|
|
@RequestParam(value = "pageCapacity", defaultValue = "10") int pageCapacity,
|
|
@@ -72,13 +72,49 @@ public class VoteController {
|
|
|
return ApiResponse.successful(list);
|
|
return ApiResponse.successful(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建投票
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dto 投票创建数据传输对象
|
|
|
|
|
+ * @return 接口返回对象
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("vote/")
|
|
|
|
|
+ public ApiResponse<Integer> createVote(@RequestBody @Valid VoteCreateDto dto) {
|
|
|
|
|
+ int voteId = voteService.createVote(dto);
|
|
|
|
|
+ return ApiResponse.successful(voteId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新投票
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dto 投票更新数据传输对象
|
|
|
|
|
+ * @return 接口返回对象
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("vote/")
|
|
|
|
|
+ public ApiResponse<Integer> createVote(@RequestBody @Valid VoteUpdateDto dto) {
|
|
|
|
|
+ voteService.updateVote(dto);
|
|
|
|
|
+ return ApiResponse.successful();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 依据投票活动 ID 获取投票列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param activityId 投票活动 ID
|
|
|
|
|
+ * @return 接口返回对象
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping(" votes/")
|
|
|
|
|
+ public ApiResponse<List<VoteViewDto>> searchVote(@RequestParam("activityId") Integer activityId) {
|
|
|
|
|
+ List<VoteViewDto> votes = voteService.searchVotes(activityId);
|
|
|
|
|
+ return ApiResponse.successful(votes);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 投票
|
|
* 投票
|
|
|
*
|
|
*
|
|
|
* @param dto 投票数据传输对象
|
|
* @param dto 投票数据传输对象
|
|
|
* @return 接口返回对象
|
|
* @return 接口返回对象
|
|
|
*/
|
|
*/
|
|
|
- @PutMapping("choice")
|
|
|
|
|
|
|
+ @PutMapping("choice/")
|
|
|
public ApiResponse<Void> choice(@RequestBody @Valid ChoiceDto dto) {
|
|
public ApiResponse<Void> choice(@RequestBody @Valid ChoiceDto dto) {
|
|
|
voteService.madeChoice(dto);
|
|
voteService.madeChoice(dto);
|
|
|
return ApiResponse.successful();
|
|
return ApiResponse.successful();
|