Skip to content

Commit

Permalink
[feat] 지원서 엑셀 파일 생성 시각 API 구현 (#107)
Browse files Browse the repository at this point in the history
* [chore] 지원서 엑셀 파일 생성 시각 API

* [test] 지원서 엑셀 파일 생성 시각 API (#105)
  • Loading branch information
yourzinc authored Jul 22, 2023
1 parent e7afc29 commit 69960d3
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,11 @@ public ResponseEntity<FileSystemResource> getApplicationExcel() {
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(resource);
}

@Operation(summary = "지원서 엑셀 파일 생성 시각 확인")
@GetMapping(value = "/file/creationtime")
public GetCreationTime getApplicationExcelCreationTime() {
log.info("지원서 엑셀 파일 생성 시각 확인");
return applicationExcelService.getApplicationExcelCreationTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,13 @@ public void createApplicationExcelFile() throws IOException {
// 워크북 및 자원 해제
workbook.close();
}

@Transactional(readOnly = true)
public GetCreationTime getApplicationExcelCreationTime() {
Recruitment recruitment = recruitmentRepository.findAll().get(0);
LocalDateTime applicationExcelCreatedAt = recruitment.getApplicationExcelCreatedAt();

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
return GetCreationTime.from(applicationExcelCreatedAt.format(formatter));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ceos.backend.domain.application;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

@SpringBootTest
@AutoConfigureMockMvc
public class ApplicationControllerTest {

@Autowired
private MockMvc mockMvc;

@DisplayName("지원서 엑셀 파일 생성 시각 API - 권한 X")
@Test
void getApplicationExcelCreationTime() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/applications/file/creationtime"))
.andExpect(MockMvcResultMatchers.status().is(401));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ceos.backend.domain.application;

import ceos.backend.domain.application.dto.response.GetCreationTime;
import ceos.backend.domain.application.service.ApplicationExcelService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class ApplicationExcelServiceTest {

@Autowired
ApplicationExcelService applicationExcelService;

@DisplayName("지원서 엑셀 파일 생성 시각")
@Test
public void getApplicationExcelCreationTime() throws Exception {
GetCreationTime creationTime = applicationExcelService.getApplicationExcelCreationTime();
Assertions.assertThat(creationTime.getCreateAt().charAt(4)).isEqualTo('-');
Assertions.assertThat(creationTime.getCreateAt().charAt(7)).isEqualTo('-');
}
}

This file was deleted.

0 comments on commit 69960d3

Please sign in to comment.