-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WHD-291] Feat: inquiry list by category
- Loading branch information
Showing
8 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/woohakdong/server/domain/inquiry/InquiryJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package woohakdong.server.domain.inquiry; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import woohakdong.server.domain.member.Member; | ||
|
||
import java.util.List; | ||
|
||
public interface InquiryJpaRepository extends JpaRepository<Inquiry, Long> { | ||
List<Inquiry> findByMember(Member member); | ||
|
||
@Query("SELECT i FROM Inquiry i " + | ||
"WHERE (:category IS NULL OR i.inquiryCategory = :category) " + | ||
"ORDER BY i.createdAt DESC") | ||
List<Inquiry> findByCategoryOrderByCreatedAtDesc(@Param("category") InquiryCategory category); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,17 @@ | |
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import woohakdong.server.api.controller.admin.overall.dto.ClubListResponse; | ||
import woohakdong.server.api.controller.admin.overall.dto.ClubPaymentResponse; | ||
import woohakdong.server.api.controller.admin.overall.dto.CountResponse; | ||
import woohakdong.server.api.controller.admin.overall.dto.SchoolListResponse; | ||
import woohakdong.server.api.controller.admin.overall.dto.*; | ||
import woohakdong.server.domain.club.Club; | ||
import woohakdong.server.domain.club.ClubRepository; | ||
import woohakdong.server.domain.clubHistory.ClubHistory; | ||
import woohakdong.server.domain.clubHistory.ClubHistoryRepository; | ||
import woohakdong.server.domain.clubmember.ClubMember; | ||
import woohakdong.server.domain.clubmember.ClubMemberRepository; | ||
import woohakdong.server.domain.clubmember.ClubMemberRole; | ||
import woohakdong.server.domain.inquiry.Inquiry; | ||
import woohakdong.server.domain.inquiry.InquiryCategory; | ||
import woohakdong.server.domain.inquiry.InquiryRepository; | ||
import woohakdong.server.domain.member.Member; | ||
import woohakdong.server.domain.member.MemberRepository; | ||
import woohakdong.server.domain.school.School; | ||
|
@@ -53,6 +53,9 @@ class AdminOverallServiceTest { | |
@Autowired | ||
private ClubHistoryRepository clubHistoryRepository; | ||
|
||
@Autowired | ||
private InquiryRepository inquiryRepository; | ||
|
||
@BeforeEach | ||
void setup() { | ||
// 초기 데이터 삽입 예시 | ||
|
@@ -208,6 +211,22 @@ void getClubPaymentWithAssignedTerm() { | |
assertThat(response.clubPayment()).isEqualTo(30000 + (2 * 500) + 30500); | ||
} | ||
|
||
@Test | ||
void findByCategoryOrderByCreatedAtDesc() { | ||
// Given | ||
School school = createSchool("ajou.ac.kr"); | ||
Member member1 = createMember(school, "testProvideId2", "박상준", "[email protected]"); | ||
Inquiry inquiry1 = Inquiry.create("Content1", InquiryCategory.INQUIRY, member1); | ||
Inquiry inquiry2 = Inquiry.create("Content2", InquiryCategory.ETC, member1); | ||
inquiryRepository.save(inquiry1); | ||
inquiryRepository.save(inquiry2); | ||
|
||
// When | ||
List<InquiryListResponse> result = adminOverallService.getInquiry("INQUIRY"); | ||
|
||
// Then | ||
assertThat(result.get(0).inquiryContent()).isEqualTo("Content1"); | ||
} | ||
|
||
private Club createClub(School school1, String name, String englishName) { | ||
Club club = Club.builder() | ||
|
@@ -258,4 +277,13 @@ private ClubHistory createClubHistory(Club club, LocalDate date) { | |
ClubHistory clubHistory = ClubHistory.create(club, date); | ||
return clubHistoryRepository.save(clubHistory); | ||
} | ||
|
||
private School createSchool(String domain) { | ||
School school = School.builder() | ||
.schoolDomain(domain) | ||
.schoolName("아주대학교") | ||
.build(); | ||
return schoolRepository.save(school); | ||
} | ||
|
||
} |