Skip to content

Commit

Permalink
#40 [FIx]: MessageController 삭제 이후 ResumeController 로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
gytjd committed Aug 13, 2024
1 parent ec231ac commit 13d0a50
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 44 deletions.
Binary file modified .gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
1 change: 0 additions & 1 deletion .idea/modules/Recruitment.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package Aws6.Recruitment.api.controller.message;

import Aws6.Recruitment.api.dto.message.MessageDto;
import Aws6.Recruitment.service.message.MessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
public class MessageController {

private final MessageService messageService;

/**
* Queue로 메시지를 발행
*
* @param messageDto 발행할 메시지의 DTO 객체
* @return ResponseEntity 객체로 응답을 반환
*/
@RequestMapping(value = "/send/message", method = RequestMethod.POST)
public ResponseEntity<?> sendMessage(@RequestBody MessageDto messageDto) {
messageService.sendMessage(messageDto);
return ResponseEntity.ok("Message sent to RabbitMQ!");
}
}
//package Aws6.Recruitment.api.controller.message;
//
//import Aws6.Recruitment.api.dto.message.MessageDto;
//import Aws6.Recruitment.service.message.MessageService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//@Slf4j
//@RequiredArgsConstructor
//@RestController
//public class MessageController {
//
// private final MessageService messageService;
//
// /**
// * Queue로 메시지를 발행
// *
// * @param messageDto 발행할 메시지의 DTO 객체
// * @return ResponseEntity 객체로 응답을 반환
// */
// @RequestMapping(value = "/send/message", method = RequestMethod.POST)
// public ResponseEntity<?> sendMessage(@RequestBody MessageDto messageDto) {
// messageService.sendMessage(messageDto);
// return ResponseEntity.ok("Message sent to RabbitMQ!");
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@
import Aws6.Recruitment.entity.response.SingleResult;
import Aws6.Recruitment.entity.resume.Resume;
import Aws6.Recruitment.entity.user.User;
import Aws6.Recruitment.service.message.MessageService;
import Aws6.Recruitment.service.response.ResponseService;
import Aws6.Recruitment.service.resume.ResumeService;
import Aws6.Recruitment.service.user.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping("/api/resumes")
@RequiredArgsConstructor
Expand All @@ -29,9 +34,10 @@ public class ResumeController {

private final UserService userService;

private final MessageService messageService;
@PostMapping
public CommonResult createResume(@RequestBody ResumeRequestDto resumeRequestDto) {
resumeService.createResume(resumeRequestDto);
messageService.sendMessage(resumeRequestDto);
return responseService.getSuccessResult();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package Aws6.Recruitment.api.dto.resume;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class ResumeRequestDto {

private Long jobPostingId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package Aws6.Recruitment.service.message;

import Aws6.Recruitment.api.dto.message.MessageDto;
import Aws6.Recruitment.api.dto.resume.ResumeRequestDto;
import Aws6.Recruitment.service.resume.ResumeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
Expand All @@ -21,14 +23,15 @@ public class MessageService {

private final RabbitTemplate rabbitTemplate;

private final ResumeService resumeService;
/**
* Queue로 메시지를 발행
*
* @param messageDto 발행할 메시지의 DTO 객체
*/
public void sendMessage(MessageDto messageDto) {
log.info("message sent: {}", messageDto.toString());
rabbitTemplate.convertAndSend(exchangeName, routingKey, messageDto);
public void sendMessage(ResumeRequestDto resumeRequestDto) {
log.info("message sent: {}", resumeRequestDto.toString());
rabbitTemplate.convertAndSend(exchangeName, routingKey, resumeRequestDto);
}

/**
Expand All @@ -37,7 +40,8 @@ public void sendMessage(MessageDto messageDto) {
* @param messageDto 구독한 메시지를 담고 있는 MessageDto 객체
*/
@RabbitListener(queues = "${rabbitmq.queue.name}")
public void reciveMessage(MessageDto messageDto) {
log.info("Received message: {}", messageDto.toString());
public void reciveMessage(ResumeRequestDto resumeRequestDto) {
log.info("Received message: {}", resumeRequestDto.toString());
resumeService.createResume(resumeRequestDto);
}
}

0 comments on commit 13d0a50

Please sign in to comment.