Skip to content

Commit 963ad27

Browse files
authored
Merge pull request #44 from parentsgowork/refactor/#43
[#43] Refactor: 북마크 조회 기능
2 parents 51dfca9 + e514e68 commit 963ad27

38 files changed

Lines changed: 570 additions & 673 deletions

src/main/java/com/parentsgowork/server/apiPayload/code/status/ErrorStatus.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum ErrorStatus implements BaseErrorCode {
1717
_FORBIDDEN(HttpStatus.FORBIDDEN, "COMMON403", "금지된 요청입니다."),
1818

1919
//멤버 관련 에러
20-
USER_NOT_FOUND(HttpStatus.UNAUTHORIZED, "USER4001", "이메일 또는 패스워드가 일치하지 않습니다."),
20+
USER_NOT_FOUND(HttpStatus.NOT_FOUND, "USER4001", "회원을 찾을 수 없습니다."),
2121
EMAIL_ALREADY_EXISTS(HttpStatus.CONFLICT, "USER4002", "이미 존재하는 이메일입니다."),
2222
USER_STATUS_INACTIVE(HttpStatus.FORBIDDEN, "USER4003", "탈퇴한 회원입니다."),
2323

@@ -45,18 +45,10 @@ public enum ErrorStatus implements BaseErrorCode {
4545
EMAIL_SEND_FAIL(HttpStatus.INTERNAL_SERVER_ERROR, "AUTH5001", "이메일 전송에 실패했습니다."),
4646
EMAIL_ENCODING_FAIL(HttpStatus.INTERNAL_SERVER_ERROR, "AUTH5002", "이메일 내용 인코딩에 실패했습니다."),
4747

48-
// 크롤링 관련 에러
49-
CRAWLING_DRIVER_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR, "CRAWLING4001", "크롬 드라이버 경로가 설정되지 않았습니다."),
50-
CRAWLING_PAGE_LOAD_FAIL(HttpStatus.INTERNAL_SERVER_ERROR,"CRAWLING4002", "페이지 로딩 중 오류가 발생했습니다."),
51-
CRAWLING_ELEMENT_NOT_FOUND(HttpStatus.NOT_FOUND,"CRAWLING4003", "요소를 찾을 수 없습니다."),
52-
CRAWLING_TIMEOUT(HttpStatus.INTERNAL_SERVER_ERROR,"CRAWLING4004", "페이지 로딩 시간이 초과되었습니다."),
53-
CRAWLING_SESSION_FAIL(HttpStatus.INTERNAL_SERVER_ERROR,"CRAWLING4005", "크롬 드라이버 세션을 시작할 수 없습니다."),
54-
CRAWLING_INVALID_SELECTOR(HttpStatus.BAD_REQUEST,"CRAWLING4006", "유효하지 않은 셀렉터입니다."),
55-
CRAWLING_NO_RESULTS(HttpStatus.NOT_FOUND,"CRAWLING4007", "크롤링 결과가 존재하지 않습니다."),
56-
CRAWLING_UNKNOWN_ERROR(HttpStatus.INTERNAL_SERVER_ERROR,"CRAWLING4008", "알 수 없는 크롤링 오류가 발생했습니다."),
57-
5848
// 북마크 관련 에러
59-
BOOKMARK_NOT_FOUND(HttpStatus.NOT_FOUND, "BOOKMARK4001", "북마크가 존재하지 않습니다.");
49+
EDUCATION_INFO_NOT_FOUND(HttpStatus.NOT_FOUND, "BOOKMARK4001", "북마크한 교육정보가 존재하지 않습니다."),
50+
POLICY_INFO_NOT_FOUND(HttpStatus.NOT_FOUND, "BOOKMARK4002", "북마크한 정책정보가 존재하지 않습니다.");
51+
6052

6153

6254

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.parentsgowork.server.apiPayload.exception;
2+
3+
import com.parentsgowork.server.apiPayload.code.BaseErrorCode;
4+
5+
public class EducationInfoHandler extends GeneralException {
6+
public EducationInfoHandler(BaseErrorCode code) {
7+
super(code);
8+
}
9+
}

src/main/java/com/parentsgowork/server/apiPayload/exception/BookmarkHandler.java renamed to src/main/java/com/parentsgowork/server/apiPayload/exception/PolicyInfoHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.parentsgowork.server.apiPayload.code.BaseErrorCode;
44

5-
public class BookmarkHandler extends GeneralException {
6-
public BookmarkHandler(BaseErrorCode code) {
5+
public class PolicyInfoHandler extends GeneralException {
6+
public PolicyInfoHandler(BaseErrorCode code) {
77
super(code);
88
}
9-
109
}

src/main/java/com/parentsgowork/server/converter/BookmarkConverter.java

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.parentsgowork.server.converter;
2+
3+
import com.parentsgowork.server.domain.EducationInfo;
4+
import com.parentsgowork.server.web.dto.EducationInfoDTO.EducationInfoResponseDTO;
5+
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
9+
public class EducationInfoConverter {
10+
11+
public static List<EducationInfoResponseDTO.EducationInfoListDTO> getEducationInfoListDTO(List<EducationInfo> educationInfos) {
12+
return educationInfos.stream()
13+
.map(education -> EducationInfoResponseDTO.EducationInfoListDTO.builder()
14+
.id(education.getId())
15+
.title(education.getTitle())
16+
.url(education.getUrl())
17+
.build())
18+
.collect(Collectors.toList());
19+
}
20+
21+
public static EducationInfoResponseDTO.EducationInfoDetailDTO getEducationInfoDetailDTO(EducationInfo educationInfo) {
22+
return EducationInfoResponseDTO.EducationInfoDetailDTO.builder()
23+
.id(educationInfo.getId())
24+
.title(educationInfo.getTitle())
25+
.url(educationInfo.getUrl())
26+
.build();
27+
}
28+
29+
30+
public static EducationInfoResponseDTO.DeleteEducationInfoDTO DeleteEducationInfoDTO(EducationInfo educationInfo) {
31+
return EducationInfoResponseDTO.DeleteEducationInfoDTO.builder()
32+
.id(educationInfo.getId())
33+
.message("저장한 교육정보를 삭제하였습니다.")
34+
.build();
35+
}
36+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.parentsgowork.server.converter;
2+
3+
import com.parentsgowork.server.domain.PolicyInfo;
4+
import com.parentsgowork.server.web.dto.PolicyInfoDTO.PolicyInfoResponseDTO;
5+
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
9+
public class PolicyInfoConverter {
10+
public static List<PolicyInfoResponseDTO.PolicyInfoListDTO> getPolicyInfoListDTO(List<PolicyInfo> policyInfos) {
11+
return policyInfos.stream()
12+
.map(policy -> PolicyInfoResponseDTO.PolicyInfoListDTO.builder()
13+
.id(policy.getId())
14+
.title(policy.getTitle())
15+
.url(policy.getUrl())
16+
.build())
17+
.collect(Collectors.toList());
18+
}
19+
20+
public static PolicyInfoResponseDTO.PolicyInfoDetailDTO getPolicyInfoDetailDTO(PolicyInfo policyInfo) {
21+
return PolicyInfoResponseDTO.PolicyInfoDetailDTO.builder()
22+
.id(policyInfo.getId())
23+
.title(policyInfo.getTitle())
24+
.url(policyInfo.getUrl())
25+
.build();
26+
}
27+
28+
29+
public static PolicyInfoResponseDTO.DeletePolicyInfoDTO DeletePolicyInfoDTO(PolicyInfo policyInfo) {
30+
return PolicyInfoResponseDTO.DeletePolicyInfoDTO.builder()
31+
.id(policyInfo.getId())
32+
.message("저장한 정책정보를 삭제하였습니다.")
33+
.build();
34+
}
35+
}

src/main/java/com/parentsgowork/server/crawling/JobInfoCrawling.java

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/main/java/com/parentsgowork/server/repository/BookmarkRepository.java

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.parentsgowork.server.repository;
2+
3+
import com.parentsgowork.server.domain.EducationInfo;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Query;
6+
import org.springframework.data.repository.query.Param;
7+
8+
import java.util.List;
9+
import java.util.Optional;
10+
11+
public interface EducationInfoRepository extends JpaRepository<EducationInfo, Long> {
12+
@Query("SELECT ei FROM EducationInfo ei " +
13+
"WHERE ei. user.id = :userId")
14+
List<EducationInfo> findEducationInfoList(@Param("userId") Long userId);
15+
16+
Optional<EducationInfo> findByIdAndUserId(@Param("educationInfoId") Long educationInfoId, @Param("userId") Long userId);
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.parentsgowork.server.repository;
2+
3+
import com.parentsgowork.server.domain.PolicyInfo;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Query;
6+
import org.springframework.data.repository.query.Param;
7+
8+
import java.util.List;
9+
import java.util.Optional;
10+
11+
public interface PolicyInfoRepository extends JpaRepository<PolicyInfo, Long> {
12+
13+
@Query("SELECT pi FROM PolicyInfo pi " +
14+
"WHERE pi. user.id = :userId")
15+
List<PolicyInfo> findPolicyInfoList(@Param("userId") Long userId);
16+
17+
Optional<PolicyInfo> findByIdAndUserId(@Param("policyInfoId") Long policyInfoId, @Param("userId") Long userId);
18+
}

0 commit comments

Comments
 (0)