-
Notifications
You must be signed in to change notification settings - Fork 2
[REFACTOR/#233] 성주 리팩토링 #241
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d10b543
[Refactor/#233]
sjhwang0 5b79b41
[Refactor/#233]
sjhwang0 944fe70
[Refactor/#233]
sjhwang0 cdccff2
[Refactor/#233]
sjhwang0 caea635
[Refactor/#233]
sjhwang0 5a19cb4
[Refactor/#233]
sjhwang0 245a31c
Merge branch 'develop' into refactor/#233-sjhwang-refactoring
BAEK0111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
4 changes: 0 additions & 4 deletions
4
src/main/java/com/assu/server/domain/admin/converter/AdminConverter.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/assu/server/domain/admin/dto/AdminRequestDTO.java
This file was deleted.
Oops, something went wrong.
51 changes: 33 additions & 18 deletions
51
src/main/java/com/assu/server/domain/admin/dto/AdminResponseDTO.java
This file contains hidden or 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,22 +1,37 @@ | ||
| package com.assu.server.domain.admin.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| public class AdminResponseDTO { | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public static class RandomPartnerResponseDTO { | ||
| private Long partnerId; | ||
| private String partnerAddress; | ||
| private String partnerDetailAddress; | ||
| private String partnerName; | ||
| private String partnerUrl; | ||
| private String partnerPhone; | ||
| import com.assu.server.domain.partner.entity.Partner; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record AdminResponseDTO ( | ||
| @Schema(description = "제휴업체 ID", example = "101") | ||
| @NotNull Long partnerId, | ||
|
|
||
| @Schema(description = "제휴업체 이름", example = "역전할머니 맥주 숭실대점") | ||
| @NotNull String partnerName, | ||
|
|
||
| @Schema(description = "제휴업체 주소", example = "서울특별시 동작구") | ||
| @NotNull String partnerAddress, | ||
|
|
||
| @Schema(description = "제휴업체 상세주소", example = "2층 201호") | ||
| String partnerDetailAddress, | ||
|
|
||
| @Schema(description = "제휴업체 URL", example = "https://www.beer.co.kr") | ||
| String partnerUrl, | ||
|
|
||
| @Schema(description = "제휴업체 전화번호", example = "02-123-4567") | ||
| String partnerPhone | ||
| ) { | ||
| public static AdminResponseDTO from(Partner partner) { | ||
| return new AdminResponseDTO( | ||
| partner.getId(), | ||
| partner.getName(), | ||
| partner.getAddress(), | ||
| partner.getDetailAddress(), | ||
| partner.getMember() != null ? partner.getMember().getProfileUrl() : null, | ||
| partner.getMember() != null ? partner.getMember().getPhoneNum() : null | ||
| ); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,24 +4,25 @@ | |
| import java.util.Optional; | ||
|
|
||
| import com.assu.server.domain.admin.entity.Admin; | ||
| import com.assu.server.domain.common.enums.ActivationStatus; | ||
| import com.assu.server.domain.member.entity.Member; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import com.assu.server.domain.admin.entity.Admin; | ||
| import com.assu.server.domain.user.entity.enums.Department; | ||
| import com.assu.server.domain.user.entity.enums.Major; | ||
| import com.assu.server.domain.user.entity.enums.University; | ||
|
|
||
| public interface AdminRepository extends JpaRepository<Admin, Long> { | ||
|
|
||
| // 여기 예원이 머지하고 수정 | ||
| @Query("SELECT a FROM Admin a WHERE " + | ||
| "(a.university = :university AND a.department IS NULL AND a.major IS NULL) OR " + | ||
| "(a.university = :university AND a.department = :department AND a.major IS NULL) OR " + | ||
| "(a.university = :university AND a.department = :department AND a.major = :major)") | ||
| @Query(""" | ||
| SELECT a FROM Admin a | ||
| WHERE a.university = :university | ||
| AND ( | ||
| (a.department IS NULL AND a.major IS NULL) OR | ||
| (a.department = :department AND a.major IS NULL) OR | ||
| (a.department = :department AND a.major = :major) | ||
| ) | ||
| """) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 쿼리들이 인덱스가 필요한 경우가 많이 보입니다. 잊지말고 추후 개선사항에 인덱스까지 적용해서 레포지토리 쿼리를 보강합시다 |
||
| List<Admin> findMatchingAdmins(@Param("university") University university, | ||
| @Param("department") Department department, | ||
| @Param("major") Major major); | ||
|
|
@@ -32,47 +33,47 @@ List<Admin> findMatchingAdmins(@Param("university") University university, | |
| @Query(value = """ | ||
| SELECT COUNT(*) | ||
| FROM admin a | ||
| LEFT JOIN paper pa | ||
| ON pa.admin_id = a.id | ||
| AND pa.partner_id = :partnerId | ||
| AND pa.is_activated = 'ACTIVE' | ||
| WHERE pa.id IS NULL | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM paper pa | ||
| WHERE pa.admin_id = a.id | ||
| AND pa.partner_id = :partnerId | ||
| AND pa.is_activated = 'ACTIVE' | ||
| ) | ||
| """, nativeQuery = true) | ||
| long countPartner(@Param("partnerId") Long partnerId); | ||
|
|
||
| // 랜덤 오프셋으로 1~N건 가져오기 (LIMIT :offset, :limit) | ||
| @Query(value = """ | ||
| SELECT a.* | ||
| FROM admin a | ||
| LEFT JOIN paper pa | ||
| ON pa.admin_id = a.id | ||
| AND pa.partner_id = :partnerId | ||
| AND pa.is_activated = 'ACTIVE' | ||
| WHERE pa.id IS NULL | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM paper pa | ||
| WHERE pa.admin_id = a.id | ||
| AND pa.partner_id = :partnerId | ||
| AND pa.is_activated = 'ACTIVE' | ||
| ) | ||
| LIMIT :offset, :limit | ||
| """, nativeQuery = true) | ||
| List<Admin> findPartnerWithOffset(@Param("partnerId") Long partnerId, | ||
| @Param("offset") int offset, | ||
| @Param("limit") int limit); | ||
| @Param("offset") int offset, | ||
| @Param("limit") int limit); | ||
|
|
||
| @Query(value = """ | ||
| SELECT a.* | ||
| FROM admin a | ||
| @Query(""" | ||
| SELECT DISTINCT a | ||
| FROM Admin a | ||
| LEFT JOIN FETCH a.member | ||
| WHERE a.point IS NOT NULL | ||
| AND ST_Contains(ST_GeomFromText(:wkt, 4326), a.point) | ||
| """, nativeQuery = true) | ||
| List<Admin> findAllWithinViewport(@Param("wkt") String wkt); | ||
| AND function('ST_Contains', function('ST_GeomFromText', :wkt, 4326), a.point) = true | ||
| """) | ||
| List<Admin> findAllWithinViewportWithMember(@Param("wkt") String wkt); | ||
|
|
||
| @Query(""" | ||
| select distinct a | ||
| from Admin a | ||
| where lower(a.name) like lower(concat('%', :keyword, '%')) | ||
| SELECT DISTINCT a | ||
| FROM Admin a | ||
| LEFT JOIN FETCH a.member | ||
| WHERE LOWER(a.name) LIKE LOWER(CONCAT('%', :keyword, '%')) | ||
| """) | ||
| List<Admin> searchAdminByKeyword( | ||
| List<Admin> searchAdminByKeywordWithMember( | ||
| @Param("keyword") String keyword | ||
| ); | ||
|
|
||
| Long member(Member member); | ||
|
|
||
| Optional<Admin> findById(Long id); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.