Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix/#326] 회계내역 사용자 조회 오류 #327

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
@Getter
@NoArgsConstructor
public class ApprovedMemberSummaryDto {

@NotNull private Long id;

@NotBlank
@Length(max = 50)
private String name;
Expand All @@ -29,7 +32,13 @@ public class ApprovedMemberSummaryDto {

@Builder
public ApprovedMemberSummaryDto(
String name, String studentId, MemberType memberType, Integer generation, String major) {
Long id,
String name,
String studentId,
MemberType memberType,
Integer generation,
String major) {
this.id = id;
this.name = name;
this.studentId = studentId;
this.memberType = memberType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface MemberRepository extends JpaRepository<Member, Long>, MemberRep

List<Member> findAllByIbasInformation_IsHOF(boolean IsHOF);

Optional<Member> findByStudentId_IdAndName_Value(String studentId, String name);
Optional<Member> findByIdAndStudentId_IdAndName_Value(Long id, String studentId, String name);

// OAuth
boolean existsByProviderAndUid(OAuth2Provider provider, UID uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class BudgetHistoryCreateForm {

@NotBlank private String details;

private Long memberIdReceived;

private String memberStudentIdReceived;

private String memberNameReceived;
Expand All @@ -54,6 +56,7 @@ public BudgetHistoryCreateForm(
LocalDateTime dateUsed,
String title,
String details,
Long memberIdReceived,
String memberStudentIdReceived,
String memberNameReceived,
Integer income,
Expand All @@ -62,6 +65,7 @@ public BudgetHistoryCreateForm(
this.dateUsed = dateUsed;
this.title = title;
this.details = details;
this.memberIdReceived = memberIdReceived;
this.memberStudentIdReceived = memberStudentIdReceived;
this.memberNameReceived = memberNameReceived;
this.income = income;
Expand All @@ -75,13 +79,15 @@ public BudgetHistoryCreateForm(
public boolean isIncome() {
return this.income > ZERO
&& this.outcome == 0
&& this.memberIdReceived == null
&& this.memberNameReceived == null
&& this.memberStudentIdReceived == null;
}

public boolean isOutcome() {
return this.outcome > ZERO
&& this.income == 0
&& this.memberIdReceived != null
&& this.memberNameReceived != null
&& this.memberStudentIdReceived != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public Long createHistory(BudgetHistoryCreateForm form, Long secretaryId) {
} else if (form.isOutcome()) {
memberReceived =
memberRepository
.findByStudentId_IdAndName_Value(
form.getMemberStudentIdReceived(), form.getMemberNameReceived())
.findByIdAndStudentId_IdAndName_Value(
form.getMemberIdReceived(),
form.getMemberStudentIdReceived(),
form.getMemberNameReceived())
.orElseThrow(MemberNotFoundException::new);
} else {
throw new InvalidInputException();
Expand Down Expand Up @@ -79,8 +81,10 @@ public void modifyHistory(Long historyId, BudgetHistoryCreateForm form, Long sec
} else if (form.isOutcome()) {
memberReceived =
memberRepository
.findByStudentId_IdAndName_Value(
form.getMemberStudentIdReceived(), form.getMemberNameReceived())
.findByIdAndStudentId_IdAndName_Value(
form.getMemberIdReceived(),
form.getMemberStudentIdReceived(),
form.getMemberNameReceived())
.orElseThrow(MemberNotFoundException::new);
} else {
throw new InvalidInputException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public List<ApprovedMemberSummaryDto> getAllApprovedMembersBySearchAndRole(Strin
.map(
member ->
ApprovedMemberSummaryDto.builder()
.id(member.getId())
.name(member.getName())
.studentId(member.getStudentId())
.memberType(member.getSchoolInformation().getMemberType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void createOutcomeHistoryTest() {
.dateUsed(LocalDateTime.now())
.title("title")
.details("details")
.memberIdReceived(1L)
.memberStudentIdReceived("12171707")
.memberNameReceived("조승현")
.income(0)
Expand All @@ -125,7 +126,7 @@ public void createOutcomeHistoryTest() {
.build();

given(memberRepository.findById(any())).willReturn(Optional.of(secretary));
given(memberRepository.findByStudentId_IdAndName_Value(any(), any()))
given(memberRepository.findByIdAndStudentId_IdAndName_Value(any(), any(), any()))
.willReturn(Optional.of(memberReceived));
given(menuRepository.findById(anyInt())).willReturn(Optional.of(menu));
given(boardFileRepository.getAllByIdInAndUploader(anyList(), any())).willReturn(List.of(file));
Expand Down Expand Up @@ -153,6 +154,7 @@ public void modifyHistoryTest() {
LocalDateTime.now().minusDays(1L),
"title",
"details",
1L,
"12171234",
"유동현",
0,
Expand All @@ -173,7 +175,7 @@ public void modifyHistoryTest() {
.writtenBy(secretary, BudgetHistory.class);
ReflectionTestUtils.setField(budgetHistory, "id", 1L);
given(memberRepository.findById(any())).willReturn(Optional.of(secretary));
given(memberRepository.findByStudentId_IdAndName_Value(any(), any()))
given(memberRepository.findByIdAndStudentId_IdAndName_Value(any(), any(), any()))
.willReturn(Optional.of(memberReceived));
given(budgetHistoryRepository.findById(any())).willReturn(Optional.of(budgetHistory));
given(boardFileRepository.getAllByIdInAndUploader(anyList(), any())).willReturn(List.of(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void getAllNotGraduatedMembers() throws Exception {
// given
List<ApprovedMemberSummaryDto> dtoList = new ArrayList<>();
ApprovedMemberSummaryDto dto1 =
new ApprovedMemberSummaryDto("홍길동", "12171707", UNDERGRADUATE, 1, "컴퓨터공학과");
new ApprovedMemberSummaryDto(1L, "홍길동", "12171707", UNDERGRADUATE, 1, "컴퓨터공학과");
dtoList.add(dto1);

given(memberManageService.getAllApprovedMembersBySearchAndRole(any())).willReturn(dtoList);
Expand Down
Loading