Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jiyoung #64

Open
wants to merge 26 commits into
base: backend
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
06a3c56
init
EveKristinLee Feb 4, 2022
263de52
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 6, 2022
2f26264
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 7, 2022
3a47e17
[#4] 로그인 기능 구현
EveKristinLee Feb 8, 2022
59e3981
[#4]Feat: 로그인 기능 구현
EveKristinLee Feb 8, 2022
28aae37
[#4]Feat: 로그인 기능 구현
EveKristinLee Feb 8, 2022
0657f36
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 9, 2022
35b0fea
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 10, 2022
6be36a5
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 12, 2022
fe91e01
[#4]Feat: 로그인 기능 구현
EveKristinLee Feb 12, 2022
61fc1ff
[#17]Feat: 관리자페이지 기능 구현
EveKristinLee Feb 13, 2022
152cf43
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 14, 2022
075d013
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 14, 2022
75e1f79
[#17]Feat: 관리자페이지 기능 구현
EveKristinLee Feb 15, 2022
5589972
[#6]Feat: DM페이지 기능 구현
EveKristinLee Feb 17, 2022
d537f18
[#23]Feat: 구글 소셜로그인 기능 구현
EveKristinLee Feb 19, 2022
35b2521
commit
EveKristinLee Feb 21, 2022
33380ca
[#17]Feat: 관리자페이지 기능 구현
EveKristinLee Feb 22, 2022
af11b31
[#23]Feat: 구글 소셜로그인 기능 구현
EveKristinLee Mar 2, 2022
71f188a
[#6]Feat: DM페이지 기능 구현
EveKristinLee Mar 3, 2022
8e3872c
[#23]Feat: 구글 소셜로그인 기능 구현
EveKristinLee Mar 4, 2022
b1d6f86
[#23]Feat: 구글 소셜로그인 기능 구현
EveKristinLee Mar 4, 2022
a7ffbe5
[#45]Feat: 소셜로그인 닉네임 생성 규칙 변경
EveKristinLee Mar 14, 2022
9320aca
[#59]Feat: DM페이지 정렬 방식 수정
EveKristinLee Mar 25, 2022
1d52414
[#62]Feat: DM페이지 생성시 response 수정
EveKristinLee Mar 26, 2022
cb537a0
[#62]Feat: DM페이지 생성시 response 수정
EveKristinLee Mar 27, 2022
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
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
application-aws.properties
chromedriver1
### STS ###
.apt_generated
.classpath
Expand Down
7 changes: 6 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ dependencies {
implementation 'org.webjars:sockjs-client:1.1.2'
implementation 'org.webjars:stomp-websocket:2.3.3-1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.code.gson:gson:2.8.7'

implementation group: 'com.google.firebase',name: 'firebase-admin', version:'8.1.0'

implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
implementation 'org.jsoup:jsoup:1.14.2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
implementation 'com.google.guava:guava:30.1.1-jre'

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.4.5'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:3.0.3'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package moviegoods.movie.configure;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.HashSet;
import java.util.Set;

//@Configuration
//@EnableWebMvc
public class SwaggerConfig {
private ApiInfo swaggerInfo() {
return new ApiInfoBuilder().title("SweetRedBeans Spring Boot REST API")
.description("영화 굿즈 수집 collector의 swagger api 입니다.").build();
}

@Bean
public Docket swaggerApi() {
return new Docket(DocumentationType.SWAGGER_2)
.consumes(getConsumeContentTypes())
.produces(getProduceContentTypes())
.apiInfo(swaggerInfo()).select()
.apis(RequestHandlerSelectors.basePackage("moviegoods.movie.controller"))
.paths(PathSelectors.any())
.build()
.useDefaultResponseMessages(false);
}

private Set<String> getConsumeContentTypes() {
Set<String> consumes = new HashSet<>();
consumes.add("application/json;charset=UTF-8");
consumes.add("application/x-www-form-urlencoded");
return consumes;
}

private Set<String> getProduceContentTypes() {
Set<String> produces = new HashSet<>();
produces.add("application/json;charset=UTF-8");
return produces;
}
}

29 changes: 29 additions & 0 deletions backend/src/main/java/moviegoods/movie/configure/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package moviegoods.movie.configure;

import moviegoods.movie.domain.argumentresolver.LoginMemberArgumentResolver;
import moviegoods.movie.domain.interceptor.LoginCheckInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new LoginMemberArgumentResolver());
}

@Override
public void addInterceptors(InterceptorRegistry registry) {

registry.addInterceptor(new LoginCheckInterceptor())
.order(2)
.addPathPatterns("/direct-message", "/mypage")
.excludePathPatterns("/main/**", "/members/add", "/signin", "/logout",
"/css/**", "/*.ico", "/error");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package moviegoods.movie.configure;

import moviegoods.movie.domain.interceptor.HttpHandshakeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
Expand All @@ -17,9 +18,10 @@ public void configureMessageBroker(MessageBrokerRegistry config){

}
public void registerStompEndpoints(StompEndpointRegistry registry){
registry.addEndpoint("/ws-stomp")
registry.addEndpoint("/ws-stomp").addInterceptors()
.setAllowedOriginPatterns("*")
.withSockJS();
.setAllowedOrigins("http://localhost:3000")
.withSockJS().setInterceptors(new HttpHandshakeInterceptor());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
package moviegoods.movie.controller;


import com.google.api.Http;
import com.google.firebase.auth.FirebaseAuthException;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import moviegoods.movie.configure.SessionConfig;
import moviegoods.movie.domain.argumentresolver.Login;
import moviegoods.movie.domain.dto.directMessage.*;
import moviegoods.movie.domain.entity.ChatRoom.ChatRoomRepository;
import moviegoods.movie.domain.entity.Message.Message;
import moviegoods.movie.domain.entity.Message.MessageRepository;
import moviegoods.movie.domain.entity.Report.Report;
import moviegoods.movie.domain.entity.User.User;
import moviegoods.movie.domain.entity.User.UserRepository;
import moviegoods.movie.service.FireBaseService;
import moviegoods.movie.service.ChatService;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.messaging.simp.annotation.SendToUser;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.WebRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/direct-message")
Expand All @@ -29,33 +41,37 @@ public class ChatController {
private final FireBaseService fireBaseService;

@MessageMapping("/chat/message")
public void message(DirectMessage message) throws IOException, FirebaseAuthException {
// if(message.getMessageType().equals(DirectMessage.MessageType.ENTER)) {
// message.setContent(message.getNickname() + "입장");

//}
messageService.saveMessage(message);
public void message(@Login User loginUser,DirectMessage message, SimpMessageHeaderAccessor headerAccessor) throws IOException, FirebaseAuthException {

User user1 = (User) headerAccessor.getSessionAttributes().get(SessionConfig.SessionConst.LOGIN_MEMBER);
String url= messageService.saveMessage(user1,message);
if(message.getImage_url()!=null){
message.setImage_url(url);
}else{
message.setImage_url("");
}
message.setNickname(user1.getNickname());
message.setUser_id(user1.getUser_id());

messagingTemplate.convertAndSend("/sub/chat/room/"+message.getChat_room_id());

messagingTemplate.convertAndSend("/sub/chat/room/"+message.getChat_room_id(), message);

}


@PostMapping("/detail")
public Result saveMessage(@ModelAttribute DirectMessage message) throws IOException, FirebaseAuthException {
public Result saveMessage(@Login User loginUser,@ModelAttribute DirectMessage message) throws IOException, FirebaseAuthException {

messageService.saveMessage(message);
messageService.saveMessage(loginUser,message);
Result result=new Result();
result.setResult(true);
return result;

}

@PostMapping("/transaction-complete")
public Result complete(@RequestBody DirectMessageRequestComplete dmrc){
Boolean check= messageService.updateTransactionComplete(dmrc);
public Result complete(@Login User loginUser,@RequestBody DirectMessageRequestComplete dmrc){
Boolean check= messageService.updateTransactionComplete(loginUser,dmrc);
Result result=new Result();
if(check==true){
result.setResult(true);
Expand All @@ -66,8 +82,8 @@ public Result complete(@RequestBody DirectMessageRequestComplete dmrc){
}

@PostMapping("/reliability")
public Result updateReliability(@RequestBody DirectMessageRequestReliability dmrr){
Boolean check=messageService.updateReliability(dmrr);
public Result updateReliability(@Login User loginUser, @RequestBody DirectMessageRequestReliability dmrr){
Boolean check=messageService.updateReliability(loginUser, dmrr);
Result result=new Result();
if(check==true){
result.setResult(true);
Expand All @@ -78,8 +94,8 @@ public Result updateReliability(@RequestBody DirectMessageRequestReliability dmr
}

@PostMapping("/report")
public Result Report(@RequestBody DirectMessageRequestReport dmrr){
Report report=messageService.report(dmrr);
public Result Report(@Login User loginUser, @RequestBody DirectMessageRequestReport dmrr){
Report report=messageService.report(loginUser, dmrr);
Result result=new Result();
if(report!=null){
result.setResult(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import moviegoods.movie.domain.argumentresolver.Login;
import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto;
import moviegoods.movie.domain.dto.directMessage.DirectMessageCreateRoomRequestDto;
import moviegoods.movie.domain.dto.directMessage.DirectMessageCreateRoomResponseDto;
import moviegoods.movie.domain.dto.directMessage.DirectMessageDetailResponseDto;
import moviegoods.movie.domain.dto.directMessage.DirectMessageListResponseDto;
import moviegoods.movie.domain.entity.ChatRoom.ChatRoomRepository;
import moviegoods.movie.domain.entity.User.User;
import moviegoods.movie.service.ChatRoomService;
import moviegoods.movie.service.ChatService;
import org.springframework.http.HttpStatus;
Expand All @@ -24,26 +28,37 @@ public class ChatRoomController {

private final ChatRoomService chatRoomService;
private final ChatService chatService;
private final ChatRoomRepository chatRoomRepository;

@PostMapping
public ResponseEntity<DirectMessageCreateRoomResponseDto> create(@RequestBody DirectMessageCreateRoomRequestDto requestDto){
DirectMessageCreateRoomResponseDto responseDto = chatRoomService.createRoom(requestDto);
ResponseEntity<DirectMessageCreateRoomResponseDto> result = new ResponseEntity<>(responseDto, HttpStatus.OK);
public ResponseEntity<DirectMessageCreateRoomResponseDto> create(@Login User loginUser, @RequestBody DirectMessageCreateRoomRequestDto requestDto){
DirectMessageCreateRoomResponseDto responseDto = chatRoomService.createRoom(loginUser, requestDto);
ResponseEntity<DirectMessageCreateRoomResponseDto> result;
result = new ResponseEntity<>(responseDto, HttpStatus.OK);

if (!responseDto.isResult()) {
result = new ResponseEntity<>(responseDto, HttpStatus.UNAUTHORIZED);
}

return result;
}

@GetMapping
public ResponseEntity<Map<String, List<DirectMessageListResponseDto>>> directMessageList (@RequestParam Long user_id) {
List<DirectMessageListResponseDto> roomsList = chatRoomService.findMessageRooms(user_id);
public ResponseEntity<Map<String, List<DirectMessageListResponseDto>>> directMessageList (@Login User loginUser) {
Long user_id = null;
if (loginUser != null) {
user_id = loginUser.getUser_id();
}
List<DirectMessageListResponseDto> roomsList = chatRoomService.findMessageRooms(loginUser, user_id);
Map<String, List<DirectMessageListResponseDto>> roomsListJson = new HashMap<>();
roomsListJson.put("room_id", roomsList);
ResponseEntity<Map<String, List<DirectMessageListResponseDto>>> result = new ResponseEntity<>(roomsListJson, HttpStatus.OK);
return result;
}

@GetMapping("/detail")
public ResponseEntity<Map<String, List<DirectMessageDetailResponseDto>>> detail (@RequestParam Long room_id) {
List<DirectMessageDetailResponseDto> messagesList = chatService.show(room_id);
public ResponseEntity<Map<String, List<DirectMessageDetailResponseDto>>> detail (@Login User loginUser, @RequestParam Long room_id) {
List<DirectMessageDetailResponseDto> messagesList = chatService.show(loginUser, room_id);
Map<String, List<DirectMessageDetailResponseDto>> messagesListJson = new HashMap<>();

messagesListJson.put("message", messagesList);
Expand All @@ -52,4 +67,10 @@ public ResponseEntity<Map<String, List<DirectMessageDetailResponseDto>>> detail
return result;
}

@DeleteMapping
public Boolean create(@Login User loginUser, @RequestBody DirectMessageCreateRoomResponseDto responseDto){
chatRoomRepository.deleteById(responseDto.getChat_room_id());
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import moviegoods.movie.domain.argumentresolver.Login;
import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto;
import moviegoods.movie.domain.dto.events.*;
import moviegoods.movie.domain.entity.User.User;
import moviegoods.movie.service.EventsService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@RestController
Expand All @@ -21,23 +22,32 @@ public class EventsController {
private final EventsService eventsService;

@GetMapping("/search")
public ResponseEntity<List<EventsSearchResponseDto>> search(@ModelAttribute EventsSearchRequestDto requestDto) throws ParseException {
List<EventsSearchResponseDto> list = eventsService.search(requestDto);
public ResponseEntity<List<EventsSearchResponseDto>> search(@Login User loginUser, @ModelAttribute EventsSearchRequestDto requestDto) {
List<EventsSearchResponseDto> list = eventsService.search(loginUser, requestDto);
ResponseEntity<List<EventsSearchResponseDto>> result = new ResponseEntity<>(list, HttpStatus.OK);

return result;
}

@GetMapping("/detail")
public ResponseEntity<EventsDetailResponseDto> save(@ModelAttribute EventsDetailRequestDto requestDto) throws ParseException {
EventsDetailResponseDto detail_result = eventsService.detail(requestDto);
public ResponseEntity<EventsDetailResponseDto> detail(@Login User loginUser, @ModelAttribute EventsDetailRequestDto requestDto) {
EventsDetailResponseDto detail_result = eventsService.detail(loginUser, requestDto);
ResponseEntity<EventsDetailResponseDto> result = new ResponseEntity<>(detail_result, HttpStatus.OK);

return result;
}

@PostMapping("/like")
public ResultResponseDto like(@RequestBody EventsLikeRequestDto requestDto) throws ParseException {
ResultResponseDto resultResponseDto = eventsService.like(requestDto);
return resultResponseDto;
public ResponseEntity<ResultResponseDto> like(@Login User loginUser, @RequestBody EventsLikeRequestDto requestDto) {
ResultResponseDto resultResponseDto = eventsService.like(loginUser, requestDto);
ResponseEntity<ResultResponseDto> result;
result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK);

if (!resultResponseDto.isResult()) {
result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED);
}

return result;
}

}
Loading