Skip to content
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 @@ -3,7 +3,7 @@
public final class ApiConstants {
public static final String SOLVED_AC_PROBLEM_API_URL = "https://solved.ac/api/v3/problem/lookup?problemIds=";
public static final String BOJ_USER_PROFILE_URL = "https://www.acmicpc.net/user/";
public static final String BOJ_PROBLEM_URL = "www.acmicpc.net";
public static final String BOJ_URL = "www.acmicpc.net";
public static final String SERVER_HTTPS_ENDPOINT = "https://api.algohub.kr";
public static final String RC_SERVER_HTTPS_ENDPOINT = "https://api.rc.algohub.kr";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class EdgeCase {
@JoinColumn(name = "user_id")
private User author;

private LocalDateTime createdAt;
private LocalDateTime deletedAt;

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
import com.gamzabat.algohub.feature.edgecase.domain.EdgeCase;

public interface EdgeCaseRepository extends JpaRepository<EdgeCase, Long> {
List<EdgeCase> findAllByProblemNumber(Integer number);
List<EdgeCase> findAllByProblemNumberOrderByCreatedAtDesc(Integer problemNumber);
List<EdgeCase> findAllByOrderByCreatedAtDesc();
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ private void saveEdgeCase(User author, CreateEdgeCaseRequest request, int level,
public GetEdgeCaseListResponse getEdgeCaseList(Integer problemNumber) {
List<EdgeCase> edgeCaseList;
if (problemNumber == null)
edgeCaseList = edgeCaseRepository.findAll();
edgeCaseList = edgeCaseRepository.findAllByOrderByCreatedAtDesc();
else
edgeCaseList = edgeCaseRepository.findAllByProblemNumber(problemNumber);
edgeCaseList = edgeCaseRepository.findAllByProblemNumberOrderByCreatedAtDesc(problemNumber);

List<GetEdgeCaseResponse> responseList = edgeCaseList.stream()
.map(edgeCase -> new GetEdgeCaseResponse(
Expand Down Expand Up @@ -111,8 +111,9 @@ public TogleEdgeCaseResponse togleEdgeCaseLike(User user, Long edgeCaseId) {

private String getProblemId(String url) {
String[] parts = url.split("/");
if (parts.length < 3 || !parts[2].equals(BOJ_PROBLEM_URL))
if (parts.length < 3 || !parts[2].equals(BOJ_URL))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 단순 궁금증인데, parts.length < 3 을 해준 이유가 url 형식 때문인 걸까요? 기존 url 형식이 어떤 형식인지 궁금해요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네
기존 URL형식이 https://www.acmicpc.net/problem/1000 처럼 들어와서 https://www.acmicpc.net 이 부분까지 있는지 확인하고 백준 url이 맞는지 확인하는 부분입니다 !.!

throw new NotBojLinkException(HttpStatus.BAD_REQUEST.value(), "백준 링크가 아닙니다");
return parts[parts.length - 1];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public String getProblemTitle(JsonNode problemDetails) {
private String getProblemId(CreateProblemRequest request) {
String url = request.link();
String[] parts = url.split("/");
if (parts.length < 3 || !parts[2].equals(BOJ_PROBLEM_URL))
if (parts.length < 3 || !parts[2].equals(BOJ_URL))
throw new NotBojLinkException(HttpStatus.BAD_REQUEST.value(), "백준 링크가 아닙니다");
return parts[parts.length - 1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void getEdgeCaseListSuccess_1() {
//given
Integer problemNumber = 1001;
List<EdgeCase> edgeCaseList = Arrays.asList(edgeCase1, edgeCase2);
when(edgeCaseRepository.findAllByProblemNumber(problemNumber))
when(edgeCaseRepository.findAllByProblemNumberOrderByCreatedAtDesc(problemNumber))
.thenReturn(edgeCaseList);

//when
Expand Down Expand Up @@ -186,7 +186,7 @@ void getEdgeCaseListSuccess_2() {
// given
Integer problemNumber = null;
List<EdgeCase> edgeCaseList = Arrays.asList(edgeCase1, edgeCase2, edgeCase3);
when(edgeCaseRepository.findAll())
when(edgeCaseRepository.findAllByOrderByCreatedAtDesc())
.thenReturn(edgeCaseList);
// when
GetEdgeCaseListResponse response = edgeCaseService.getEdgeCaseList(problemNumber);
Expand Down
Loading