-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from PawWithU/feat/56-get-applications-api
[Feature] 이동봉사자 봉사 관리 - 승인 대기중, 진행중 목록 조회 API 구현
- Loading branch information
Showing
9 changed files
with
248 additions
and
6 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
14 changes: 14 additions & 0 deletions
14
...m/pawwithu/connectdog/domain/application/dto/response/ApplicationProgressingResponse.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.pawwithu.connectdog.domain.application.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record ApplicationProgressingResponse(String mainImage, String departureLoc, String arrivalLoc, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate startDate, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate endDate, | ||
String intermediaryName, | ||
Boolean isKennel) { | ||
} |
15 changes: 15 additions & 0 deletions
15
...a/com/pawwithu/connectdog/domain/application/dto/response/ApplicationWaitingResponse.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.pawwithu.connectdog.domain.application.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record ApplicationWaitingResponse(String mainImage, String departureLoc, String arrivalLoc, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate startDate, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate endDate, | ||
String intermediaryName, | ||
Boolean isKennel, | ||
Long applicationId) { | ||
} |
13 changes: 13 additions & 0 deletions
13
...va/com/pawwithu/connectdog/domain/application/repository/CustomApplicationRepository.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.pawwithu.connectdog.domain.application.repository; | ||
|
||
import com.pawwithu.connectdog.domain.application.dto.response.ApplicationProgressingResponse; | ||
import com.pawwithu.connectdog.domain.application.dto.response.ApplicationWaitingResponse; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.util.List; | ||
|
||
public interface CustomApplicationRepository { | ||
|
||
List<ApplicationWaitingResponse> getWaitingApplications(Long volunteerId, Pageable pageable); | ||
List<ApplicationProgressingResponse> getProgressingApplications(Long volunteerId, Pageable pageable); | ||
} |
63 changes: 63 additions & 0 deletions
63
...wwithu/connectdog/domain/application/repository/impl/CustomApplicationRepositoryImpl.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.pawwithu.connectdog.domain.application.repository.impl; | ||
|
||
import com.pawwithu.connectdog.domain.application.dto.response.ApplicationProgressingResponse; | ||
import com.pawwithu.connectdog.domain.application.dto.response.ApplicationWaitingResponse; | ||
import com.pawwithu.connectdog.domain.application.entity.ApplicationStatus; | ||
import com.pawwithu.connectdog.domain.application.repository.CustomApplicationRepository; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
import static com.pawwithu.connectdog.domain.application.entity.QApplication.application; | ||
import static com.pawwithu.connectdog.domain.intermediary.entity.QIntermediary.intermediary; | ||
import static com.pawwithu.connectdog.domain.post.entity.QPost.post; | ||
import static com.pawwithu.connectdog.domain.post.entity.QPostImage.postImage; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class CustomApplicationRepositoryImpl implements CustomApplicationRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<ApplicationWaitingResponse> getWaitingApplications(Long volunteerId, Pageable pageable) { | ||
return queryFactory | ||
.select(Projections.constructor(ApplicationWaitingResponse.class, | ||
postImage.image, post.departureLoc, post.arrivalLoc, post.startDate, post.endDate, | ||
intermediary.name, post.isKennel, application.id)) | ||
.from(application) | ||
.join(application.post, post) | ||
.join(application.post.intermediary, intermediary) | ||
.join(application.post.mainImage, postImage) | ||
.where(application.status.eq(ApplicationStatus.WAITING) | ||
.and(application.volunteer.id.eq(volunteerId))) | ||
.orderBy(application.createdDate.desc()) | ||
.offset(pageable.getOffset()) // 페이지 번호 | ||
.limit(pageable.getPageSize()) // 페이지 사이즈 | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<ApplicationProgressingResponse> getProgressingApplications(Long volunteerId, Pageable pageable) { | ||
return queryFactory | ||
.select(Projections.constructor(ApplicationProgressingResponse.class, | ||
postImage.image, post.departureLoc, post.arrivalLoc, post.startDate, post.endDate, | ||
intermediary.name, post.isKennel)) | ||
.from(application) | ||
.join(application.post, post) | ||
.join(application.post.intermediary, intermediary) | ||
.join(application.post.mainImage, postImage) | ||
.where(application.status.eq(ApplicationStatus.PROGRESSING) | ||
.and(application.volunteer.id.eq(volunteerId))) | ||
.orderBy(application.createdDate.desc()) | ||
.offset(pageable.getOffset()) // 페이지 번호 | ||
.limit(pageable.getPageSize()) // 페이지 사이즈 | ||
.fetch(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- INSERT INTERMEDIARY | ||
INSERT INTO intermediary (id, email, password, name, url, auth_image, profile_image, intro, contact, role, is_option_agr, notification, created_date, modified_date) VALUES (1, '[email protected]', '{bcrypt}$2a$10$Llg2MwZS/oOv/2/ozaice.49CU35kK6W9kYEb.oqyTy6vmh7E4yv2', '한호정', 'https://connectdog.site', 'authImageUrl', 'profileImageUrl', '안녕하세요.', '인스타그램: @hoxjeong', 'AUTH_INTERMEDIARY', false, false, now(), now()); | ||
-- INSERT VOLUNTEER | ||
INSERT INTO volunteer (id, email, password, nickname, profile_image_num, name, phone, role, is_option_agr, notification, created_date, modified_date) VALUES (1, '[email protected]', '{bcrypt}$2a$10$VieltvcRaI/rJnaRHuRPju9rqM9BvmKRkmn./oOninx7fOGT/q2De', '봉사자하노정', 1, '한호정', '01022223333', 'AUTH_VOLUNTEER', false, false, now(), now()); | ||
-- INSERT DOG | ||
INSERT INTO dog (id, name, size, gender, weight, specifics, created_date, modified_date) VALUES (1, '포포', 0, 1, 4.6, '밥을 잘 먹음', now(), now()); | ||
INSERT INTO dog (id, name, size, gender, weight, specifics, created_date, modified_date) VALUES (2, '남2포포', 1, 0, 4.6, '밥을 잘 먹음', now(), now()); | ||
INSERT INTO dog (id, name, size, gender, weight, specifics, created_date, modified_date) VALUES (3, '여3포포', 2, 1, 4.6, '밥을 잘 먹음', now(), now()); | ||
INSERT INTO dog (id, name, size, gender, weight, specifics, created_date, modified_date) VALUES (4, '여4포포', 2, 1, 4.6, '밥을 잘 먹음', now(), now()); | ||
INSERT INTO dog (id, name, size, gender, weight, specifics, created_date, modified_date) VALUES (5, '남5포포', 1, 0, 4.6, '밥을 잘 먹음', now(), now()); | ||
-- INSERT POST | ||
INSERT INTO post (id, status, departure_loc, arrival_loc, start_date, end_date, pick_up_time, is_kennel, content, intermediary_id, dog_id, created_date, modified_date) VALUES (1, 0, '서울시 성북구', '경기 고양시', '2023-11-13', '2023-11-25', '13:00', false, '이동봉사 공고입니다.', 1, 1, now(), now()); | ||
INSERT INTO post (id, status, departure_loc, arrival_loc, start_date, end_date, pick_up_time, is_kennel, content, intermediary_id, dog_id, created_date, modified_date) VALUES (2, 0, '서울시 성북구', '경기 고양시', '2023-11-13', '2023-11-25', '13:00', false, '이동봉사 공고입니다.', 1, 2, now(), now()); | ||
INSERT INTO post (id, status, departure_loc, arrival_loc, start_date, end_date, pick_up_time, is_kennel, content, intermediary_id, dog_id, created_date, modified_date) VALUES (3, 1, '서울시 성북구', '경기 고양시', '2023-11-13', '2023-11-25', '13:00', false, '이동봉사 공고입니다.', 1, 3, now(), now()); | ||
INSERT INTO post (id, status, departure_loc, arrival_loc, start_date, end_date, pick_up_time, is_kennel, content, intermediary_id, dog_id, created_date, modified_date) VALUES (4, 2, '서울시 성북구', '경기 고양시', '2023-11-13', '2023-11-25', '13:00', false, '이동봉사 공고입니다.', 1, 4, now(), now()); | ||
INSERT INTO post (id, status, departure_loc, arrival_loc, start_date, end_date, pick_up_time, is_kennel, content, intermediary_id, dog_id, created_date, modified_date) VALUES (5, 3, '서울시 성북구', '경기 고양시', '2023-11-13', '2023-11-25', '13:00', false, '이동봉사 공고입니다.', 1, 5, now(), now()); | ||
-- INSERT POST_IMAGE | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (1, 'image1', 1, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (2, 'image2', 1, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (3, 'image3', 1, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (4, 'image1', 2, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (5, 'image2', 2, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (6, 'image1', 3, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (7, 'image2', 3, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (8, 'image1', 4, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (9, 'image2', 4, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (10, 'image1', 5, now(), now()); | ||
INSERT INTO post_image (id, image, post_id, created_date, modified_date) VALUES (11, 'image2', 5, now(), now()); | ||
-- UPDATE POST MAIN IMAGE | ||
UPDATE post SET main_image_id = 1 WHERE id = 1; | ||
UPDATE post SET main_image_id = 4 WHERE id = 2; | ||
UPDATE post SET main_image_id = 6 WHERE id = 3; | ||
UPDATE post SET main_image_id = 8 WHERE id = 4; | ||
UPDATE post SET main_image_id = 10 WHERE id = 5; | ||
-- INSERT APPLICATION | ||
INSERT INTO application (id, status, volunteer_name, phone, transportation, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (1, 0, '한호정', '01022223333', 'BMW', '이동봉사 신청합니다!', 3, 1, 1,now(), now()); | ||
INSERT INTO application (id, status, volunteer_name, phone, transportation, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (2, 1, '한호정', '01022223333', 'BMW', '이동봉사 신청합니다!', 4, 1, 1,now(), now()); | ||
INSERT INTO application (id, status, volunteer_name, phone, transportation, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (3, 2, '한호정', '01022223333', 'BMW', '이동봉사 신청합니다!', 5, 1, 1,now(), now()); |
Oops, something went wrong.