-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] recruit status change api #781
Changes from 4 commits
554a8d0
92f8706
2d9d9a4
4d4ab30
20ce835
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 ### | ||
|
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(); | ||
} | ||
} |
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; | ||
} |
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()); | ||
} | ||
} |
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; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํน์ ์ด์ ๋ง์ํ์
จ๋ ํ
์คํธ fail ์ด๋ถ๋ถ ๊ณ ์น์ ๊ฑด๊ฐ์?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ค ์ 3๊ฐ์ง,, ์ 2๊ฐ ๊ณ์ fail๋จ๋๊ฑฐ ์ด๊ฑฐ ๊ณ ์น๋๊น ๋๊ธด ํ๋๋ผ๊ตฌ์ |
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()); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkstyle์ ๊ฑธ๋ฆด ๊ฒ ๊ฐ์์ฉ setter ์ ์ฐ๋ ๊ฑฐ ๊ฐ์๋ฐ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ทธ๋ฆฌ๊ณ ์ ํฌ ์ด์ ๋ฐ๋ก dev์ ๋จธ์งํ๋์ฉ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setter ์ checkstyle ์๊ฑธ๋ ธ์๊น์,, ์ด์ dev๋ฐ๋ก ๋จธ์งํด๋ ๋ ๊ฑฐ๊ฐ์์ ๋นจ๋ฆฌ๋นจ๋ฆฌ ์งํํ๋ ค๊ณ dev์๋ค๊ฐ ํ์ต๋๋น