-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] recruit status change api (#781)
- Loading branch information
Showing
10 changed files
with
147 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ build/ | |
gg-pingpong-api/src/main/resources/application.yml | ||
.DS_Store | ||
python | ||
/logs | ||
**/logs | ||
|
||
|
||
### STS ### | ||
|
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
29 changes: 29 additions & 0 deletions
29
gg-recruit-api/src/main/java/gg/recruit/api/admin/controller/AdminRecruitmentController.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,29 @@ | ||
package gg.recruit.api.admin.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.recruit.api.admin.controller.request.UpdateStatusRequestDto; | ||
import gg.recruit.api.admin.service.AdminRecruitmentService; | ||
import gg.recruit.api.admin.service.UpdateRecruitStatusParam; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequestMapping("/admin/recruitments") | ||
@RequiredArgsConstructor | ||
public class AdminRecruitmentController { | ||
private final AdminRecruitmentService adminRecruitmentService; | ||
|
||
@PatchMapping("/{recruitId}/status") | ||
public ResponseEntity<Void> updateRecruitStatus(@PathVariable Long recruitId, | ||
@RequestBody UpdateStatusRequestDto requestDto) { | ||
|
||
adminRecruitmentService.updateRecruitStatus( | ||
new UpdateRecruitStatusParam(recruitId, requestDto.getFinish())); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...uit-api/src/main/java/gg/recruit/api/admin/controller/request/UpdateStatusRequestDto.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,12 @@ | ||
package gg.recruit.api.admin.controller.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UpdateStatusRequestDto { | ||
private Boolean finish; | ||
} |
22 changes: 22 additions & 0 deletions
22
gg-recruit-api/src/main/java/gg/recruit/api/admin/service/AdminRecruitmentService.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,22 @@ | ||
package gg.recruit.api.admin.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.data.recruit.recruitment.Recruitments; | ||
import gg.repo.recruit.user.recruitment.RecruitmentRepository; | ||
import gg.utils.exception.custom.NotExistException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AdminRecruitmentService { | ||
private final RecruitmentRepository recruitmentRepository; | ||
|
||
@Transactional | ||
public void updateRecruitStatus(UpdateRecruitStatusParam updateRecruitStatusParam) { | ||
Recruitments recruitments = recruitmentRepository.findById(updateRecruitStatusParam.getRecruitId()) | ||
.orElseThrow(() -> new NotExistException("Recruitment not found.")); | ||
recruitments.setFinish(updateRecruitStatusParam.getFinish()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
gg-recruit-api/src/main/java/gg/recruit/api/admin/service/UpdateRecruitStatusParam.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,11 @@ | ||
package gg.recruit.api.admin.service; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public class UpdateRecruitStatusParam { | ||
private Long recruitId; | ||
private Boolean finish; | ||
} |
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
64 changes: 64 additions & 0 deletions
64
...uit-api/src/test/java/gg/recruit/api/admin/controller/AdminRecruitmentControllerTest.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,64 @@ | ||
package gg.recruit.api.admin.controller; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
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.http.MediaType; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import gg.data.recruit.recruitment.Recruitments; | ||
import gg.data.user.User; | ||
import gg.recruit.api.admin.controller.request.UpdateStatusRequestDto; | ||
import gg.recruit.api.user.RecruitMockData; | ||
import gg.repo.recruit.user.recruitment.RecruitmentRepository; | ||
import gg.utils.TestDataUtils; | ||
import gg.utils.annotation.IntegrationTest; | ||
|
||
@IntegrationTest | ||
@Transactional | ||
@AutoConfigureMockMvc | ||
class AdminRecruitmentControllerTest { | ||
@Autowired | ||
private RecruitMockData recruitMockData; | ||
|
||
@Autowired | ||
private TestDataUtils testDataUtils; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@Autowired | ||
private RecruitmentRepository recruitmentRepository; | ||
|
||
@Test | ||
@DisplayName("PATCH /admin/recruitments/{recruitId}/status -> 204 NO CONTENT TEST") | ||
public void updateRecruitStatusTest() throws Exception { | ||
//given | ||
Recruitments recruitments = recruitMockData.createRecruitments(); | ||
UpdateStatusRequestDto requestDto = new UpdateStatusRequestDto(true); | ||
User adminUser = testDataUtils.createAdminUser(); | ||
|
||
//when | ||
mockMvc.perform(patch("/admin/recruitments/{recruitId}/status", recruitments.getId()) | ||
.header("Authorization", "Bearer " + testDataUtils.getLoginAccessTokenFromUser(adminUser)) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(requestDto))) | ||
.andExpect(status().isNoContent()); | ||
|
||
//then | ||
Recruitments updatedRecruitments = recruitmentRepository.findById(recruitments.getId()).get(); | ||
assertTrue(updatedRecruitments.getIsFinish()); | ||
} | ||
|
||
} |
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