96 lines
3.0 KiB
Java
96 lines
3.0 KiB
Java
package io.company.localhost.controller.api;
|
|
|
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PatchMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import io.company.localhost.common.annotation.Member;
|
|
import io.company.localhost.common.annotation.ParameterCheck;
|
|
import io.company.localhost.common.annotation.ReqMap;
|
|
import io.company.localhost.common.dto.ApiResponse;
|
|
import io.company.localhost.common.dto.MapDto;
|
|
import io.company.localhost.service.localvoteService;
|
|
import io.company.localhost.utils.AuthUtil;
|
|
import io.company.localhost.vo.MemberVo;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Slf4j
|
|
@RequestMapping("/api/vote")
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
public class VoteBoardController {
|
|
|
|
private final localvoteService localvoteservice;
|
|
|
|
/**
|
|
* 투표목록조회
|
|
* @param page 페이지번호 , 내가한투표 :0 투표안한것 :1 , 전체:0,투표마감:1,투표중:2
|
|
* @return
|
|
*/
|
|
@Member
|
|
@ParameterCheck
|
|
@GetMapping("getVoteList")
|
|
public ApiResponse<PageInfo<MapDto>> getVoteList(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
|
|
|
//userId
|
|
Long userId = AuthUtil.getUser().getId();
|
|
map.put("userId", userId);
|
|
PageInfo<MapDto> VoteList = localvoteservice.getVoteList(map);
|
|
|
|
|
|
return ApiResponse.ok(VoteList);
|
|
}
|
|
|
|
/**
|
|
* 투표 등록
|
|
* @param title 제목 ,endDate 종료날짜 ,itemList 항목리스트(항목,링크) ,addvoteIs 항목추가여부, votemMltiIs 다중투표 허용여부
|
|
* @return
|
|
*/
|
|
@Member
|
|
@PostMapping("insertWord")
|
|
public ApiResponse<Long> insertWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
|
|
|
//userId
|
|
Long userId = AuthUtil.getUser().getId();
|
|
map.put("userId", userId);
|
|
Long result = localvoteservice.insertVote(map);
|
|
return ApiResponse.ok(result);
|
|
}
|
|
|
|
/**
|
|
* 투표 선택
|
|
* @param title 제목 ,endDate 종료날짜 ,itemList 항목리스트(항목,링크) ,addvoteIs 항목추가여부, votemMltiIs 다중투표 허용여부
|
|
* @return
|
|
*/
|
|
@Member
|
|
@PostMapping("insertCheckedNums")
|
|
public ApiResponse<Long> insertCheckedNums(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
|
|
|
Long userId = AuthUtil.getUser().getId();
|
|
map.put("userId", userId);
|
|
return ApiResponse.ok(localvoteservice.insertCheckedNums(map));
|
|
}
|
|
|
|
/**
|
|
* 투표 종료
|
|
* @param endVoteId 투표번호
|
|
* @return
|
|
*/
|
|
@Member
|
|
@PatchMapping("updateEndData")
|
|
public ApiResponse<Long> updateEndData(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
|
|
|
Long userId = AuthUtil.getUser().getId();
|
|
map.put("userId", userId);
|
|
return ApiResponse.ok(localvoteservice.updateEndData(map));
|
|
}
|
|
|
|
|
|
}
|