Skip to content
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

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build/
gg-pingpong-api/src/main/resources/application.yml
.DS_Store
python
/logs
**/logs


### STS ###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Copy link
Member

Choose a reason for hiding this comment

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

checkstyle์— ๊ฑธ๋ฆด ๊ฒƒ ๊ฐ™์•„์šฉ setter ์•ˆ ์“ฐ๋Š” ๊ฑฐ ๊ฐ™์€๋ฐ??

Copy link
Member

Choose a reason for hiding this comment

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

๊ทธ๋ฆฌ๊ณ  ์ €ํฌ ์ด์ œ ๋ฐ”๋กœ dev์— ๋จธ์ง€ํ•˜๋‚˜์šฉ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setter ์™œ checkstyle ์•ˆ๊ฑธ๋ ธ์„๊นŒ์š”,, ์ด์ œ dev๋ฐ”๋กœ ๋จธ์ง€ํ•ด๋„ ๋ ๊ฑฐ๊ฐ™์•„์„œ ๋นจ๋ฆฌ๋นจ๋ฆฌ ์ง„ํ–‰ํ•˜๋ ค๊ณ  dev์—๋‹ค๊ฐ€ ํ–ˆ์Šต๋‹ˆ๋‹น


@Entity
@Getter
Expand Down Expand Up @@ -56,4 +57,8 @@ public void del() {
public Boolean isEnd() {
return LocalDateTime.now().isAfter(this.endTime);
}

public void setFinish(Boolean finish) {
this.isFinish = finish;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public GroupedOpenApi recruitGroup() {
public GroupedOpenApi recruitAdminGroup() {
return GroupedOpenApi.builder()
.group("recruit admin")
.pathsToMatch("admin/recruitments/**")
.pathsToMatch("/admin/recruitments/**")
.packagesToScan("gg.recruit.api.admin")
.build();
}
Expand Down
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;
}
Copy link
Member

Choose a reason for hiding this comment

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

ํ˜น์‹œ ์–ด์ œ ๋ง์”€ํ•˜์…จ๋˜ ํ…Œ์ŠคํŠธ fail ์ด๋ถ€๋ถ„ ๊ณ ์น˜์‹  ๊ฑด๊ฐ€์š”??
์ €๋Š” application API 3๊ฐœ๊ฐ€ fail ๋–ด๊ฑฐ๋“ ์š”..ใ… ..ใ… 

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Up @@ -87,7 +87,7 @@ public ResponseEntity<Void> updateApplication(@Login @Parameter(hidden = true) U
@DeleteMapping("/{recruitmentId}/applications/{applicationId}")
public ResponseEntity<Void> cancelApplication(@Login @Parameter(hidden = true) UserDto userDto,
@PathVariable Long recruitmentId, @PathVariable Long applicationId) {
applicationService.deleteApplication(new DelApplicationParam(userDto.getId(), recruitmentId, applicationId));
applicationService.deleteApplication(new DelApplicationParam(userDto.getId(), applicationId, recruitmentId));
return ResponseEntity.noContent().build();
}
}
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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
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.test.annotation.Rollback;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Loading