Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/dev_deply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
sudo docker run --name bill-api -d -p 80:8080 \
-e INTERNAL_CHAT_SECRET=${{ secrets.INTERNAL_CHAT_SECRET }} \
-e INTERNAL_API_SECRET=${{ secrets.INTERNAL_API_SECRET }} \
-e SPRING_RABBITMQ_HOST=${{ secrets.SPRING_RABBITMQ_HOST }} \
-e SPRING_RABBITMQ_PORT=${{ secrets.SPRING_RABBITMQ_PORT }} \
-e SPRING_RABBITMQ_USERNAME=${{ secrets.SPRING_RABBITMQ_USERNAME }} \
-e SPRING_RABBITMQ_PASSWORD=${{ secrets.SPRING_RABBITMQ_PASSWORD }} \
-e SPRING_DATASOURCE_DRIVER_CLASS_NAME=${{ secrets.SPRING_DATASOURCE_DRIVER_CLASS_NAME }} \
-e SPRING_DATASOURCE_URL="${{secrets.SPRING_DATASOURCE_URL}}" \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }} \
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@EnableRabbit
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@EntityScan(basePackages = "site.billbill.apiserver.model")
@ConfigurationPropertiesScan("site.billbill.apiserver.config")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package site.billbill.apiserver.api.chat.dto.request;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class PushDTO {
private String targetUserId;
private String senderId;
private String channelId;
private String content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewChannelInfoResponse;
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewChatInfoResponse;
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewUnreadChatCountResponse;
import site.billbill.apiserver.api.push.dto.request.PushRequest.SendChatPushRequest;

public interface ChatService {
String leaveChatChannel(String postId, String userId);
Expand All @@ -19,4 +20,6 @@ public interface ChatService {
String changeDate(String userId, String channelId, changeDate request);

ViewUnreadChatCountResponse getUnreadCount(String userId);

void receivePushRequest(SendChatPushRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -16,6 +18,8 @@
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewChannelInfoResponse;
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewChatInfoResponse;
import site.billbill.apiserver.api.chat.dto.response.ChatResponse.ViewUnreadChatCountResponse;
import site.billbill.apiserver.api.push.dto.request.PushRequest.SendChatPushRequest;
import site.billbill.apiserver.api.push.service.PushService;
import site.billbill.apiserver.common.enums.exception.ErrorCode;
import site.billbill.apiserver.common.utils.ULID.ULIDUtil;
import site.billbill.apiserver.exception.CustomException;
Expand All @@ -31,12 +35,14 @@
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
@Slf4j
public class ChatServiceImpl implements ChatService {
private final ChatRepository chatRepository;
private final UserRepository userRepository;
private final ItemsRepository itemsRepository;
private final ItemsBorrowRepository itemsBorrowRepository;
private final ChatServerServiceImpl chatServerService;
private final PushService pushService;

@Override
@Transactional
Expand Down Expand Up @@ -164,4 +170,11 @@ public ViewUnreadChatCountResponse getUnreadCount(String userId) {

return ChatConverter.toViewUnreadChatCount(count);
}

@Override
@RabbitListener(queues = "push.queue")
public void receivePushRequest(SendChatPushRequest request) {
log.info("Push 요청 수신 성공: {}", request);
pushService.sendChatPush(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static class SendPushRequest {

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public static class SendChatPushRequest {
private String userId;
private String senderId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package site.billbill.apiserver.config.rabbitMQ;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
@Bean
public Queue pushQueue() {
return new Queue("push.queue", true);
}

@Bean
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}
}