Skip to content

Commit

Permalink
Merge pull request #472 from SWM-NM/feat/#471
Browse files Browse the repository at this point in the history
♻️ [REFACTOR] 제출 API 수정 #471
  • Loading branch information
miiiinju1 authored Oct 18, 2023
2 parents 4f43b32 + 9b5faff commit 52e73be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
@RequiredArgsConstructor
@Getter
public enum SubmitConstants {
JAVA("93"),
C_PLUSPLUS("84"),
PYTHON("28"),
PYPY3("73"),
Java("93"),
Cpp("84"),
Python("28"),
Pypy3("73"),
C99("0"),
RUBY("68"),
Ruby("68"),
KOTLIN("69"),
SWIFT("74"),
TEXT("58"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Getter
@Setter
public class SubmitCodeDto {
public String problemId;
public String bojProblemId;
public String language;
public String sourceCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public String getCSRFKey(String cookie, String problemId) {

}
//POST로 보낼 때 필요한 파라미터들을 생성
private MultiValueMap<String, String> createParameters(SubmitCodeDto submitCodeDto, String CSRFKey, String problemId) {
private MultiValueMap<String, String> createParameters(SubmitCodeDto submitCodeDto, String CSRFKey, String bojProblemId) {
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.add("problem_id", problemId);
parameters.add("problem_id", bojProblemId);
parameters.add("language", submitCodeDto.getLanguageId());
parameters.add("code_open", CodeVisuabilityConstants.CLOSE.getCodeVisuability());
parameters.add("source", submitCodeDto.getSourceCode());
Expand All @@ -118,16 +118,16 @@ public ResponseEntity<String> submit(SubmitCodeDto submitCodeDto) {
String cookie = Optional.ofNullable((String) redisTemplate.opsForValue().get(key))
.orElseThrow(() -> new MorandiException(SubmitErrorCode.COOKIE_NOT_EXIST));

String problemId = submitCodeDto.getProblemId();
String bojProblemId = submitCodeDto.getBojProblemId();

String CSRFKey = getCSRFKey(cookie, problemId);
String CSRFKey = getCSRFKey(cookie, bojProblemId);

String acmicpcUrl = "https://www.acmicpc.net/submit/" + problemId;
String acmicpcUrl = "https://www.acmicpc.net/submit/" + bojProblemId;

HttpHeaders headers = createHeaders(cookie);
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

MultiValueMap<String, String> parameters = createParameters(submitCodeDto, CSRFKey, problemId);
MultiValueMap<String, String> parameters = createParameters(submitCodeDto, CSRFKey, bojProblemId);

HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(parameters, headers);

Expand Down

0 comments on commit 52e73be

Please sign in to comment.