feat: back button + reopen for approved/rejected tickets

This commit is contained in:
pray4skylark
2026-06-08 18:01:53 +09:00
parent 3047354571
commit 969efe3fc3
3 changed files with 62 additions and 4 deletions
@@ -135,6 +135,13 @@ public class TicketController {
return ResponseEntity.ok(ApiResponse.ok("반려되었습니다", ticketService.rejectTicket(ticketId, currentUser.getEmpId(), body.get("reason"))));
}
@Operation(summary = "티켓 재오픈", description = "APPROVED/REJECTED 상태를 PENDING_APPROVAL로 되돌립니다")
@PreAuthorize("hasAnyRole('MANAGER', 'ADMIN')")
@PostMapping("/{ticketId}/reopen")
public ResponseEntity<ApiResponse<IssueTicket>> reopenTicket(@PathVariable Long ticketId) {
return ResponseEntity.ok(ApiResponse.ok("재오픈되었습니다", ticketService.reopenTicket(ticketId)));
}
@Operation(summary = "댓글 목록 조회", description = "티켓의 댓글 목록을 조회합니다")
@PreAuthorize("hasAnyRole('EMPLOYEE', 'MANAGER', 'ADMIN')")
@GetMapping("/{ticketId}/comments")
@@ -234,6 +234,19 @@ public class TicketService {
return toIssueTicket(ticketRepository.save(ticket));
}
@Transactional
public IssueTicket reopenTicket(Long ticketId) {
Ticket ticket = ticketRepository.findById(ticketId)
.orElseThrow(() -> new BusinessException(ErrorCode.TICKET_NOT_FOUND));
if (ticket.getStatus() != TicketStatus.APPROVED && ticket.getStatus() != TicketStatus.REJECTED) {
throw new BusinessException(ErrorCode.INVALID_STATUS);
}
ticket.setStatus(TicketStatus.PENDING_APPROVAL);
ticket.setApprovedBy(null);
ticket.setApprovedAt(null);
return toIssueTicket(ticketRepository.save(ticket));
}
private IssueTicket toIssueTicket(Ticket ticket) {
return new IssueTicket(
ticket.getTicketId(),