Skip to content

Commit

Permalink
fix: 단과대별 후보자 기본 정보 조회 기능 수정 (#44)
Browse files Browse the repository at this point in the history
* feat: 개표 결과 저장 기능 구현

* feat: 개표 결과 조회 기능 구현

* feat: 회원가입 시 소속 정보 받도록 수정

* fix: 단과대별 후보자 기본 정보 조회 기능 수정
  • Loading branch information
LEEJaeHyeok97 authored Dec 22, 2024
1 parent 82cde22 commit 1c4b575
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ public RegisterCandidateInfoResponse registerCandidate(CustomUserDetails userDet
}

@Transactional(readOnly = true)
public CandidateInfoListResponse getCandidateInfo(CustomUserDetails userDetails,String governanceType) {
User user = userDetails.user();
public CandidateInfoListResponse getCandidateInfo(String governanceId) {
List<CandidateInfo> candidateInfoList = candidateInfoRepository
.findAllCandidateByGovernanceType(user.getId(), governanceType);
.findAllByGovernanceId(governanceId);

if (candidateInfoList.isEmpty()) throw new DefaultException(ErrorCode.CANDIDATE_INFO_NOT_FOUND);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public interface CandidateInfoRepository extends JpaRepository<CandidateInfo, Lo
"join c.user u " +
"join u.governance g " +
"where u.id = :userId " +
"and g.governanceType = :governanceType")
List<CandidateInfo> findAllCandidateByGovernanceType(@Param("userId") Long userId, @Param("governanceType") String governanceType);
"and g.id = :governanceId")
List<CandidateInfo> findAllCandidateByGovernanceType(@Param("userId") Long userId, @Param("governanceId") String governanceId);


@Query("select c from CandidateInfo c "
+ "join c.user u "
+ "join u.governance g "
+ "where g.id = :governanceId")
List<CandidateInfo> findAllByGovernanceId(String governanceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@RequiredArgsConstructor
@RestController
@RequestMapping("api/v1")
@RequestMapping("/api/v1")
public class CandidateController {

private final CandidateService candidateService;
Expand All @@ -29,12 +29,10 @@ public ResponseCustom<RegisterCandidateInfoResponse> registerPoster(@Authenticat
return ResponseCustom.OK(registerCandidateInfoResponse);
}

@GetMapping("/candidateInfo/{governance}")
@GetMapping("/candidateInfo/{governanceId}")
@Operation(summary = "단과대별 후보자 기본 정보 조회", description = "단과대학 타입을 입력하면 후보자 기본정보(선거유형, 선본명, 선본통신공간주소, 입후보자 공고 이미지, 로고이미지)를 조회합니다.")
public ResponseCustom<CandidateInfoListResponse> getCandidateInfo(@AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable("governance") String governanceType) {
CandidateInfoListResponse candidateInfo = candidateService.getCandidateInfo(userDetails, governanceType);
public ResponseCustom<CandidateInfoListResponse> getCandidateInfo(@PathVariable("governanceId") String governanceId) {
CandidateInfoListResponse candidateInfo = candidateService.getCandidateInfo(governanceId);
return ResponseCustom.OK(candidateInfo);
}


}

0 comments on commit 1c4b575

Please sign in to comment.