|
| 1 | +package org.ject.support.domain.recruit.controller; |
| 2 | + |
| 3 | +import io.swagger.v3.oas.annotations.Operation; |
| 4 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 5 | +import jakarta.validation.Valid; |
| 6 | +import lombok.RequiredArgsConstructor; |
| 7 | +import lombok.extern.slf4j.Slf4j; |
| 8 | +import org.ject.support.domain.recruit.domain.Recruit; |
| 9 | +import org.ject.support.domain.recruit.dto.RecruitUpdateRequest; |
| 10 | +import org.ject.support.domain.recruit.dto.RecruitUpdatedEvent; |
| 11 | +import org.ject.support.domain.recruit.exception.RecruitErrorCode; |
| 12 | +import org.ject.support.domain.recruit.exception.RecruitException; |
| 13 | +import org.ject.support.domain.recruit.repository.RecruitRepository; |
| 14 | +import org.springframework.context.ApplicationEventPublisher; |
| 15 | +import org.springframework.context.annotation.Profile; |
| 16 | +import org.springframework.transaction.annotation.Transactional; |
| 17 | +import org.springframework.web.bind.annotation.PathVariable; |
| 18 | +import org.springframework.web.bind.annotation.PutMapping; |
| 19 | +import org.springframework.web.bind.annotation.RequestBody; |
| 20 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 21 | +import org.springframework.web.bind.annotation.RestController; |
| 22 | + |
| 23 | +@Tag(name = "Dev Recruit", description = "개발용 모집 관리 API") |
| 24 | +@Slf4j |
| 25 | +@RestController |
| 26 | +@RequestMapping("/admin/recruits") |
| 27 | +@RequiredArgsConstructor |
| 28 | +@Profile({"dev", "local"}) |
| 29 | +public class DevRecruitController { |
| 30 | + |
| 31 | + private final RecruitRepository recruitRepository; |
| 32 | + private final ApplicationEventPublisher eventPublisher; |
| 33 | + |
| 34 | + @Operation(summary = "모집 정보 강제 수정", description = "마감 여부와 관계없이 모집 정보를 강제로 수정합니다.") |
| 35 | + @PutMapping("/{recruitId}/force-update") |
| 36 | + @Transactional |
| 37 | + public void updateRecruit(@PathVariable Long recruitId, |
| 38 | + @RequestBody @Valid RecruitUpdateRequest request) { |
| 39 | + log.info("force update recruitId: {}, request: {}", recruitId, request); |
| 40 | + |
| 41 | + Recruit recruit = recruitRepository.findById(recruitId) |
| 42 | + .orElseThrow(() -> new RecruitException(RecruitErrorCode.NOT_FOUND_RECRUIT)); |
| 43 | + recruit.update(request.jobFamily(), request.startDate(), request.endDate()); |
| 44 | + |
| 45 | + eventPublisher.publishEvent(new RecruitUpdatedEvent( |
| 46 | + recruit.getId(), |
| 47 | + recruit.getJobFamily(), |
| 48 | + recruit.getStartDate(), |
| 49 | + recruit.getEndDate())); |
| 50 | + } |
| 51 | +} |
0 commit comments