-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
37 changed files
with
1,420 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
:toc: left | ||
:toclevels: 2 | ||
:sectlinks: | ||
:docinfo: shared-head | ||
|
||
[[AdminChat]] | ||
= 관리자용 채팅 API | ||
|
||
== 미할당 채팅방 조회 | ||
=== HTTP Request | ||
include::{snippets}/adminchat/rooms/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/adminchat/rooms/request-headers.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adminchat/rooms/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adminchat/rooms/response-fields.adoc[] | ||
|
||
== 자신이 속한 채팅방 조회 | ||
=== HTTP Request | ||
include::{snippets}/adminchat/myrooms/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/adminchat/myrooms/request-headers.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adminchat/myrooms/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adminchat/myrooms/response-fields.adoc[] | ||
|
||
== 채팅방 대화 조회 API | ||
=== HTTP Request | ||
include::{snippets}/adminchat/getmessages/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/adminchat/getmessages/request-headers.adoc[] | ||
==== Path Parameters | ||
include::{snippets}/adminchat/getmessages/path-parameters.adoc[] | ||
==== Query Parameters | ||
include::{snippets}/adminchat/getmessages/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adminchat/getmessages/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adminchat/getmessages/response-fields.adoc[] | ||
|
||
== 상담 완료 처리 API | ||
=== HTTP Request | ||
include::{snippets}/adminchat/completechat/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/adminchat/completechat/request-headers.adoc[] | ||
==== Path Parameters | ||
include::{snippets}/adminchat/completechat/path-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adminchat/completechat/http-response.adoc[] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script> | ||
function ready(callbackFunc) { | ||
if (document.readyState !== 'loading') { | ||
// Document is already ready, call the callback directly | ||
callbackFunc(); | ||
} else if (document.addEventListener) { | ||
// All modern browsers to register DOMContentLoaded | ||
document.addEventListener('DOMContentLoaded', callbackFunc); | ||
} else { | ||
// Old IE browsers | ||
document.attachEvent('onreadystatechange', function () { | ||
if (document.readyState === 'complete') { | ||
callbackFunc(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function openPopup(event) { | ||
|
||
const target = event.target; | ||
if (target.className !== "popup") { | ||
return; | ||
} | ||
|
||
event.preventDefault(); | ||
const screenX = event.screenX; | ||
const screenY = event.screenY; | ||
window.open(target.href, target.text, `left=${screenX}, top=${screenY}, width=500, height=600, status=no, menubar=no, toolbar=no, resizable=no`); | ||
} | ||
|
||
ready(function () { | ||
const el = document.getElementById("content"); | ||
el.addEventListener("click", event => openPopup(event), false); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
:toc: left | ||
:toclevels: 2 | ||
:sectlinks: | ||
:docinfo: shared-head | ||
|
||
[[UserChat]] | ||
= 사용자용 채팅 API | ||
|
||
== 채팅방 대화 조회 API | ||
=== HTTP Request | ||
include::{snippets}/userchat/getmessages/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/userchat/getmessages/request-headers.adoc[] | ||
==== Query Parameters | ||
include::{snippets}/userchat/getmessages/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/userchat/getmessages/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/userchat/getmessages/response-fields.adoc[] | ||
|
||
== 상담방 나가기 (삭제) API | ||
=== HTTP Request | ||
include::{snippets}/userchat/exitchat/http-request.adoc[] | ||
==== Request Header | ||
include::{snippets}/userchat/exitchat/request-headers.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/userchat/exitchat/http-response.adoc[] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Server/src/main/java/com/server/auth/util/SecurityUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.server.auth.util; | ||
|
||
import com.server.auth.jwt.service.CustomUserDetails; | ||
import com.server.domain.member.entity.Authority; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class SecurityUtil { | ||
|
||
public static String getEmail() { | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
if(authentication == null || authentication.getPrincipal() == null) { | ||
return "미로그인 사용자"; | ||
} | ||
|
||
CustomUserDetails principal = (CustomUserDetails) authentication.getPrincipal(); | ||
return principal.getUsername(); | ||
} | ||
|
||
public static boolean isAdmin() { | ||
|
||
if(SecurityContextHolder.getContext().getAuthentication() == null) { | ||
return false; | ||
} | ||
|
||
CustomUserDetails principal = (CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
return Authority.valueOf(principal.getAuthorities().stream() | ||
.map(GrantedAuthority::getAuthority) | ||
.collect(Collectors.joining())).equals(Authority.ROLE_ADMIN); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Server/src/main/java/com/server/chat/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.server.chat.config; | ||
|
||
import com.server.chat.entity.ChatMessage; | ||
import com.server.chat.sub.RedisSubscriber; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.listener.ChannelTopic; | ||
import org.springframework.data.redis.listener.RedisMessageListenerContainer; | ||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; | ||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
@Configuration | ||
public class RedisConfig { | ||
|
||
@Bean | ||
public ChannelTopic channelTopic() { | ||
return new ChannelTopic("chatroom"); | ||
} | ||
|
||
/** | ||
* redis pub/sub 메시지를 처리하는 listener 설정 | ||
*/ | ||
@Bean | ||
public RedisMessageListenerContainer redisMessageListener(RedisConnectionFactory connectionFactory, | ||
MessageListenerAdapter listenerAdapter, | ||
ChannelTopic channelTopic) { | ||
RedisMessageListenerContainer container = new RedisMessageListenerContainer(); | ||
container.setConnectionFactory(connectionFactory); | ||
container.addMessageListener(listenerAdapter, channelTopic); | ||
return container; | ||
} | ||
|
||
@Bean | ||
public MessageListenerAdapter listenerAdapter(RedisSubscriber redisSubscriber) { | ||
return new MessageListenerAdapter(redisSubscriber, "sendMessage"); | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) { | ||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(connectionFactory); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(String.class)); | ||
return redisTemplate; | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, ChatMessage> redisTemplateChatMessage(RedisConnectionFactory connectionFactory) { | ||
RedisTemplate<String, ChatMessage> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(connectionFactory); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(ChatMessage.class)); | ||
return redisTemplate; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Server/src/main/java/com/server/chat/config/WebSocketConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.server.chat.config; | ||
|
||
import com.server.chat.interceptor.StompHandler; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.messaging.simp.config.ChannelRegistration; | ||
import org.springframework.messaging.simp.config.MessageBrokerRegistry; | ||
import org.springframework.web.socket.config.annotation.*; | ||
|
||
@Configuration | ||
@EnableWebSocketMessageBroker | ||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { | ||
|
||
private final StompHandler stompHandler; | ||
|
||
public WebSocketConfig(StompHandler stompHandler) { | ||
this.stompHandler = stompHandler; | ||
} | ||
|
||
@Override | ||
public void configureMessageBroker(MessageBrokerRegistry config) { | ||
config.enableSimpleBroker("/sub"); | ||
config.setApplicationDestinationPrefixes("/pub"); | ||
} | ||
|
||
@Override | ||
public void registerStompEndpoints(StompEndpointRegistry registry) { | ||
registry.addEndpoint("/ws") | ||
.setAllowedOriginPatterns("*") | ||
.withSockJS() | ||
; | ||
} | ||
|
||
@Override | ||
public void configureClientInboundChannel(ChannelRegistration registration) { | ||
registration.interceptors(stompHandler); | ||
} | ||
} |
Oops, something went wrong.