diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..636cd33 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,38 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ +application-aws.properties +chromedriver1 +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/backend/build.gradle b/backend/build.gradle new file mode 100644 index 0000000..75d3e34 --- /dev/null +++ b/backend/build.gradle @@ -0,0 +1,54 @@ +plugins { + id 'org.springframework.boot' version '2.6.3' + id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'java' +} + +group = 'movie-goods' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.3' + implementation 'org.springframework.boot:spring-boot-starter-websocket' + implementation 'org.webjars.bower:bootstrap:4.3.1' + 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' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation("org.junit.vintage:junit-vintage-engine") { + exclude group: "org.hamcrest", module: "hamcrest-core" + } + + +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/backend/gradle/wrapper/gradle-wrapper.jar b/backend/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/backend/gradle/wrapper/gradle-wrapper.jar differ diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2e6e589 --- /dev/null +++ b/backend/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/backend/gradlew b/backend/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/backend/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/backend/gradlew.bat b/backend/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/backend/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend/settings.gradle b/backend/settings.gradle new file mode 100644 index 0000000..f9b811d --- /dev/null +++ b/backend/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'movie' diff --git a/backend/src/main/java/moviegoods/movie/MovieApplication.java b/backend/src/main/java/moviegoods/movie/MovieApplication.java new file mode 100644 index 0000000..8f219d5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/MovieApplication.java @@ -0,0 +1,27 @@ +package moviegoods.movie; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +public class MovieApplication { + + public static void main(String[] args) { + SpringApplication.run(MovieApplication.class, args); + } + + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedOrigins("http://localhost:3000").allowedMethods("GET", "POST", "DELETE", "PATCH") + .allowCredentials(true); + } + }; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/configure/FireBaseConfig.java b/backend/src/main/java/moviegoods/movie/configure/FireBaseConfig.java new file mode 100644 index 0000000..49a7ee6 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/FireBaseConfig.java @@ -0,0 +1,39 @@ +package moviegoods.movie.configure; + +import com.google.auth.oauth2.GoogleCredentials; +import com.google.firebase.FirebaseApp; +import com.google.firebase.FirebaseOptions; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.io.FileInputStream; +import java.io.IOException; + + +@Service +@Slf4j +public class FireBaseConfig { + + + @PostConstruct + public void initialize(){ + try{ + FileInputStream serviceAccount=new FileInputStream("src/main/resources/serviceAccountKey.json"); + + FirebaseOptions options= new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream(serviceAccount)). + setDatabaseUrl("https://stroagetest.firebaseio.com/").build(); + FirebaseApp.initializeApp(options); + /* FirebaseOptions options=new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream( + new ClassPathResource(firebaseConfigPath).getInputStream() + )).build(); + if(FirebaseApp.getApps().isEmpty()){ + FirebaseApp.initializeApp(options); + log.info("Firebase application has been initialized"); + }*/ + + }catch(IOException e){ + log.error(e.getMessage()); + } + } +} diff --git a/backend/src/main/java/moviegoods/movie/configure/SessionConfig.java b/backend/src/main/java/moviegoods/movie/configure/SessionConfig.java new file mode 100644 index 0000000..566824f --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/SessionConfig.java @@ -0,0 +1,8 @@ +package moviegoods.movie.configure; + +public class SessionConfig { + public abstract class SessionConst { + public static final String LOGIN_MEMBER = "loginMember"; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/configure/SwaggerConfig.java b/backend/src/main/java/moviegoods/movie/configure/SwaggerConfig.java new file mode 100644 index 0000000..b8a4cf5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/SwaggerConfig.java @@ -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 getConsumeContentTypes() { + Set consumes = new HashSet<>(); + consumes.add("application/json;charset=UTF-8"); + consumes.add("application/x-www-form-urlencoded"); + return consumes; + } + + private Set getProduceContentTypes() { + Set produces = new HashSet<>(); + produces.add("application/json;charset=UTF-8"); + return produces; + } +} + diff --git a/backend/src/main/java/moviegoods/movie/configure/WebConfig.java b/backend/src/main/java/moviegoods/movie/configure/WebConfig.java new file mode 100644 index 0000000..54ae03b --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/WebConfig.java @@ -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 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"); + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/configure/WebSecurityConfig.java b/backend/src/main/java/moviegoods/movie/configure/WebSecurityConfig.java new file mode 100644 index 0000000..9ebd2c5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/WebSecurityConfig.java @@ -0,0 +1,26 @@ +package moviegoods.movie.configure; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +@Configuration +@EnableWebSecurity +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + @Bean + public PasswordEncoder getPasswordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.cors().disable() + .csrf().disable() + .formLogin().disable() + .headers().frameOptions().disable(); + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/configure/WebSockConfig.java b/backend/src/main/java/moviegoods/movie/configure/WebSockConfig.java new file mode 100644 index 0000000..c1fd2f1 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/configure/WebSockConfig.java @@ -0,0 +1,28 @@ +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; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +@Configuration +@EnableWebSocketMessageBroker +public class WebSockConfig implements WebSocketMessageBrokerConfigurer { + + public void configureMessageBroker(MessageBrokerRegistry config){ + config.enableSimpleBroker("/sub"); //메세지 구독 요청 + config.setApplicationDestinationPrefixes("/pub"); //메세지 발행 요청 + + + } + public void registerStompEndpoints(StompEndpointRegistry registry){ + registry.addEndpoint("/ws-stomp").addInterceptors() + .setAllowedOriginPatterns("*") + .setAllowedOrigins("http://localhost:3000") + .withSockJS().setInterceptors(new HttpHandshakeInterceptor()); + + } + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/controller/ChatController.java b/backend/src/main/java/moviegoods/movie/controller/ChatController.java new file mode 100644 index 0000000..48048c6 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/ChatController.java @@ -0,0 +1,108 @@ +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") +public class ChatController { + private final UserRepository informationShareUserRepository; + private final SimpMessageSendingOperations messagingTemplate; + private final ChatRoomRepository chatRoomRepository; + private final MessageRepository messageRepository; + private final ChatService messageService; + private final FireBaseService fireBaseService; + + @MessageMapping("/chat/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(), message); + + } + + + @PostMapping("/detail") + public Result saveMessage(@Login User loginUser,@ModelAttribute DirectMessage message) throws IOException, FirebaseAuthException { + + messageService.saveMessage(loginUser,message); + Result result=new Result(); + result.setResult(true); + return result; + + } + + @PostMapping("/transaction-complete") + 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); + }else{ + result.setResult(false); + } + return result; + } + + @PostMapping("/reliability") + 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); + }else{ + result.setResult(false); + } + return result; + } + + @PostMapping("/report") + 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); + }else{ + result.setResult(false); + } + return result; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/ChatRoomController.java b/backend/src/main/java/moviegoods/movie/controller/ChatRoomController.java new file mode 100644 index 0000000..cb1933f --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/ChatRoomController.java @@ -0,0 +1,76 @@ +package moviegoods.movie.controller; + +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; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@RequiredArgsConstructor +@RestController +@RequestMapping("/direct-message") +public class ChatRoomController { + + private final ChatRoomService chatRoomService; + private final ChatService chatService; + private final ChatRoomRepository chatRoomRepository; + + @PostMapping + public ResponseEntity create(@Login User loginUser, @RequestBody DirectMessageCreateRoomRequestDto requestDto){ + DirectMessageCreateRoomResponseDto responseDto = chatRoomService.createRoom(loginUser, requestDto); + ResponseEntity result; + result = new ResponseEntity<>(responseDto, HttpStatus.OK); + + if (!responseDto.isResult()) { + result = new ResponseEntity<>(responseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + + @GetMapping + public ResponseEntity>> directMessageList (@Login User loginUser) { + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + List roomsList = chatRoomService.findMessageRooms(loginUser, user_id); + Map> roomsListJson = new HashMap<>(); + roomsListJson.put("room_id", roomsList); + ResponseEntity>> result = new ResponseEntity<>(roomsListJson, HttpStatus.OK); + return result; + } + + @GetMapping("/detail") + public ResponseEntity>> detail (@Login User loginUser, @RequestParam Long room_id) { + List messagesList = chatService.show(loginUser, room_id); + Map> messagesListJson = new HashMap<>(); + + messagesListJson.put("message", messagesList); + + ResponseEntity>> result = new ResponseEntity<>(messagesListJson, HttpStatus.OK); + return result; + } + + @DeleteMapping + public Boolean create(@Login User loginUser, @RequestBody DirectMessageCreateRoomResponseDto responseDto){ + chatRoomRepository.deleteById(responseDto.getChat_room_id()); + return true; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/EventsController.java b/backend/src/main/java/moviegoods/movie/controller/EventsController.java new file mode 100644 index 0000000..3032dfd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/EventsController.java @@ -0,0 +1,53 @@ +package moviegoods.movie.controller; + +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.util.List; + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/events") +public class EventsController { + + private final EventsService eventsService; + + @GetMapping("/search") + public ResponseEntity> search(@Login User loginUser, @ModelAttribute EventsSearchRequestDto requestDto) { + List list = eventsService.search(loginUser, requestDto); + ResponseEntity> result = new ResponseEntity<>(list, HttpStatus.OK); + + return result; + } + + @GetMapping("/detail") + public ResponseEntity detail(@Login User loginUser, @ModelAttribute EventsDetailRequestDto requestDto) { + EventsDetailResponseDto detail_result = eventsService.detail(loginUser, requestDto); + ResponseEntity result = new ResponseEntity<>(detail_result, HttpStatus.OK); + + return result; + } + + @PostMapping("/like") + public ResponseEntity like(@Login User loginUser, @RequestBody EventsLikeRequestDto requestDto) { + ResultResponseDto resultResponseDto = eventsService.like(loginUser, requestDto); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/GeneralBoardController.java b/backend/src/main/java/moviegoods/movie/controller/GeneralBoardController.java new file mode 100644 index 0000000..b9e2d7d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/GeneralBoardController.java @@ -0,0 +1,90 @@ +package moviegoods.movie.controller; + +import com.google.firebase.auth.FirebaseAuthException; +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.generalBoard.*; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.GeneralBoardService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + + + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/general-board") +public class GeneralBoardController { + private final GeneralBoardService generalBoardService; + + @PostMapping("/write") + public ResponseEntity write(@Login User loginUser, @RequestParam(value="image_url",required = false) MultipartFile image_url, + @RequestParam(value="title")String title, + @RequestParam(value="content")String content + ) throws IOException, FirebaseAuthException { + GeneralBoardWriteRequestDto requestDto = new GeneralBoardWriteRequestDto(title, content, image_url); + ResultResponseDto resultResponseDto = generalBoardService.savePost(loginUser,requestDto); + + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + + } + + @GetMapping("/search") + public ResponseEntity> search(@ModelAttribute GeneralBoardSearchRequestDto requestDto){ + List list = generalBoardService.search(requestDto); + ResponseEntity> entity = new ResponseEntity<>(list, HttpStatus.OK); + + return entity; + } + + @GetMapping("/detail") + public GeneralBoardDetailResponseDto detail(@Login User loginUser, @ModelAttribute GeneralBoardDetailRequestDto requestDto){ + GeneralBoardDetailResponseDto responseDto = generalBoardService.detailInfo(loginUser, requestDto); + + return responseDto; + } + + @PostMapping("/comment") + public ResponseEntity saveComment(@Login User loginUser, @RequestBody GeneralBoardCommentRequestDto requestDto){ + ResultResponseDto resultResponseDto = generalBoardService.saveComment(loginUser,requestDto); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + + @DeleteMapping("/detail") + public ResultResponseDto deleteDetail(@Login User loginUser, @RequestBody GeneralBoardDetailDeleteRequestDto requestDto){ + ResultResponseDto resultResponseDto=generalBoardService.deleteDetail(loginUser, requestDto); + + return resultResponseDto; + } + + @DeleteMapping("/comment") + public ResultResponseDto deleteComment(@Login User loginUser, @RequestBody GeneralBoardCommentDeleteRequestDto requestDto){ + ResultResponseDto resultResponseDto=generalBoardService.deleteComment(loginUser, requestDto); + + return resultResponseDto; + } + + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/InformationShareController.java b/backend/src/main/java/moviegoods/movie/controller/InformationShareController.java new file mode 100644 index 0000000..4bce82d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/InformationShareController.java @@ -0,0 +1,122 @@ +package moviegoods.movie.controller; + + +import com.google.firebase.auth.FirebaseAuthException; +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.informationShare.*; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.FireBaseService; +import moviegoods.movie.service.InformationShareService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/information-share") +public class InformationShareController { + + private final InformationShareService informationShareService; + private final FireBaseService fireBaseService; + + @PostMapping("/write") + public ResponseEntity write2(@Login User loginUser, @RequestParam(value="image_url",required = false)MultipartFile image_url, + @RequestParam(value="cinema_name")String cinema_name, + @RequestParam(value="cinema_area")String cinema_area, + @RequestParam(value="cinema_branch")String cinema_branch, + @RequestParam(value="title")String title, + @RequestParam(value="content")String content + ) throws IOException, FirebaseAuthException { + ResponseEntity result2; + Result result=new Result(); + if (loginUser == null) { + result2 = new ResponseEntity<>(result, HttpStatus.UNAUTHORIZED); + return result2; + } + Long user_id = loginUser.getUser_id(); + + if (cinema_area.equals("") || cinema_name.equals("") || cinema_branch.equals("") || user_id.equals("") || title.equals("") || content.equals("")) { + result.setResult(false); + result2 = new ResponseEntity<>(result, HttpStatus.OK); + + return result2; + } + InformationShareRequestWrite isrw=new InformationShareRequestWrite(user_id,image_url,cinema_branch,cinema_area,cinema_name,title,content); + + //informationShareRepository.savePost(isrw); + List postList=informationShareService.savePost(isrw); + for (Post post : postList) { + log.info("저장된post_title={}",post.getTitle()); + log.info("저장된 post_id={}",post.getPost_id()); + log.info("저장된 post_user_id={}",post.getUser().getUser_id()); + } + + result.setResult(true); + result2 = new ResponseEntity<>(result, HttpStatus.OK); + + return result2; + + } + + @GetMapping("/search") + public ResponseEntity> search(@ModelAttribute InformationShareRequestSearch isrs){ + List list = informationShareService.Search(isrs); + ResponseEntity> entity=new ResponseEntity<>(list, HttpStatus.OK); + return entity; + } + + @GetMapping("/detail") + public InformationShareResponseDetail detail(@Login User loginUser, @ModelAttribute InformationShareRequestDetail isrd){ + InformationShareResponseDetail ifsr=informationShareService.detailInfo(loginUser, isrd); + return ifsr; + } + + @PostMapping("/comment") + public ResponseEntity saveComment(@Login User loginUser, @RequestBody InformationShareRequestSaveComment isrsc){ + ResultResponseDto resultResponseDto=informationShareService.saveComment(loginUser,isrsc); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + + @DeleteMapping("/detail") + public Result deleteDetail(@Login User loginUser, @RequestBody InformationShareRequestDeleteDetail isrdd){ + Boolean check=informationShareService.deleteDetail(loginUser, isrdd); + Result result=new Result(); + if(check==false){ + result.setResult(true); + }else{ + result.setResult(false); + } + return result; + } + + @DeleteMapping("/comment") + public Result deleteComment(@Login User loginUser, @RequestBody InformationShareRequestDeleteComment isrdc){ + Boolean check=informationShareService.deleteComment(loginUser, isrdc); + Result result=new Result(); + if(check==false){ + result.setResult(true); + }else{ + result.setResult(false); + } + return result; + } + + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/LogOutController.java b/backend/src/main/java/moviegoods/movie/controller/LogOutController.java new file mode 100644 index 0000000..64c6849 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/LogOutController.java @@ -0,0 +1,31 @@ +package moviegoods.movie.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +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.logout.LogOutRequestDto; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.LogOutService; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.util.HashMap; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("users/logout") +public class LogOutController { + + private final LogOutService logOutService; + + @PostMapping + public ResultResponseDto logout(@Login User loginUser, HttpSession session) { + ResultResponseDto resultResponseDto = logOutService.logout(loginUser, session); + return resultResponseDto; + } +} diff --git a/backend/src/main/java/moviegoods/movie/controller/MainController.java b/backend/src/main/java/moviegoods/movie/controller/MainController.java new file mode 100644 index 0000000..136bc49 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/MainController.java @@ -0,0 +1,52 @@ +package moviegoods.movie.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.argumentresolver.Login; +import moviegoods.movie.domain.dto.main.MainDailyCommunityRequestDto; +import moviegoods.movie.domain.dto.main.MainDailyCommunityResponseDto; +import moviegoods.movie.domain.dto.main.MainEventLimitResponseDto; +import moviegoods.movie.domain.dto.main.MainVideoResponseDto; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.MainService; +import moviegoods.movie.service.MovieVideoService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.text.ParseException; +import java.util.List; + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/main") +public class MainController { + private final MainService mainService; + private final MovieVideoService movieVideoService; + + @GetMapping("/video") + public MainVideoResponseDto video() throws IOException { + String src=movieVideoService.startDriver(); + MainVideoResponseDto mainVideoResponseDto=new MainVideoResponseDto(); + mainVideoResponseDto.setSrc(src); + return mainVideoResponseDto; + } + + @GetMapping("/event-limit") + public ResponseEntity> eventLimit(@Login User loginUser){ + List list = mainService.eventLimit(loginUser); + ResponseEntity> result = new ResponseEntity<>(list, HttpStatus.OK); + return result; + } + + @GetMapping("/daily-community") + public ResponseEntity> dailyCommunity(@ModelAttribute MainDailyCommunityRequestDto requestDto) { + List list = mainService.dailyCommunity(requestDto); + ResponseEntity> result = new ResponseEntity<>(list, HttpStatus.OK); + return result; + } + + +} diff --git a/backend/src/main/java/moviegoods/movie/controller/ManagerController.java b/backend/src/main/java/moviegoods/movie/controller/ManagerController.java new file mode 100644 index 0000000..4d0c5b3 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/ManagerController.java @@ -0,0 +1,40 @@ +package moviegoods.movie.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.manager.ManagerRequestDto; +import moviegoods.movie.domain.dto.manager.ManagerResponseDto; +import moviegoods.movie.service.ManagerService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/manager/report") +public class ManagerController { + + private final ManagerService managerService; + + @GetMapping + public ResponseEntity>> show() { + List reportsList = managerService.show(); + Map> reportJson = new HashMap<>(); + reportJson.put("reports", reportsList); + + ResponseEntity>> result = new ResponseEntity<>(reportJson, HttpStatus.OK); + return result; + } + + @PatchMapping + public ResultResponseDto approve(@RequestBody ManagerRequestDto requestDto) { + ResultResponseDto result = managerService.approve(requestDto.getUser_id()); + return result; + } +} diff --git a/backend/src/main/java/moviegoods/movie/controller/MyPageController.java b/backend/src/main/java/moviegoods/movie/controller/MyPageController.java new file mode 100644 index 0000000..ab94447 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/MyPageController.java @@ -0,0 +1,77 @@ +package moviegoods.movie.controller; + + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.argumentresolver.Login; +import moviegoods.movie.domain.dto.mypage.*; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.MyPageService; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + + @RestController + @Slf4j + @RequiredArgsConstructor + @RequestMapping("/mypage") + public class MyPageController { + + + private final MyPageService myPageService; + + @GetMapping + public MyPageResponseSearch searchMyPage(@Login User loginUser, @ModelAttribute MyPageRequestSearch mprs){ + MyPageResponseSearch myPageResponseSearch=myPageService.search(loginUser,mprs); + + return myPageResponseSearch; + } + + + @PatchMapping("/profile") + public Result updateProfile(@Login User loginUser, @RequestParam(value="file",required = false)MultipartFile file + )throws Exception{ + + MyPageRequestProfile mprp=new MyPageRequestProfile(); + mprp.setProfile_image(file); + + myPageService.updateProfile(loginUser,mprp); + Result result=new Result(); + result.setResult(true); + return result; + } + + @PatchMapping("/nickname") + public Result updateNickname(@Login User loginUser,@RequestBody MyPageRequestNickname mrnn){ + Result result=new Result(); + String name=myPageService.updateNickname(loginUser,mrnn); + if(mrnn.getNickname().equals(name)){ + result.setResult(true); + } + else{ + result.setResult(false); + } + return result; + + } + + @DeleteMapping("/withdrawal") + public Result withdrawal(@Login User loginUser, @RequestBody MyPageRequestWithdrawal mrwd){ + Boolean check= myPageService.withdrawal(loginUser,mrwd); + Result result=new Result(); + if(check==true){ + result.setResult(true); + }else{ + result.setResult(false); + } + return result; + + } + + @PostMapping("/duplicate-check") + public Result nicknameDuplicate(@RequestBody MyPageRequestNicknameDuplicateDto mprnd){ + Result result= myPageService.nicknameDuplicate(mprnd); + return result; + + } + } + diff --git a/backend/src/main/java/moviegoods/movie/controller/SignInController.java b/backend/src/main/java/moviegoods/movie/controller/SignInController.java new file mode 100644 index 0000000..82c4ab1 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/SignInController.java @@ -0,0 +1,44 @@ +package moviegoods.movie.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.signin.SignInRequestDto; +import moviegoods.movie.domain.dto.signin.SignInResponseDto; +import moviegoods.movie.service.SignInService; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/signin") +public class SignInController { + + private final SignInService signInService; + + @PostMapping + public SignInResponseDto login(@RequestBody SignInRequestDto requestDto, HttpServletRequest httpServletRequest) { + + return signInService.login(requestDto, httpServletRequest); + } + + @ResponseBody + @GetMapping("/oauth2/code/kakao") + public SignInRequestDto kakaoCallback(@RequestParam String code, HttpServletRequest httpServletRequest){ + + String access_Token = signInService.getKaKaoAccessToken(code); + SignInRequestDto userInfo = signInService.getUserInfo(access_Token); + + return userInfo; + + } + + @GetMapping("/auth/google/callback") + public SignInRequestDto googleCallback(@RequestParam String code) { + String access_Token = signInService.googleRequestAccessToken(code); + SignInRequestDto userInfo = signInService.googleGetUserInfo(access_Token); + + return userInfo; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/controller/SignUpController.java b/backend/src/main/java/moviegoods/movie/controller/SignUpController.java new file mode 100644 index 0000000..de934bd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/SignUpController.java @@ -0,0 +1,36 @@ +package moviegoods.movie.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.signup.SignUpDuplicateCheckRequestDto; +import moviegoods.movie.domain.dto.signup.SignUpRequestDto; +import moviegoods.movie.domain.entity.User.Method; +import moviegoods.movie.service.SignUpService; +import org.springframework.web.bind.annotation.*; + + +@RestController +@RequiredArgsConstructor +@RequestMapping("/signup") +public class SignUpController { + + private final SignUpService signUpService; + + @PostMapping + public ResultResponseDto signup(@RequestBody SignUpRequestDto requestDto){ + ResultResponseDto resultResponseDto = signUpService.saveUser(requestDto, Method.일반); + + return resultResponseDto; + } + + @PostMapping("/duplicate-check") + public ResultResponseDto duplicateCheck(@RequestBody SignUpDuplicateCheckRequestDto requestDto){ + ResultResponseDto resultResponseDto = signUpService.duplicateCheck(requestDto,Method.일반); + + return resultResponseDto; + } + +} + + diff --git a/backend/src/main/java/moviegoods/movie/controller/TransactionsController.java b/backend/src/main/java/moviegoods/movie/controller/TransactionsController.java new file mode 100644 index 0000000..6bc3d78 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/controller/TransactionsController.java @@ -0,0 +1,83 @@ +package moviegoods.movie.controller; + + +import lombok.RequiredArgsConstructor; +import moviegoods.movie.domain.argumentresolver.Login; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.service.TransactionsService; +import moviegoods.movie.domain.dto.transactions.*; +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 +@RequiredArgsConstructor +@RequestMapping("/transactions") +public class TransactionsController { + + private final TransactionsService transactionsService; + + @PostMapping("/write") + public ResponseEntity write(@Login User loginUser, @RequestBody TransactionsSaveRequestDto requestDto) { + ResultResponseDto resultResponseDto = transactionsService.write(loginUser,requestDto); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + + @GetMapping("/search") + public ResponseEntity> search(@Login User loginUser, @ModelAttribute TransactionsSearchRequestDto requestDto) { + List list = transactionsService.search(loginUser, requestDto); + ResponseEntity> result = new ResponseEntity<>(list, HttpStatus.OK); + + return result; + } + + @PostMapping("/change-status") + public ResultResponseDto changeStatus(@Login User loginUser, @RequestBody TransactionsChangeStatusRequestDto requestDto) { + ResultResponseDto resultResponseDto = transactionsService.changeStatus(loginUser, requestDto); + + return resultResponseDto; + } + + @DeleteMapping + public ResultResponseDto delete(@Login User loginUser, @RequestBody TransactionsDeleteRequestDto requestDto) { + ResultResponseDto resultResponseDto = transactionsService.delete(loginUser, requestDto); + + return resultResponseDto; + } + + @PostMapping("/report") + public ResponseEntity report(@Login User loginUser, @RequestBody TransactionsReportRequestDto requestDto) { + ResultResponseDto resultResponseDto = transactionsService.report(loginUser, requestDto); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } + + @PostMapping("/like") + public ResponseEntity like(@Login User loginUser, @RequestBody TransactionsLikeRequestDto requestDto) throws ParseException { + ResultResponseDto resultResponseDto = transactionsService.like(loginUser, requestDto); + ResponseEntity result; + result = new ResponseEntity<>(resultResponseDto, HttpStatus.OK); + + if (!resultResponseDto.isResult()) { + result = new ResponseEntity<>(resultResponseDto, HttpStatus.UNAUTHORIZED); + } + + return result; + } +} diff --git a/backend/src/main/java/moviegoods/movie/domain/argumentresolver/Login.java b/backend/src/main/java/moviegoods/movie/domain/argumentresolver/Login.java new file mode 100644 index 0000000..05c0690 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/argumentresolver/Login.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.argumentresolver; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface Login { +} + diff --git a/backend/src/main/java/moviegoods/movie/domain/argumentresolver/LoginMemberArgumentResolver.java b/backend/src/main/java/moviegoods/movie/domain/argumentresolver/LoginMemberArgumentResolver.java new file mode 100644 index 0000000..db7336a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/argumentresolver/LoginMemberArgumentResolver.java @@ -0,0 +1,36 @@ +package moviegoods.movie.domain.argumentresolver; + +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.entity.User.User; +import org.springframework.core.MethodParameter; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; +import moviegoods.movie.configure.SessionConfig.SessionConst; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +@Slf4j +public class LoginMemberArgumentResolver implements HandlerMethodArgumentResolver { + @Override + public boolean supportsParameter(MethodParameter parameter) { + + boolean hasLoginAnnotation = parameter.hasParameterAnnotation(Login.class); + boolean hasMemberType = User.class.isAssignableFrom(parameter.getParameterType()); + + return hasLoginAnnotation && hasMemberType; + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { + + HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); + HttpSession session = request.getSession(false); + if (session == null) { + return null; + } + User user = (User)session.getAttribute(SessionConst.LOGIN_MEMBER); + return user; + } +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerRequestDto.java new file mode 100644 index 0000000..7d036cc --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerRequestDto.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.manager; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ManagerRequestDto { + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerResponseDto.java new file mode 100644 index 0000000..40f9658 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/Manager/ManagerResponseDto.java @@ -0,0 +1,22 @@ +package moviegoods.movie.domain.dto.manager; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ManagerResponseDto { + + private String report_content; + private LocalDateTime written_date; + private String nickname; + private Long user_id; + private Long reported_user_id; + private String reported_nickname; + private String reported_content; + private Boolean is_complete; +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/booleanResult/ResultResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/booleanResult/ResultResponseDto.java new file mode 100644 index 0000000..98b63d4 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/booleanResult/ResultResponseDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.booleanResult; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.context.annotation.Bean; + +import javax.persistence.Entity; + +@Data +@NoArgsConstructor +public class ResultResponseDto { + private boolean result; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/comments/Comments.java b/backend/src/main/java/moviegoods/movie/domain/dto/comments/Comments.java new file mode 100644 index 0000000..8810b60 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/comments/Comments.java @@ -0,0 +1,30 @@ +package moviegoods.movie.domain.dto.comments; + +import lombok.AllArgsConstructor; +import lombok.Data; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + + +@Data +@AllArgsConstructor +public class Comments { + private Long comment_id; + private Long user_id; + private String comment_nickname; + private String comment_content; + private Boolean is_mine; + private LocalDateTime comment_written_date; + private UserStatus user_status; + + public Comments(Long user_id, String comment_nickname, String comment_content, LocalDateTime comment_written_date, Long comment_id, UserStatus status){ + this.comment_id=comment_id; + this.user_id=user_id; + this.comment_nickname=comment_nickname; + this.comment_content=comment_content; + this.comment_written_date=comment_written_date; + this.user_status=status; + + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessage.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessage.java new file mode 100644 index 0000000..a668425 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessage.java @@ -0,0 +1,21 @@ +package moviegoods.movie.domain.dto.directMessage; + +import lombok.Getter; +import lombok.Setter; + +import java.time.LocalDateTime; + + +@Getter +@Setter +public class DirectMessage { + + private String image_url; + private String content; + private Long chat_room_id; + private String nickname; + private Long user_id; + private LocalDateTime written_date; + + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomRequestDto.java new file mode 100644 index 0000000..03b3927 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomRequestDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.directMessage; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DirectMessageCreateRoomRequestDto { + + Long user_id; + Long transaction_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomResponseDto.java new file mode 100644 index 0000000..3a959ec --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageCreateRoomResponseDto.java @@ -0,0 +1,27 @@ +package moviegoods.movie.domain.dto.directMessage; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DirectMessageCreateRoomResponseDto { + + private boolean result; + private Long chat_room_id; + private Long not_mine_id; + private String not_mine_nickname; + private String not_mine_profile_url; + private Long not_mine_reliability; + private UserStatus user_status; + private UserStatus not_mine_user_status; + private Long transaction_id; + private Boolean is_complete; + private String recent_message; + private LocalDateTime recent_message_date; +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageDetailResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageDetailResponseDto.java new file mode 100644 index 0000000..6f83469 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageDetailResponseDto.java @@ -0,0 +1,21 @@ +package moviegoods.movie.domain.dto.directMessage; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DirectMessageDetailResponseDto { + + private String content; + private LocalDateTime written_date; + private String image_url; + private Long user_id; + private String nickname; + private String profile_url; + private Long reliability; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageListResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageListResponseDto.java new file mode 100644 index 0000000..fd4abff --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageListResponseDto.java @@ -0,0 +1,28 @@ +package moviegoods.movie.domain.dto.directMessage; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DirectMessageListResponseDto { + + private Long chat_room_id; + + private Long not_mine_id; + private String not_mine_nickname; + private String not_mine_profile_url; + private Long not_mine_reliability; + private UserStatus not_mine_user_status; + + private Long transaction_id; + private Boolean is_complete; + + private String recent_message; + private LocalDateTime recent_message_date; +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestComplete.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestComplete.java new file mode 100644 index 0000000..6f75d6d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestComplete.java @@ -0,0 +1,9 @@ +package moviegoods.movie.domain.dto.directMessage; + + +import lombok.Data; + +@Data +public class DirectMessageRequestComplete { //구매자한테만 구매완료 버튼 보이도록 + Long transaction_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReliability.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReliability.java new file mode 100644 index 0000000..9f7117c --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReliability.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.dto.directMessage; + + +import lombok.Data; + +@Data +public class DirectMessageRequestReliability { + + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReport.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReport.java new file mode 100644 index 0000000..14f442d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/DirectMessageRequestReport.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.directMessage; + + +import lombok.Data; + +@Data +public class DirectMessageRequestReport { + + Long transaction_id; + Long user_id; + String report_content; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/Result.java b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/Result.java new file mode 100644 index 0000000..8aaa611 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/directMessage/Result.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.dto.directMessage; + + +import lombok.Data; + +@Data +public class Result { + + private boolean result; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailRequestDto.java new file mode 100644 index 0000000..6987edc --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailRequestDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EventsDetailRequestDto { + private Long user_id; + private Long event_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailResponseDto.java new file mode 100644 index 0000000..db4c26b --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsDetailResponseDto.java @@ -0,0 +1,27 @@ +package moviegoods.movie.domain.dto.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; +import moviegoods.movie.domain.dto.mypage.MyPageLikeEvent; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EventsDetailResponseDto { + private Long event_id; + private String cinema_name; + private String title; + private List detail_image_url=new ArrayList<>(); + private String link_url; + private Date start_date; + private Date end_date; + private Long like_count; + private Boolean is_like; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsLikeRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsLikeRequestDto.java new file mode 100644 index 0000000..00892d2 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsLikeRequestDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EventsLikeRequestDto { + private Long user_id; + private Long event_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchRequestDto.java new file mode 100644 index 0000000..b12a2ac --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchRequestDto.java @@ -0,0 +1,16 @@ +package moviegoods.movie.domain.dto.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class EventsSearchRequestDto { + private String cinema_name; + private String search_word; + private String sort_criteria; + private Boolean is_end; + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchResponseDto.java new file mode 100644 index 0000000..977b208 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/events/EventsSearchResponseDto.java @@ -0,0 +1,23 @@ +package moviegoods.movie.domain.dto.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EventsSearchResponseDto { + private String cinema_name; + private Long event_id; + private String thumbnail_url; + private String title; + private Date start_date; + private Date end_date; + private Boolean is_like; + private Boolean is_end; + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentDeleteRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentDeleteRequestDto.java new file mode 100644 index 0000000..63f8116 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentDeleteRequestDto.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralBoardCommentDeleteRequestDto { + Long comment_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentRequestDto.java new file mode 100644 index 0000000..5f82e2b --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardCommentRequestDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralBoardCommentRequestDto { + String content; + Long post_id; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailDeleteRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailDeleteRequestDto.java new file mode 100644 index 0000000..b490c30 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailDeleteRequestDto.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralBoardDetailDeleteRequestDto { + Long post_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailRequestDto.java new file mode 100644 index 0000000..f09d7d1 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailRequestDto.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralBoardDetailRequestDto { + Long post_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailResponseDto.java new file mode 100644 index 0000000..bc346ba --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardDetailResponseDto.java @@ -0,0 +1,27 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.dto.comments.Comments; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralBoardDetailResponseDto { + private long post_id; + private String title; + private LocalDateTime written_date; + private String content; + private Long views; + private String nickname; + private String image_url ; + private Boolean is_mine; + + List comment=new ArrayList<>(); + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchRequestDto.java new file mode 100644 index 0000000..c3a5352 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchRequestDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +public class GeneralBoardSearchRequestDto { + String search_word; + String search_criteria; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchResponseDto.java new file mode 100644 index 0000000..0a912c7 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardSearchResponseDto.java @@ -0,0 +1,18 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@AllArgsConstructor +@NoArgsConstructor +@Data +public class GeneralBoardSearchResponseDto { + private Long post_id; + private String title; + private String nickname; + private LocalDateTime written_date; + private Long view; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardWriteRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardWriteRequestDto.java new file mode 100644 index 0000000..974dbf8 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/generalBoard/GeneralBoardWriteRequestDto.java @@ -0,0 +1,16 @@ +package moviegoods.movie.domain.dto.generalBoard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.web.multipart.MultipartFile; + + +@AllArgsConstructor +@NoArgsConstructor +@Data +public class GeneralBoardWriteRequestDto { + private String title; + private String content; + private MultipartFile image_url; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareDetailDTO.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareDetailDTO.java new file mode 100644 index 0000000..ff35b8c --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareDetailDTO.java @@ -0,0 +1,39 @@ +package moviegoods.movie.domain.dto.informationShare; + + + +import lombok.Data; + +import java.time.LocalDateTime; + + +@Data +public class InformationShareDetailDTO { + Long user_id; + String nickname; + Long views; + String title; + String image_url; + + LocalDateTime written_date; + String content; + String name; + String area; + String branch; + + public InformationShareDetailDTO(Long user_id, String nickname, Long views, String title, String image_url, + LocalDateTime written_date, String content, String name, String area, String branch){ + this.user_id=user_id; + this.nickname=nickname; + this.views=views; + this.title=title; + this.image_url=image_url; + this.written_date=written_date; + this.content=content; + this.name=name; + this.area=area; + this.branch=branch; + } + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteComment.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteComment.java new file mode 100644 index 0000000..e84992c --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteComment.java @@ -0,0 +1,11 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; + +@Data +public class InformationShareRequestDeleteComment { + + private Long user_id; + private Long comment_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteDetail.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteDetail.java new file mode 100644 index 0000000..9d29689 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDeleteDetail.java @@ -0,0 +1,11 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; + +@Data +public class InformationShareRequestDeleteDetail { + + private Long user_id; + private Long post_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDetail.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDetail.java new file mode 100644 index 0000000..dd454f6 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestDetail.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +public class InformationShareRequestDetail { + private Long post_id; + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSaveComment.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSaveComment.java new file mode 100644 index 0000000..aa882e5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSaveComment.java @@ -0,0 +1,11 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; + +@Data +public class InformationShareRequestSaveComment { + Long post_id; + Long user_id; + String content; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSearch.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSearch.java new file mode 100644 index 0000000..b667392 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestSearch.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; + +@Data +public class InformationShareRequestSearch { + private String search_word; + private String cinema_name; + private String cinema_area; + private String cinema_branch; + private String sort_name; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestWrite.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestWrite.java new file mode 100644 index 0000000..424ed00 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareRequestWrite.java @@ -0,0 +1,52 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.NotBlank; + +@Getter +@AllArgsConstructor +public class InformationShareRequestWrite { + + + + private Long user_id; + @NotBlank + private String title; + + @NotBlank + private String cinema_name; + + @NotBlank + private String cinema_area; + + @NotBlank + private String cinema_branch; + @NotBlank + private String content; + + private MultipartFile image_url; + + public InformationShareRequestWrite(){ + + } + + public InformationShareRequestWrite(Long user_id,MultipartFile image_url,String cinema_branch,String cinema_area,String cinema_name,String title,String content){ + this.cinema_area=cinema_area; + this.cinema_branch=cinema_branch; + this.cinema_name=cinema_name; + this.content=content; + this.title=title; + this.user_id=user_id; + this.image_url=image_url; + } + + + + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseDetail.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseDetail.java new file mode 100644 index 0000000..fa5ba77 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseDetail.java @@ -0,0 +1,38 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; +import moviegoods.movie.domain.dto.comments.Comments; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +public class InformationShareResponseDetail { + + private long post_id; + private String title; + private LocalDateTime written_date; + private String content; + private Long views; + private String nickname; + private String image_url ; + private String cinema_name; + private String cinema_area; + private String cinema_branch; + private Boolean is_mine; + private UserStatus user_status; + List comment=new ArrayList<>(); //댓글리스트 + + /* + private Long user_id; + private String comment_nickname; + private String comment_content; + private LocalDateTime comment_written_date; + */ + + + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseSearch.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseSearch.java new file mode 100644 index 0000000..3691477 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/InformationShareResponseSearch.java @@ -0,0 +1,18 @@ +package moviegoods.movie.domain.dto.informationShare; + +import lombok.Data; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + + +@Data +public class InformationShareResponseSearch { + + private Long post_id; //post + private String title; //post + private String nickname; //user + private LocalDateTime written_date; //content-detail + private Long view; //post + private UserStatus user_status; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/Result.java b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/Result.java new file mode 100644 index 0000000..651a3f5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/informationShare/Result.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.dto.informationShare; + + +import lombok.Data; + +@Data +public class Result { + + private boolean result; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/logout/LogOutRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/logout/LogOutRequestDto.java new file mode 100644 index 0000000..997e67a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/logout/LogOutRequestDto.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.dto.logout; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class LogOutRequestDto { + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityRequestDto.java new file mode 100644 index 0000000..82ce583 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityRequestDto.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.main; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MainDailyCommunityRequestDto { + private String community_category; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityResponseDto.java new file mode 100644 index 0000000..d5ef8b9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainDailyCommunityResponseDto.java @@ -0,0 +1,20 @@ +package moviegoods.movie.domain.dto.main; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MainDailyCommunityResponseDto { + private Long post_id; + private String title; + private String content; + private Long views; + private Long comments_num; + private LocalDateTime written_date; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/main/MainEventLimitResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainEventLimitResponseDto.java new file mode 100644 index 0000000..bbd8c21 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainEventLimitResponseDto.java @@ -0,0 +1,21 @@ +package moviegoods.movie.domain.dto.main; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MainEventLimitResponseDto { + private String cinema_name; + private Long event_id; + private String thumbnail_url; + private String title; + private Date start_date; + private Date end_date; + private Boolean is_like; +// private Boolean is_end; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/main/MainVideoResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainVideoResponseDto.java new file mode 100644 index 0000000..f4e0e5d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/main/MainVideoResponseDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.main; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MainVideoResponseDto { + + private String src; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageComment.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageComment.java new file mode 100644 index 0000000..08f9fa7 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageComment.java @@ -0,0 +1,23 @@ +package moviegoods.movie.domain.dto.mypage; + +import lombok.Data; + +import java.time.LocalDateTime; + + +@Data +public class MyPageComment { + Long comment_id; + String comment_content; + LocalDateTime written_date ; + String category; + Long post_id; + + public MyPageComment(Long comment_id, String comment_content, LocalDateTime written_date,String category,Long post_id){ + this.comment_content=comment_content; + this.comment_id=comment_id; + this.written_date=written_date; + this.category=category; + this.post_id=post_id; + } +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageContent.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageContent.java new file mode 100644 index 0000000..19d9a5d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageContent.java @@ -0,0 +1,24 @@ +package moviegoods.movie.domain.dto.mypage; + +import lombok.Data; + +import java.time.LocalDateTime; + + +@Data +public class MyPageContent { + + Long post_id; + String title; + LocalDateTime written_date; + String category; + String content; + + public MyPageContent(Long post_id, String title, LocalDateTime written_date, String category, String content){ + this.category=category; + this.post_id=post_id; + this.title=title; + this.written_date=written_date; + this.content=content; + } +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageLikeEvent.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageLikeEvent.java new file mode 100644 index 0000000..e688337 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageLikeEvent.java @@ -0,0 +1,25 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; + +import java.util.Date; + +@Data +public class MyPageLikeEvent { + + // 좋아요한 이벤트 + private Long event_id; + private String title; + private String thumbnail_url; + private Date end_date; + private Date start_date; + + public MyPageLikeEvent(Long event_id, String title, String thumbnail_url,Date start_date,Date end_date){ + this.event_id=event_id; + this.title=title; + this.thumbnail_url=thumbnail_url; + this.start_date=start_date; + this.end_date=end_date; + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNickname.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNickname.java new file mode 100644 index 0000000..c05c131 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNickname.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class MyPageRequestNickname { + private Long user_id; + private String nickname; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNicknameDuplicateDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNicknameDuplicateDto.java new file mode 100644 index 0000000..2340da1 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestNicknameDuplicateDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MyPageRequestNicknameDuplicateDto { + + private String nickname; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestProfile.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestProfile.java new file mode 100644 index 0000000..875fdcd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestProfile.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +public class MyPageRequestProfile { + private MultipartFile profile_image; + private Long user_id; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestSearch.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestSearch.java new file mode 100644 index 0000000..b864711 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestSearch.java @@ -0,0 +1,12 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class MyPageRequestSearch { + + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestWithdrawal.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestWithdrawal.java new file mode 100644 index 0000000..73125d9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageRequestWithdrawal.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; + +@Data +public class MyPageRequestWithdrawal { + + private Long user_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageResponseSearch.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageResponseSearch.java new file mode 100644 index 0000000..1f2d929 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageResponseSearch.java @@ -0,0 +1,24 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Data +@RequiredArgsConstructor +public class MyPageResponseSearch { + + private List comment=new ArrayList<>(); + private List content=new ArrayList<>(); + private List likeEvent=new ArrayList<>(); + private MyPageUser user; + private List likeTransaction=new ArrayList<>(); + private List writeTransaction=new ArrayList<>(); + + + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageTransaction.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageTransaction.java new file mode 100644 index 0000000..a7adc92 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageTransaction.java @@ -0,0 +1,37 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import moviegoods.movie.domain.entity.Transaction.Status; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + +@Data +public class MyPageTransaction { + + Long transaction_id; + String content; + LocalDateTime written_date; + String nickname; + Long reliability; + Boolean is_mine; + Status status; + UserStatus user_status; + String profile_url; + + + + public MyPageTransaction(Long transaction_id, String content, LocalDateTime written_date,String nickname,Long reliability,Boolean is_mine,Status status,String profile_url,UserStatus user_status){ + this.transaction_id=transaction_id; + this.content=content; + this.written_date=written_date; + this.nickname=nickname; + this.reliability=reliability; + this.is_mine=is_mine; + this.status=status; + this.profile_url=profile_url; + this.user_status=user_status; + + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageUser.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageUser.java new file mode 100644 index 0000000..cda3eab --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/MyPageUser.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class MyPageUser { + + private String nickname; + private String profile_url; + private Long reliability; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/mypage/Result.java b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/Result.java new file mode 100644 index 0000000..cadcb98 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/mypage/Result.java @@ -0,0 +1,11 @@ +package moviegoods.movie.domain.dto.mypage; + + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class Result { + Boolean result; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInRequestDto.java new file mode 100644 index 0000000..c397ac0 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInRequestDto.java @@ -0,0 +1,17 @@ +package moviegoods.movie.domain.dto.signin; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Component +public class SignInRequestDto { + private String email; + private String password; + private String method; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInResponseDto.java new file mode 100644 index 0000000..0818dc2 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/signin/SignInResponseDto.java @@ -0,0 +1,17 @@ +package moviegoods.movie.domain.dto.signin; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.User.UserStatus; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SignInResponseDto { + private String nickname; + private String image_url; + private UserStatus user_status; + private Boolean result; + private String authority; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpDuplicateCheckRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpDuplicateCheckRequestDto.java new file mode 100644 index 0000000..2f4a4d9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpDuplicateCheckRequestDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.signup; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SignUpDuplicateCheckRequestDto { + private String email; + private String nickname; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpRequestDto.java new file mode 100644 index 0000000..fe1334c --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/signup/SignUpRequestDto.java @@ -0,0 +1,19 @@ +package moviegoods.movie.domain.dto.signup; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Component +public class SignUpRequestDto { + private String email; + private String nickname; + private String password; + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsChangeStatusRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsChangeStatusRequestDto.java new file mode 100644 index 0000000..26a8c36 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsChangeStatusRequestDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TransactionsChangeStatusRequestDto { + private Long user_id; + private Long transaction_id; + private String status; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsDeleteRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsDeleteRequestDto.java new file mode 100644 index 0000000..b50bd4e --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsDeleteRequestDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TransactionsDeleteRequestDto { + private Long user_id; + private Long transaction_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsLikeRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsLikeRequestDto.java new file mode 100644 index 0000000..b2d13e3 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsLikeRequestDto.java @@ -0,0 +1,13 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TransactionsLikeRequestDto { + private Long user_id; + private Long transaction_id; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsReportRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsReportRequestDto.java new file mode 100644 index 0000000..7414535 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsReportRequestDto.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TransactionsReportRequestDto { + private Long user_id; + private Long transaction_id; + private String content; +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSaveRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSaveRequestDto.java new file mode 100644 index 0000000..709b560 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSaveRequestDto.java @@ -0,0 +1,20 @@ +package moviegoods.movie.domain.dto.transactions; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TransactionsSaveRequestDto { + + private String content; + private Long user_id; + + +// public Transaction toEntity() { +// return Transaction.builder().user(user).content_detail(content_detail).build(); +// } +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchRequestDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchRequestDto.java new file mode 100644 index 0000000..2c831db --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchRequestDto.java @@ -0,0 +1,19 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TransactionsSearchRequestDto { + private Long user_id; + private Boolean is_proceed; + private String search_word; + private String sort_criteria; + private String search_criteria; + private Long start; + private Long end; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchResponseDto.java b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchResponseDto.java new file mode 100644 index 0000000..a07f8de --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/dto/transactions/TransactionsSearchResponseDto.java @@ -0,0 +1,27 @@ +package moviegoods.movie.domain.dto.transactions; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.User.UserStatus; + +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TransactionsSearchResponseDto { + private Long user_id; + private String content; + private String status; + private UserStatus user_status; + private Long transaction_id; + private Long reliability; + private LocalDateTime written_date; + private Boolean is_mine; + private Boolean is_like; + private String nickname; + private String profile_url; + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/ChatRoomRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/ChatRoomRepository.java new file mode 100644 index 0000000..3cab6c5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/ChatRoomRepository.java @@ -0,0 +1,9 @@ +package moviegoods.movie.domain.entity.ChatRoom; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface ChatRoomRepository extends JpaRepository { + Optional findById(Long chat_room_id); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/Chat_Room.java b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/Chat_Room.java new file mode 100644 index 0000000..40b0136 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoom/Chat_Room.java @@ -0,0 +1,41 @@ +package moviegoods.movie.domain.entity.ChatRoom; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.ChatRoomJoin.Chat_Room_Join; +import moviegoods.movie.domain.entity.Message.Message; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Entity(name = "chat_room") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Chat_Room { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long chat_room_id; + + @NotNull + @DateTimeFormat + private LocalDateTime create_date; + + @OneToMany(mappedBy = "chat_room", cascade = CascadeType.ALL) + private List chat_room_joins = new ArrayList<>(); + + @OneToMany(mappedBy = "chat_room",cascade = CascadeType.ALL) + private List messages = new ArrayList<>(); + + @ManyToOne + @JoinColumn(name = "transaction_id") + private Transaction transaction; + +} + diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/ChatRoomJoinRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/ChatRoomJoinRepository.java new file mode 100644 index 0000000..54714d9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/ChatRoomJoinRepository.java @@ -0,0 +1,6 @@ +package moviegoods.movie.domain.entity.ChatRoomJoin; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ChatRoomJoinRepository extends JpaRepository { +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/Chat_Room_Join.java b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/Chat_Room_Join.java new file mode 100644 index 0000000..3a60407 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/ChatRoomJoin/Chat_Room_Join.java @@ -0,0 +1,30 @@ +package moviegoods.movie.domain.entity.ChatRoomJoin; + +import javax.persistence.*; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.ChatRoom.Chat_Room; +import moviegoods.movie.domain.entity.User.User; + +@Entity(name = "chat_room_join") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Chat_Room_Join { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long chat_room_join_id; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "chat_room_id") + private Chat_Room chat_room; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/Cinema.java b/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/Cinema.java new file mode 100644 index 0000000..5437995 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/Cinema.java @@ -0,0 +1,43 @@ +package moviegoods.movie.domain.entity.Cinema; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Event.Event; +import moviegoods.movie.domain.entity.Post.Post; + +import javax.persistence.*; +import javax.validation.constraints.NotBlank; + +@Builder +@Data +@AllArgsConstructor +@Entity(name="cinema") +@NoArgsConstructor +public class Cinema { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long cinema_id; + + @NotBlank + @Column(length = 30) + private String name; + + @Column(length = 30) + private String area; + + @Column(length = 50) + private String branch; + + @OneToOne(mappedBy = "cinema") + private Post post; + + @OneToOne(mappedBy = "cinema") + private Event event; + + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/CinemaRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/CinemaRepository.java new file mode 100644 index 0000000..f6692d9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Cinema/CinemaRepository.java @@ -0,0 +1,6 @@ +package moviegoods.movie.domain.entity.Cinema; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CinemaRepository extends JpaRepository { +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Comment/Comment.java b/backend/src/main/java/moviegoods/movie/domain/entity/Comment/Comment.java new file mode 100644 index 0000000..ce71615 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Comment/Comment.java @@ -0,0 +1,38 @@ +package moviegoods.movie.domain.entity.Comment; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.User.User; + +import javax.persistence.*; + +@Data +@Entity(name="comment") +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class Comment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long comment_id; + + @ManyToOne + @JoinColumn(name="post_id") + private Post post; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "content_detail_id") + private Content_Detail content_detail; + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Comment/CommentRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Comment/CommentRepository.java new file mode 100644 index 0000000..4b46ce1 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Comment/CommentRepository.java @@ -0,0 +1,6 @@ +package moviegoods.movie.domain.entity.Comment; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CommentRepository extends JpaRepository { +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/ContentDetailRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/ContentDetailRepository.java new file mode 100644 index 0000000..fd1bbc9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/ContentDetailRepository.java @@ -0,0 +1,9 @@ +package moviegoods.movie.domain.entity.Content_Detail; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface ContentDetailRepository extends JpaRepository { + Optional findById(Long content_detail_id); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/Content_Detail.java b/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/Content_Detail.java new file mode 100644 index 0000000..9b361c9 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Content_Detail/Content_Detail.java @@ -0,0 +1,51 @@ +package moviegoods.movie.domain.entity.Content_Detail; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Message.Message; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.Report.Report; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Entity(name = "content_detail") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class Content_Detail { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long content_detail_id; + + @Column(columnDefinition = "TEXT") + private String content; + + @NotNull + @DateTimeFormat + private LocalDateTime written_date; + + @OneToOne(mappedBy = "content_detail") + private Post post; + + @OneToOne(mappedBy = "content_detail") + private Message message; + + @OneToOne(mappedBy = "content_detail") + private Comment comment; + + @OneToOne(mappedBy = "content_detail") + private Transaction transaction; + + @OneToOne(mappedBy = "content_detail") + private Report report; + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Event/Event.java b/backend/src/main/java/moviegoods/movie/domain/entity/Event/Event.java new file mode 100644 index 0000000..9745714 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Event/Event.java @@ -0,0 +1,58 @@ +package moviegoods.movie.domain.entity.Event; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.validation.constraints.NotBlank; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Cinema.Cinema; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; + +@Entity(name = "event") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Event { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long event_id; + + @NotBlank + @Column(length = 100) + private String title; + + @NotBlank + @Column(columnDefinition = "TEXT") + private String thumbnail_url; + + @NotBlank + @Column(columnDefinition = "TEXT") + private String detail_image_url; + + @NotBlank + @Column(columnDefinition = "TEXT") + private String link_url; + + @Temporal(TemporalType.DATE) + private java.util.Date start_date; + + @Temporal(TemporalType.DATE) + private java.util.Date end_date; + + private Long like_count = 0L; + + @OneToOne + @JoinColumn(name = "cinema_id") + private Cinema cinema; + + @OneToMany(mappedBy = "event", orphanRemoval = true) + private List likes = new ArrayList<>(); + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Event/EventRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Event/EventRepository.java new file mode 100644 index 0000000..948b73b --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Event/EventRepository.java @@ -0,0 +1,9 @@ +package moviegoods.movie.domain.entity.Event; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface EventRepository extends JpaRepository { + Optional findById(Long event_id); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/LikeBasketRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/LikeBasketRepository.java new file mode 100644 index 0000000..c190dbe --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/LikeBasketRepository.java @@ -0,0 +1,8 @@ +package moviegoods.movie.domain.entity.Like_Basket; + +import org.springframework.data.jpa.repository.JpaRepository; + + +public interface LikeBasketRepository extends JpaRepository { + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/Like_Basket.java b/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/Like_Basket.java new file mode 100644 index 0000000..245a253 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Like_Basket/Like_Basket.java @@ -0,0 +1,35 @@ +package moviegoods.movie.domain.entity.Like_Basket; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Event.Event; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.User.User; + +import javax.persistence.*; + +@Entity(name = "like_basket") +@Data +@AllArgsConstructor +@Builder +@NoArgsConstructor +public class Like_Basket { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long like_basket_id; + + @ManyToOne + @JoinColumn(name = "event_id") + private Event event; + + @ManyToOne + @JoinColumn(name = "transaction_id") + private Transaction transaction; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Message/Message.java b/backend/src/main/java/moviegoods/movie/domain/entity/Message/Message.java new file mode 100644 index 0000000..1671b33 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Message/Message.java @@ -0,0 +1,40 @@ +package moviegoods.movie.domain.entity.Message; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.ChatRoom.Chat_Room; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.User.User; + +import javax.persistence.*; + +@Entity(name = "message") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class Message { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long message_id; + + @Column(columnDefinition = "TEXT") + private String image_url; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "chat_room_id") + private Chat_Room chat_room; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "content_detail_id") + private Content_Detail content_detail; + + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Message/MessageRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Message/MessageRepository.java new file mode 100644 index 0000000..6e55efc --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Message/MessageRepository.java @@ -0,0 +1,6 @@ +package moviegoods.movie.domain.entity.Message; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MessageRepository extends JpaRepository { +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Post/Post.java b/backend/src/main/java/moviegoods/movie/domain/entity/Post/Post.java new file mode 100644 index 0000000..74f4bef --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Post/Post.java @@ -0,0 +1,58 @@ +package moviegoods.movie.domain.entity.Post; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Cinema.Cinema; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.User.User; + +import javax.persistence.*; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Entity(name = "post") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Post { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long post_id; + + @Column(columnDefinition = "TEXT") + private String image_url; + + @NotNull + @Column(columnDefinition = "bigint default 0") + private Long views; + + @NotBlank + @Column(length = 100) + private String title; + + @NotBlank + @Column(length = 50) + private String category; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "content_detail_id") + private Content_Detail content_detail; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "cinema_id") + private Cinema cinema; + + @OneToMany(mappedBy = "post", cascade = CascadeType.ALL) + private List comments = new ArrayList<>(); +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Post/PostRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Post/PostRepository.java new file mode 100644 index 0000000..2a3998e --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Post/PostRepository.java @@ -0,0 +1,10 @@ +package moviegoods.movie.domain.entity.Post; + +import moviegoods.movie.domain.entity.Transaction.Transaction; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface PostRepository extends JpaRepository { + Optional findById(Long post_id); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Report/Report.java b/backend/src/main/java/moviegoods/movie/domain/entity/Report/Report.java new file mode 100644 index 0000000..fcbf068 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Report/Report.java @@ -0,0 +1,39 @@ +package moviegoods.movie.domain.entity.Report; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.*; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.User.User; + +@Entity(name = "report") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Report { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long report_id; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "transaction_id") + private Transaction transaction; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "content_detail_id") + private Content_Detail content_detail; + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Report/ReportRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Report/ReportRepository.java new file mode 100644 index 0000000..ce981d7 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Report/ReportRepository.java @@ -0,0 +1,7 @@ +package moviegoods.movie.domain.entity.Report; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReportRepository extends JpaRepository { + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Status.java b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Status.java new file mode 100644 index 0000000..1262e4d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Status.java @@ -0,0 +1,5 @@ +package moviegoods.movie.domain.entity.Transaction; + +public enum Status { + 진행중, 마감 +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Transaction.java b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Transaction.java new file mode 100644 index 0000000..804b8ba --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/Transaction.java @@ -0,0 +1,53 @@ +package moviegoods.movie.domain.entity.Transaction; + +import javax.persistence.*; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.ChatRoom.Chat_Room; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; +import moviegoods.movie.domain.entity.Report.Report; +import moviegoods.movie.domain.entity.User.User; +import org.hibernate.annotations.DynamicUpdate; + +import java.util.ArrayList; +import java.util.List; + +@Entity(name = "transaction") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@DynamicUpdate +public class Transaction { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long transaction_id; + + @Enumerated(EnumType.STRING) + private Status status; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "content_detail_id") + private Content_Detail content_detail; + + @OneToMany(mappedBy = "transaction", cascade = CascadeType.ALL) + private List chat_rooms = new ArrayList<>(); + + @OneToMany(mappedBy = "transaction", cascade = CascadeType.ALL) + private List reports = new ArrayList<>(); + + @OneToMany(mappedBy = "transaction", orphanRemoval = true) + private List likes = new ArrayList<>(); + + + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/TransactionRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/TransactionRepository.java new file mode 100644 index 0000000..4fe2ff8 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/Transaction/TransactionRepository.java @@ -0,0 +1,9 @@ +package moviegoods.movie.domain.entity.Transaction; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface TransactionRepository extends JpaRepository { + Optional findById(Long transaction_id); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/User/Authority.java b/backend/src/main/java/moviegoods/movie/domain/entity/User/Authority.java new file mode 100644 index 0000000..e34760e --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/User/Authority.java @@ -0,0 +1,5 @@ +package moviegoods.movie.domain.entity.User; + +public enum Authority { + 관리자, 일반 +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/User/Method.java b/backend/src/main/java/moviegoods/movie/domain/entity/User/Method.java new file mode 100644 index 0000000..7b259dd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/User/Method.java @@ -0,0 +1,5 @@ +package moviegoods.movie.domain.entity.User; + +public enum Method { + 일반, 구글, 카카오 +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/User/User.java b/backend/src/main/java/moviegoods/movie/domain/entity/User/User.java new file mode 100644 index 0000000..ed20593 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/User/User.java @@ -0,0 +1,86 @@ +package moviegoods.movie.domain.entity.User; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import moviegoods.movie.domain.entity.ChatRoomJoin.Chat_Room_Join; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; +import moviegoods.movie.domain.entity.Message.Message; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.Report.Report; +import moviegoods.movie.domain.entity.Transaction.Transaction; + +import javax.persistence.*; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Data +@Entity(name = "user") +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long user_id; + + @NotBlank + @Column(length = 100) + private String email; + + @NotBlank + @Column(length = 30) + private String nickname; + + @NotBlank + @Column(columnDefinition = "TEXT") + private String password; + + @NotBlank + @Column(columnDefinition = "TEXT") + private String profile_url; + + @NotNull + @Enumerated(EnumType.STRING) + private Authority authority; + + @NotNull + @Column(columnDefinition = "bigint default 0") + private Long reliability; + + @NotNull + @Enumerated(EnumType.STRING) + private UserStatus user_status; + + @NotNull + @Enumerated(EnumType.STRING) + private Method method; + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List posts = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List transactions = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List comments = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List chat_room_joins = new ArrayList<>(); + + @OneToMany(mappedBy = "user",orphanRemoval = true) + private List likes = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List messages = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List reports = new ArrayList<>(); + + +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/User/UserRepository.java b/backend/src/main/java/moviegoods/movie/domain/entity/User/UserRepository.java new file mode 100644 index 0000000..b5979a3 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/User/UserRepository.java @@ -0,0 +1,14 @@ +package moviegoods.movie.domain.entity.User; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface UserRepository extends JpaRepository { + + Optional findById(Long user_id); + Optional findByEmail(String email); + Optional findByNickname(String nickname); + + Optional findByEmailAndMethod(String email, Method method); +} diff --git a/backend/src/main/java/moviegoods/movie/domain/entity/User/UserStatus.java b/backend/src/main/java/moviegoods/movie/domain/entity/User/UserStatus.java new file mode 100644 index 0000000..9047276 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/entity/User/UserStatus.java @@ -0,0 +1,5 @@ +package moviegoods.movie.domain.entity.User; + +public enum UserStatus { + 정상, 정지, 탈퇴 +} diff --git a/backend/src/main/java/moviegoods/movie/domain/interceptor/HttpHandshakeInterceptor.java b/backend/src/main/java/moviegoods/movie/domain/interceptor/HttpHandshakeInterceptor.java new file mode 100644 index 0000000..01f0ea2 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/interceptor/HttpHandshakeInterceptor.java @@ -0,0 +1,38 @@ +package moviegoods.movie.domain.interceptor; + +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.configure.SessionConfig; +import moviegoods.movie.domain.entity.User.User; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.http.server.ServletServerHttpRequest; +import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.server.HandshakeInterceptor; + +import javax.servlet.http.HttpSession; +import java.util.Map; +@Slf4j +public class HttpHandshakeInterceptor implements HandshakeInterceptor { + + @Override + public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, + Map attributes) throws Exception { + if (request instanceof ServletServerHttpRequest) { + ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; + HttpSession session = servletRequest.getServletRequest().getSession(false); + + if (session == null) { + return false; + } + User user = (User)session.getAttribute(SessionConfig.SessionConst.LOGIN_MEMBER); + + attributes.put(SessionConfig.SessionConst.LOGIN_MEMBER, user); + } + return true; + } + + @Override + public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { + + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/domain/interceptor/LoginCheckInterceptor.java b/backend/src/main/java/moviegoods/movie/domain/interceptor/LoginCheckInterceptor.java new file mode 100644 index 0000000..c1b82f5 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/domain/interceptor/LoginCheckInterceptor.java @@ -0,0 +1,38 @@ +package moviegoods.movie.domain.interceptor; + + +import moviegoods.movie.configure.SessionConfig.SessionConst; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.StringUtils; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +@Slf4j +public class LoginCheckInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String requestURI = request.getRequestURI(); + if(!request.getMethod().equals("GET")) { + return true; + } + + log.info("인증 체크 인터셉터 실행 {}", requestURI); + + HttpSession session = request.getSession(); + + if (session == null || session.getAttribute(SessionConst.LOGIN_MEMBER) == null) { + log.info("미인증 사용자 요청"); + //로그인으로 redirect + response.sendError(401); + +// response.sendRedirect("/signin?redirectURL=" + requestURI); + return false; + } + + return true; + } +} diff --git a/backend/src/main/java/moviegoods/movie/service/ChatRoomService.java b/backend/src/main/java/moviegoods/movie/service/ChatRoomService.java new file mode 100644 index 0000000..d397a73 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/ChatRoomService.java @@ -0,0 +1,261 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.directMessage.DirectMessageCreateRoomRequestDto; +import moviegoods.movie.domain.dto.directMessage.DirectMessageCreateRoomResponseDto; +import moviegoods.movie.domain.dto.directMessage.DirectMessageListResponseDto; +import moviegoods.movie.domain.entity.ChatRoom.ChatRoomRepository; +import moviegoods.movie.domain.entity.ChatRoom.Chat_Room; +import moviegoods.movie.domain.entity.ChatRoomJoin.ChatRoomJoinRepository; +import moviegoods.movie.domain.entity.ChatRoomJoin.Chat_Room_Join; +import moviegoods.movie.domain.entity.Message.Message; +import moviegoods.movie.domain.entity.Transaction.Status; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.Transaction.TransactionRepository; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import moviegoods.movie.domain.entity.User.UserStatus; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityManager; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; +import java.util.*; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ChatRoomService { + + private final EntityManager em; + private final ChatRoomRepository chatRoomRepository; + private final ChatRoomJoinRepository chatRoomJoinRepository; + private final TransactionRepository transactionRepository; + private final UserRepository userRepository; + + public DirectMessageCreateRoomResponseDto createRoom(User loginUser, DirectMessageCreateRoomRequestDto requestDto){ + + if (loginUser == null) { + DirectMessageCreateRoomResponseDto responseDto = + new DirectMessageCreateRoomResponseDto(false, null, null, null, null, null, null, null, null, null, null, null); + return responseDto; + } + //------------------------- + String recent_message = null; + LocalDateTime recent_message_date = null; + //------------------------- + Long user_id = loginUser.getUser_id(); + UserStatus user_status = loginUser.getUser_status(); + + log.info("transaction_id={}", requestDto.getTransaction_id()); + + Optional relatedTransaction = transactionRepository.findById(requestDto.getTransaction_id()); + if(relatedTransaction.isPresent()) { + Transaction transaction = relatedTransaction.get(); + Long transaction_id = transaction.getTransaction_id(); + Boolean is_complete = false; + Status transaction_status = transaction.getStatus(); + if(transaction_status.equals(Status.마감)) { + is_complete = true; + } + User notMineUser = transaction.getUser(); + Long not_mine_id = notMineUser.getUser_id(); + String not_mine_nickname = notMineUser.getNickname(); + String not_mine_profile_url = notMineUser.getProfile_url(); + Long not_mine_reliability = notMineUser.getReliability(); + UserStatus not_mine_user_status = notMineUser.getUser_status(); + + + //중복 확인 + boolean ifExistUserId = false; + boolean ifExixtWriterId = false; + Long exist_chat_room_id = null; + String searchChatRoomJpql = "select c from chat_room c where c.transaction = '" + transaction_id + "'"; + List list = em.createQuery(searchChatRoomJpql, Chat_Room.class).getResultList(); + for (Chat_Room chat_room : list) { + Long chat_room_id = chat_room.getChat_room_id(); + String searchChatRoomJoinJpql = "select j from chat_room_join j where j.chat_room = '" + chat_room_id + "'"; + List resultList = em.createQuery(searchChatRoomJoinJpql, Chat_Room_Join.class).getResultList(); + for (Chat_Room_Join chat_room_join : resultList) { + if(!ifExistUserId || !ifExixtWriterId) { + Long exist_user_id = chat_room_join.getUser().getUser_id(); + if(exist_user_id == user_id) { + ifExistUserId = true; + } + if(exist_user_id == not_mine_id) { + ifExixtWriterId = true; + } + } + else if(ifExistUserId && ifExixtWriterId) { + exist_chat_room_id = chat_room_id; + break; + } + } + } + + //중복일때 + if(ifExistUserId && ifExixtWriterId && (exist_chat_room_id != null)) { + DirectMessageCreateRoomResponseDto responseDto = + new DirectMessageCreateRoomResponseDto(true, + exist_chat_room_id, + not_mine_id, + not_mine_nickname, + not_mine_profile_url, + not_mine_reliability, + user_status, + not_mine_user_status, + transaction_id, + is_complete, + recent_message, + recent_message_date); + + return responseDto; + } + + //중복이 아닐때 + User user = userRepository.getById(user_id); + User writerUser = userRepository.getById(not_mine_id); + + Chat_Room chat_room = new Chat_Room(); + chat_room.setTransaction(transaction); + chat_room.setCreate_date(LocalDateTime.now()); + Chat_Room savedMessageRoom = chatRoomRepository.save(chat_room); + + Chat_Room_Join chat_room_join = new Chat_Room_Join(); + chat_room_join.setChat_room(savedMessageRoom); + chat_room_join.setUser(user); + Chat_Room_Join chat_room_join_Writer = new Chat_Room_Join(); + chat_room_join_Writer.setChat_room(savedMessageRoom); + chat_room_join_Writer.setUser(writerUser); + chatRoomJoinRepository.save(chat_room_join); + chatRoomJoinRepository.save(chat_room_join_Writer); + + List user_chat_room_join = user.getChat_room_joins(); + user_chat_room_join.add(chat_room_join); + List writer_chat_room_joins = writerUser.getChat_room_joins(); + writer_chat_room_joins.add(chat_room_join_Writer); + + DirectMessageCreateRoomResponseDto responseDto = + new DirectMessageCreateRoomResponseDto(true, + savedMessageRoom.getChat_room_id(), + not_mine_id, + not_mine_nickname, + not_mine_profile_url, + not_mine_reliability, + user_status, + not_mine_user_status, + transaction_id, + is_complete, + recent_message, + recent_message_date); + + return responseDto; + + } + else { + DirectMessageCreateRoomResponseDto responseDto = + new DirectMessageCreateRoomResponseDto(false, null, null, null, null, null, null, null, null, null, null, null); + + return responseDto; + } + } + + public List findMessageRooms(User loginUser, Long user_id) { + List roomsList = new ArrayList<>(); + Optional user = userRepository.findById(user_id); + User findedUser = user.get(); + List chat_room_joins = findedUser.getChat_room_joins(); + for (Chat_Room_Join chat_room_join : chat_room_joins) { + Chat_Room chat_room = chat_room_join.getChat_room(); + Long chat_room_id = chat_room.getChat_room_id(); + LocalDateTime create_date = chat_room.getCreate_date(); //DM창 생성시간 + + Long not_mine_id = null; + String not_mine_nickname = null; + String not_mine_profile_url = null; + Long not_mine_reliability = null; + @NotNull UserStatus not_mine_status = null; + Long transaction_id = null; + Boolean is_complete = false; + String recent_message = null; +// LocalDateTime recent_message_date = LocalDateTime.of(2019, 11, 12, 12, 32,22,3333); + LocalDateTime recent_message_date = null; + + String searchJpql = "select c from chat_room_join c where c.chat_room = '" + chat_room_id + "'"; + List list = em.createQuery(searchJpql, Chat_Room_Join.class).getResultList(); + for (Chat_Room_Join chatRoomJoin : list) { + User user1 = chatRoomJoin.getUser(); + if(!user1.getUser_id().equals(user_id)) { + not_mine_id = user1.getUser_id(); + not_mine_nickname = user1.getNickname(); + not_mine_profile_url = user1.getProfile_url(); + not_mine_reliability = user1.getReliability(); + not_mine_status = user1.getUser_status(); + } + } + + Transaction transaction = chat_room.getTransaction(); + transaction_id = transaction.getTransaction_id(); + Status status = transaction.getStatus(); + if(status.equals(Status.마감)) { + is_complete = true; + } + List messages = chat_room.getMessages(); + if(!messages.isEmpty()) { + Comp comp = new Comp(); + Collections.sort(messages, comp); + Message message = messages.get(0); + recent_message = message.getContent_detail().getContent(); + recent_message_date = message.getContent_detail().getWritten_date(); + } + else { + //메시지가 없으면 방 생성날짜로 + recent_message_date = create_date; + } + + roomsList.add(new DirectMessageListResponseDto( + chat_room_id, + not_mine_id, + not_mine_nickname, + not_mine_profile_url, + not_mine_reliability, + not_mine_status, + transaction_id, + is_complete, + recent_message, + recent_message_date)); + } + + Comp2 comp2 = new Comp2(); + Collections.sort(roomsList, comp2); + + return roomsList; + } + + private static class Comp implements Comparator { + + @Override + public int compare(Message message1, Message message2) { + + LocalDateTime date1 = message1.getContent_detail().getWritten_date(); + LocalDateTime date2 = message2.getContent_detail().getWritten_date(); + + int result = date2.compareTo(date1); + return result; + } + } + + private static class Comp2 implements Comparator { + + @Override + public int compare(DirectMessageListResponseDto responseDto1, DirectMessageListResponseDto responseDto2) { + + LocalDateTime date1 = responseDto1.getRecent_message_date(); + LocalDateTime date2 = responseDto2.getRecent_message_date(); + + int result = date2.compareTo(date1); + return result; + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/ChatService.java b/backend/src/main/java/moviegoods/movie/service/ChatService.java new file mode 100644 index 0000000..9b9bdc6 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/ChatService.java @@ -0,0 +1,174 @@ +package moviegoods.movie.service; + +import com.google.firebase.auth.FirebaseAuthException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.directMessage.*; +import moviegoods.movie.domain.entity.ChatRoom.ChatRoomRepository; +import moviegoods.movie.domain.entity.ChatRoom.Chat_Room; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +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.Report.ReportRepository; +import moviegoods.movie.domain.entity.Transaction.Status; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.Transaction.TransactionRepository; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.*; + + +@Slf4j +@Service +@AllArgsConstructor +public class ChatService { + + private final UserRepository informationShareUserRepository; + private final ChatRoomRepository chatRoomRepository; + private final MessageRepository messageRepository; + private final TransactionRepository directMessageTransactionRepository; + private final ReportRepository directMessageReportRepository; + private final FireBaseService fireBaseService; + private final ContentDetailService contentDetailService; + + @Transactional(rollbackFor = Exception.class) + public String saveMessage(User loginUser, DirectMessage message) throws IOException, FirebaseAuthException { + String finalUrl=""; + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + User user=loginUser; + Message message1=new Message(); + Chat_Room chat_room=chatRoomRepository.findById(message.getChat_room_id()).get(); + Content_Detail content_detail=new Content_Detail(); + content_detail.setWritten_date(LocalDateTime.now()); + String firebaseUrl=""; + content_detail.setContent(message.getContent()); + if(message.getImage_url()!=null){ + + content_detail.setContent(message.getContent()); + firebaseUrl+=changeStringToFileAndUpload(message.getImage_url()); + message1.setImage_url(firebaseUrl); + finalUrl+=firebaseUrl; + } + message1.setContent_detail(content_detail); + message1.setUser(user); + message1.setChat_room(chat_room); + messageRepository.save(message1); + + return finalUrl; + + } + + public String changeStringToFileAndUpload(String base64url) throws IOException, FirebaseAuthException { + String firebaseUrl=""; + String url=""; + String contentType=""; + if(base64url.contains("image/png")){ + contentType+="image/png"; + }else if(base64url.contains("image/jpeg")){ + contentType+="image/jpeg"; + } + int startIdx= base64url.indexOf("base64,"); + int start=startIdx+7; + for(int i=start; i show(User loginUser, Long room_id) { + List messagesList = new ArrayList<>(); + Optional chatRoom = chatRoomRepository.findById(room_id); + Chat_Room findedRoom = chatRoom.get(); + List messages = findedRoom.getMessages(); + for (Message message : messages) { + Content_Detail content_detail = message.getContent_detail(); + String content = content_detail.getContent(); + LocalDateTime written_date = content_detail.getWritten_date(); + String image_url = message.getImage_url(); + + User user = message.getUser(); + Long user_id = user.getUser_id(); + String nickname = user.getNickname(); + String profile_url = user.getProfile_url(); + Long reliability = user.getReliability(); + + messagesList.add(new DirectMessageDetailResponseDto(content, written_date, image_url, user_id, nickname, profile_url, reliability)); + } + return messagesList; + } + + public Boolean updateTransactionComplete(User loginUser, DirectMessageRequestComplete dmrc){ + Boolean check; + Long transaction_id=dmrc.getTransaction_id(); + Transaction transaction=directMessageTransactionRepository.findById(transaction_id).get(); + transaction.setStatus(Status.마감); + Transaction t=directMessageTransactionRepository.save(transaction); + if(t.getStatus().equals(Status.마감)){ + check=true; + }else{ + check=false; + } + return check; + + } + + public Boolean updateReliability(User loginUser, DirectMessageRequestReliability dmrr){ //메세지생성창에서 user_id 받아와야함 + Boolean check=false; + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + User user= loginUser; + User user2=informationShareUserRepository.findById(dmrr.getUser_id()).get(); + Long n= user2.getReliability()+1; + user2.setReliability(n); + User u=informationShareUserRepository.save(user2); + if(u.getReliability()==n){ + check=true; + } + return check; + + } + + public Report report(User loginUser, DirectMessageRequestReport dmrr){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + Long transaction_id=dmrr.getTransaction_id(); + String report_content=dmrr.getReport_content(); + Report report=new Report(); + User user=loginUser; + Transaction transaction=directMessageTransactionRepository.findById(transaction_id).get(); + Content_Detail content_detail=new Content_Detail(); + content_detail.setContent(report_content); + content_detail.setWritten_date(LocalDateTime.now()); + user.getReports().add(report); + report.setUser(user); + content_detail.setReport(report); + report.setContent_detail(content_detail); + transaction.getReports().add(report); + report.setTransaction(transaction); + Report report1=directMessageReportRepository.save(report); + + return report1; + + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/CinemaService.java b/backend/src/main/java/moviegoods/movie/service/CinemaService.java new file mode 100644 index 0000000..986a433 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/CinemaService.java @@ -0,0 +1,23 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.entity.Cinema.Cinema; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; + +@RequiredArgsConstructor +@Service +public class CinemaService { + public Cinema saveCinemaDetail(String cinema_name, String cinema_area, String cinema_branch) { + Cinema cinema = new Cinema(); + + cinema.setName(cinema_name); + cinema.setArea(cinema_area); + cinema.setBranch(cinema_branch); + + return cinema; + } +} diff --git a/backend/src/main/java/moviegoods/movie/service/ContentDetailService.java b/backend/src/main/java/moviegoods/movie/service/ContentDetailService.java new file mode 100644 index 0000000..bd4e60a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/ContentDetailService.java @@ -0,0 +1,21 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; + +@RequiredArgsConstructor +@Service +public class ContentDetailService { + public Content_Detail saveContentDetail(String content) { + Content_Detail content_detail = new Content_Detail(); + + content_detail.setContent(content); + content_detail.setWritten_date(LocalDateTime.now()); + + return content_detail; + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/EventsService.java b/backend/src/main/java/moviegoods/movie/service/EventsService.java new file mode 100644 index 0000000..5e3260c --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/EventsService.java @@ -0,0 +1,180 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.events.*; +import moviegoods.movie.domain.entity.Event.Event; +import moviegoods.movie.domain.entity.Event.EventRepository; +import moviegoods.movie.domain.entity.Like_Basket.LikeBasketRepository; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; +import moviegoods.movie.domain.entity.User.User; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityManager; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +@RequiredArgsConstructor +@Service +@Slf4j +public class EventsService { + + private final EventRepository eventRepository; + private final LikeBasketsService likeBasketsService; + private final LikeBasketRepository likeBasketRepository; + private final EntityManager em; + + @Transactional(rollbackFor = Exception.class) + public List search(User loginUser, EventsSearchRequestDto requestDto) { + List searchList = new ArrayList<>(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + String cinema_name = requestDto.getCinema_name(); + String search_word = requestDto.getSearch_word(); + String sort_criteria = requestDto.getSort_criteria(); // 최신순, 관심도순 + Boolean is_end = requestDto.getIs_end(); // 1(마감), 0(진행) + + String linking_word = "where "; + + String searchJpql = "select e from event e join e.cinema c where "; + Integer check = 0; + if (search_word == null) { + search_word = ""; + } + + String searchWordJpql = ""; + if (search_word != null) { + check++; + searchWordJpql = "e.title like '%" + search_word + "%' "; + + searchJpql += searchWordJpql; + } + + // 영화사 이름 + if (cinema_name != null) { + if(check >= 1) { + linking_word = "and "; + } + check++; + searchJpql += linking_word+"c.name = '"+cinema_name+"' "; + } + + // 진행여부 true(마감), false(진행중) + LocalDate now = LocalDate.now(); + String isEndJpql = ""; + if (is_end != null) { + if (Objects.equals(is_end, true)) { + isEndJpql = "e.end_date <= STR_TO_DATE(NOW(), '%Y-%m-%d') "; + } else { + isEndJpql = "e.end_date > STR_TO_DATE(NOW(), '%Y-%m-%d') "; + } + check++; + if (check >= 1) { + linking_word = "and "; + } + searchJpql += linking_word + isEndJpql; + } + + // 정렬 기준(최신순) 기본 값 줘야 + if (Objects.equals(sort_criteria,"최신순")) { + searchJpql += "order by e.start_date desc"; + } + if (Objects.equals(sort_criteria,"관심도순")) { + searchJpql += "order by e.like_count desc"; + } + + log.info("searchJpql={}",searchJpql); + List eventList = em.createQuery(searchJpql, Event.class).getResultList(); + for (Event event : eventList) { + Long event_id = event.getEvent_id(); + String search_cinema_name = event.getCinema().getName(); + String title = event.getTitle(); + String thumbnail_url = event.getThumbnail_url(); + Date start_date = event.getStart_date(); + Date end_date = event.getEnd_date(); + Boolean search_is_end = Boolean.FALSE; + Date date_now = java.sql.Date.valueOf(now); + if (end_date.before(date_now)) { + search_is_end = Boolean.TRUE; + } + + Boolean is_like=likeBasketsService.isLikeEvent(user_id, event_id); + + searchList.add(new EventsSearchResponseDto(search_cinema_name, event_id, thumbnail_url, title, start_date, end_date, is_like, search_is_end)); + } + return searchList; + } + + @Transactional(rollbackFor = Exception.class) + public EventsDetailResponseDto detail(User loginUser, EventsDetailRequestDto requestDto) { + + Long event_id = requestDto.getEvent_id(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + Event event = eventRepository.findById(event_id).orElseThrow(() -> new IllegalArgumentException("해당 이벤트가 없습니다. event_id = "+ event_id)); + String cinema_name = event.getCinema().getName(); + String title = event.getTitle(); + String detail_image_url = event.getDetail_image_url(); + + String[] array = detail_image_url.split(", "); + List image_url = new ArrayList<>(); + for (String objects : array) { + String detail_url=objects; + image_url.add(detail_url); + } + + String link_url = event.getLink_url(); + Date start_date = event.getStart_date(); + Date end_date = event.getEnd_date(); + Long like_count = event.getLike_count(); + Boolean is_like = likeBasketsService.isLikeEvent(user_id, event_id); + + EventsDetailResponseDto eventsDetailResponseDto =new EventsDetailResponseDto(event_id, cinema_name, title, + image_url, link_url, start_date, end_date, like_count, is_like); + + return eventsDetailResponseDto; + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto like(User loginUser, EventsLikeRequestDto requestDto) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long event_id = requestDto.getEvent_id(); + + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + Long user_id = loginUser.getUser_id(); + + Boolean is_like = likeBasketsService.isLikeEvent(user_id, event_id); + Event event = eventRepository.findById(event_id).orElseThrow(() -> new IllegalArgumentException("해당 이벤트가 없습니다. event_id = "+ event_id)); + + Boolean result = false; + if (Objects.equals(is_like,false)) { + Like_Basket saveEntity=Like_Basket.builder().user(loginUser).event(event).build(); + likeBasketRepository.save(saveEntity); + result = true; + } + if (Objects.equals(is_like, true)) { + Long like_basket_id = likeBasketsService.selectLikeEvent(user_id,event_id); + result = likeBasketsService.deleteLike(like_basket_id,user_id); + } + resultResponseDto.setResult(result); + + return resultResponseDto; + + } + + +} diff --git a/backend/src/main/java/moviegoods/movie/service/FireBaseService.java b/backend/src/main/java/moviegoods/movie/service/FireBaseService.java new file mode 100644 index 0000000..716a1dd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/FireBaseService.java @@ -0,0 +1,39 @@ +package moviegoods.movie.service; + +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.Bucket; +import com.google.firebase.auth.FirebaseAuthException; +import com.google.firebase.cloud.StorageClient; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + + +@Service +@RequiredArgsConstructor +public class FireBaseService { + + public String uploadFiles(MultipartFile file, String nameFile)throws IOException, FirebaseAuthException { + + Bucket bucket= StorageClient.getInstance().bucket("stroagetest-f0778.appspot.com"); + + InputStream content=new ByteArrayInputStream(file.getBytes()); + Blob blob=bucket.create(nameFile.toString(),content,file.getContentType()); + return blob.getMediaLink(); + + } + + public String uploadFiles2(byte[] decodeByte, String contentType, String nameFile) throws IOException, FirebaseAuthException { + + Bucket bucket= StorageClient.getInstance().bucket("stroagetest-f0778.appspot.com"); + InputStream content=new ByteArrayInputStream(decodeByte); + Blob blob=bucket.create(nameFile.toString(),content,contentType); + + return blob.getMediaLink(); + + } +} diff --git a/backend/src/main/java/moviegoods/movie/service/GeneralBoardService.java b/backend/src/main/java/moviegoods/movie/service/GeneralBoardService.java new file mode 100644 index 0000000..e88c9cd --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/GeneralBoardService.java @@ -0,0 +1,238 @@ +package moviegoods.movie.service; + +import com.google.firebase.auth.FirebaseAuthException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.comments.Comments; +import moviegoods.movie.domain.dto.generalBoard.*; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Comment.CommentRepository; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.Post.PostRepository; +import moviegoods.movie.domain.entity.User.UserStatus; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.EntityManager; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.*; + + +@Slf4j +@Service +@RequiredArgsConstructor +public class GeneralBoardService { + private final UserRepository userRepository; + private final ContentDetailService contentDetailService; + private final PostRepository postRepository; + private final CommentRepository commentRepository; + private final FireBaseService fireBaseService; + private final EntityManager em; + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto savePost(User loginUser, GeneralBoardWriteRequestDto requestDto) throws IOException, FirebaseAuthException { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + String title = requestDto.getTitle(); + + String content = requestDto.getContent(); + MultipartFile image_url = requestDto.getImage_url(); + String firebaseUrl = ""; + + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + Long user_id = loginUser.getUser_id(); + + if(image_url!=null){ + String nameFile= UUID.randomUUID().toString(); + + fireBaseService.uploadFiles(image_url,nameFile); + firebaseUrl+="https://firebasestorage.googleapis.com/v0/b/stroagetest-f0778.appspot.com/o/"+nameFile+"?alt=media"; + } + + User user = userRepository.getById(user_id); + Content_Detail content_detail = contentDetailService.saveContentDetail(content); + Post saveEntity = Post.builder().category("자유").views(0L).user(user).content_detail(content_detail).title(title).image_url(firebaseUrl).build(); + + postRepository.save(saveEntity); + resultResponseDto.setResult(true); + + return resultResponseDto; + + } + + @Transactional(rollbackFor = Exception.class) + public List search(GeneralBoardSearchRequestDto requestDto) { + + List searchList=new ArrayList<>(); + + String search_word = requestDto.getSearch_word(); + String search_criteria = requestDto.getSearch_criteria(); // 제목 / 제목+내용 / 내용 / 작성자 + + if (search_word == null) { + search_word = ""; + } + + String searchJpql = "select p from post p join p.user u join p.content_detail c where p.category = '자유' "; + + String criteriaJpql = ""; + String criteriaJpql2 = ""; + log.info("search_criteria={}", search_criteria); + if (search_criteria != "") { + if (Objects.equals(search_criteria, "작성자")) { + criteriaJpql = "u.nickname"; + } + if (Objects.equals(search_criteria, "내용")) { + criteriaJpql = "c.content"; + } + if (Objects.equals(search_criteria, "제목")) { + criteriaJpql = "p.title"; + } + if (Objects.equals(search_criteria, "제목+내용")) { + criteriaJpql = "c.content"; + criteriaJpql2 = "p.title"; + } + if (criteriaJpql2 != "") { + searchJpql += "and ("+criteriaJpql + " like '%" + search_word + "%' "+"OR "+criteriaJpql2 + " like '%" + search_word + "%') "; + } + else { + searchJpql += "and "+criteriaJpql + " like '%" + search_word + "%' "; + } + + } + + + searchJpql += "order by c.written_date desc"; + log.info("searchJpql={}", searchJpql); + + List postList = em.createQuery(searchJpql, Post.class).getResultList(); + for (Post post : postList) { + Long post_id = post.getPost_id(); + String title = post.getTitle(); + LocalDateTime written_date = post.getContent_detail().getWritten_date(); + String nickname = post.getUser().getNickname(); + Long view = post.getViews(); + + searchList.add(new GeneralBoardSearchResponseDto(post_id,title,nickname,written_date,view)); + } + return searchList; + + } + + @Transactional(rollbackFor = Exception.class) + public GeneralBoardDetailResponseDto detailInfo(User loginUser, GeneralBoardDetailRequestDto requestDto){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + Long post_id = requestDto.getPost_id(); + Post post=postRepository.findById(post_id).get(); + String title = post.getTitle(); + LocalDateTime written_date = post.getContent_detail().getWritten_date(); + String content = post.getContent_detail().getContent(); + Long views = post.getViews(); + String nickname = post.getUser().getNickname(); + Long post_user_id = post.getUser().getUser_id(); + String image_url = post.getImage_url(); + Boolean is_mine = Boolean.FALSE; + + if (post_user_id == user_id) { + is_mine = Boolean.TRUE; + } + + List searchCommentList = new ArrayList<>(); + + String searchJpql = "select c from comment c join c.post p left join c.user u left join c.content_detail d where p.post_id=:post_id"; + List commentList = em.createQuery(searchJpql, Comment.class).setParameter("post_id",post_id).getResultList(); + for (Comment comment : commentList) { + Long search_user_id = comment.getUser().getUser_id(); + Long comment_id = comment.getComment_id(); + String comment_nickname = comment.getUser().getNickname(); + String comment_content = comment.getContent_detail().getContent(); + LocalDateTime comment_written_date = comment.getContent_detail().getWritten_date(); + UserStatus user_status = comment.getUser().getUser_status(); + + Boolean comment_is_mine = Boolean.FALSE; + if (search_user_id == user_id) { + comment_is_mine = Boolean.TRUE; + } + + searchCommentList.add(new Comments(comment_id,search_user_id,comment_nickname,comment_content,comment_is_mine,comment_written_date,user_status)); + } + + GeneralBoardDetailResponseDto responseDto = new GeneralBoardDetailResponseDto(post_id,title,written_date,content,views+1,nickname,image_url,is_mine,searchCommentList); + post.setViews(post.getViews()+1); + postRepository.save(post); + + return responseDto; + + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto saveComment(User loginUser, GeneralBoardCommentRequestDto requestDto){ + ResultResponseDto resultResponseDto = new ResultResponseDto(); + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + + String content = requestDto.getContent(); + Long post_id = requestDto.getPost_id(); + Post post = postRepository.getById(post_id); + Content_Detail content_detail = contentDetailService.saveContentDetail(content); + Comment saveEntity = Comment.builder().post(post).user(loginUser).content_detail(content_detail).build(); + + commentRepository.save(saveEntity); + if(post.getViews()>0){ + post.setViews(post.getViews()-1); + postRepository.save(post); + } + + resultResponseDto.setResult(true); + + return resultResponseDto; + + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto deleteDetail(User loginUser, GeneralBoardDetailDeleteRequestDto requestDto){ + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + Long post_id=requestDto.getPost_id(); + postRepository.deleteById(post_id); + + + resultResponseDto.setResult(!postRepository.existsById(post_id)); + + return resultResponseDto; + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto deleteComment(User loginUser, GeneralBoardCommentDeleteRequestDto requestDto){ + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + Long comment_id=requestDto.getComment_id(); + commentRepository.deleteById(comment_id); + + resultResponseDto.setResult(!commentRepository.existsById(comment_id)); + + return resultResponseDto; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/service/InformationShareService.java b/backend/src/main/java/moviegoods/movie/service/InformationShareService.java new file mode 100644 index 0000000..27d513a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/InformationShareService.java @@ -0,0 +1,420 @@ +package moviegoods.movie.service; + + +import com.google.firebase.auth.FirebaseAuthException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.comments.Comments; +import moviegoods.movie.domain.dto.informationShare.*; +import moviegoods.movie.domain.entity.Cinema.Cinema; +import moviegoods.movie.domain.entity.Cinema.CinemaRepository; +import moviegoods.movie.domain.entity.Comment.Comment; +import moviegoods.movie.domain.entity.Comment.CommentRepository; +import moviegoods.movie.domain.entity.Content_Detail.ContentDetailRepository; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.Post.PostRepository; +import moviegoods.movie.domain.entity.User.UserStatus; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.EntityManager; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.*; + +@Slf4j +@Service +@RequiredArgsConstructor +public class InformationShareService { + + private final CinemaRepository cinemaRepository; + private final UserRepository userRepository; + private final ContentDetailRepository contentDetailRepository; + private final ContentDetailService contentDetailService; + private final PostRepository postRepository; + private final CommentRepository commentRepository; + private final FireBaseService fireBaseService; + private final EntityManager em; + + public List savePost(InformationShareRequestWrite isrw) throws IOException, FirebaseAuthException { + + Long user_id=isrw.getUser_id(); + String title=isrw.getTitle(); + String cinema_name=isrw.getCinema_name(); + String cinema_area=isrw.getCinema_area(); + String cinema_branch=isrw.getCinema_branch(); + String content=isrw.getContent(); + MultipartFile image_url=isrw.getImage_url(); + String firebaseUrl=""; + log.info("imageurl={}",image_url); + if(image_url!=null){ + String nameFile= UUID.randomUUID().toString(); + //log.info("imageurl={}",image_url); + + fireBaseService.uploadFiles(image_url,nameFile); + firebaseUrl+="https://firebasestorage.googleapis.com/v0/b/stroagetest-f0778.appspot.com/o/"+nameFile+"?alt=media"; + //log.info("firebaseurl={}",firebaseUrl); + } + + + Optional OptionalUser=userRepository.findById(user_id); + if(OptionalUser.isPresent()){ + User user=OptionalUser.get(); + Cinema cinema=new Cinema(); + cinema.setName(cinema_name); + cinema.setBranch(cinema_branch); + cinema.setArea(cinema_area); + Content_Detail content_detail=saveContent_detail(content); + Post post=new Post(); + post.setImage_url(firebaseUrl); + post.setTitle(title); + post.setViews(0L); + post.setCategory("정보공유"); + user.getPosts().add(post); + post.setUser(user); + content_detail.setPost(post); + post.setContent_detail(content_detail); + cinema.setPost(post); + post.setCinema(cinema); + + + postRepository.save(post); + + List postList=postRepository.findAll(); + + + return postList; + } + return new ArrayList<>(); + + + + } + + public Content_Detail saveContent_detail(String content){ + + Content_Detail content_detail=new Content_Detail(); + + content_detail.setContent(content); + content_detail.setWritten_date(LocalDateTime.now()); + + return content_detail; + } + + public void saveUser(User user){ + + userRepository.save(user); + + } + + + + public InformationShareResponseSearch makeInformationShareResponseSearch(String nickname, String title, Long views, Long post_id, LocalDateTime written_date, UserStatus status){ + InformationShareResponseSearch informationShareResponseSearch=new InformationShareResponseSearch(); + informationShareResponseSearch.setNickname(nickname); + informationShareResponseSearch.setPost_id(post_id); + informationShareResponseSearch.setTitle(title); + informationShareResponseSearch.setView(views); + informationShareResponseSearch.setWritten_date(written_date); + informationShareResponseSearch.setUser_status(status); + return informationShareResponseSearch; + } + + public List Search(InformationShareRequestSearch isrs) { + + List searchList=new ArrayList<>(); + + String area = isrs.getCinema_area(); + String branch = isrs.getCinema_branch(); + String name = isrs.getCinema_name(); + String search_word = isrs.getSearch_word(); + String sort_name = isrs.getSort_name(); // 제목 / 제목+내용 / 내용 / 작성자 + String searchJpql1 = "select p From post p join p.content_detail c "; + String searchWord = "where p.category='정보공유' "; + String orderLatest ="order by c.written_date DESC"; + String categoryInformationShare=" and p.category='정보공유' "; + if ((area == null) && (branch == null) && (name == null)) { // 영화관 필터가 없을때 + if (search_word.equals("")) { //검색어가 없으면 + + } + if (!search_word.equals("")) { //검색어가 있으면 + if (sort_name.equals("제목")) { + searchWord += "and p.title like '%" + search_word + "%'"; + } else if (sort_name.equals("제목+내용")) { + searchWord += "and (c.content like '%" + search_word + "%') " + "OR (p.title like '%" + search_word + "%')"; + + } else if (sort_name.equals("내용")) { + searchWord += "and c.content like '%" + search_word + "%'"; + } else if (sort_name.equals("작성자")) { + + String searchJpql2="select p From post p join p.user u where u.nickname like '%"+search_word+"%'"+categoryInformationShare; + + List postList=em.createQuery(searchJpql2,Post.class).getResultList(); + for (Post post : postList) { + Long content_detail_id=post.getContent_detail().getContent_detail_id(); + Content_Detail content_detail=contentDetailRepository.findById(content_detail_id).get(); + + String nickname=post.getUser().getNickname(); + UserStatus status=userRepository.findByNickname(nickname).get().getUser_status(); + String title=post.getTitle(); + Long views=post.getViews(); + Long post_id=post.getPost_id(); + LocalDateTime written_date=content_detail.getWritten_date(); + searchList.add(makeInformationShareResponseSearch(nickname,title,views,post_id,written_date,status)); + + + + } + Collections.reverse(searchList); + return searchList; + } + } + searchJpql1+=searchWord; + + searchJpql1+=orderLatest; + + List postList=em.createQuery(searchJpql1,Post.class).getResultList(); + for (Post post : postList) { + Long user_id=post.getUser().getUser_id(); + User user=userRepository.findById(user_id).get(); + String nickname=user.getNickname(); + UserStatus status=userRepository.findByNickname(nickname).get().getUser_status(); + String title=post.getTitle(); + Long views=post.getViews(); + Long post_id=post.getPost_id(); + LocalDateTime written_date=post.getContent_detail().getWritten_date(); + searchList.add(makeInformationShareResponseSearch(nickname,title,views,post_id,written_date,status)); + + } + return searchList; + } + else{ //영화관 필터가 있을때 + + + Boolean check=false; + if(search_word.equals("")){ //검색어가 없으면 + check=false; + String filterJpql="select p from post p join p.cinema c where "; + if(area!=null){ + filterJpql+="c.area= '"+area+"'"; + check=true; + } + if(branch!=null){ + if(check==true){ + filterJpql+="AND c.branch= '"+branch+"'"; + } + else{ + filterJpql+="c.branch= '"+branch+"'"; + + } + check=true; + } + if(name!=null){ + if(check==true){ + filterJpql+="AND c.name= '"+name+"'"; + } + else{ + filterJpql+="c.name= '"+name+"'"; + } + } + + filterJpql+=categoryInformationShare; + + + List postList=em.createQuery(filterJpql,Post.class).getResultList(); + for (Post post : postList) { + String nickname=userRepository.findById(post.getUser().getUser_id()).get().getNickname(); + UserStatus status=userRepository.findByNickname(nickname).get().getUser_status(); + String title=post.getTitle(); + Long views=post.getViews(); + Long post_id=post.getPost_id(); + LocalDateTime written_date=contentDetailRepository.findById(post.getContent_detail().getContent_detail_id()).get().getWritten_date(); + searchList.add(makeInformationShareResponseSearch(nickname,title,views,post_id,written_date,status)); + + } + Collections.reverse(searchList); + return searchList; + + } + //영화관 필터 & 검색어가 있으면 + check=false; + String filterJpql1="select p from post p join p.cinema c left join p.content_detail d left join p.user u where "; + if(area!=null){ + filterJpql1+="c.area= '"+area+"'"; + check=true; + } + if(branch!=null){ + if(check==true){ + filterJpql1+="AND c.branch= '"+branch+"'"; + } + else{ + filterJpql1+="c.branch= '"+branch+"'"; + + } + check=true; + } + if(name!=null){ + if(check==true){ + filterJpql1+="AND c.name= '"+name+"'"; + } + else{ + filterJpql1+="c.name= '"+name+"'"; + } + } + filterJpql1+=categoryInformationShare; + filterJpql1+="AND "; + if (sort_name.equals("제목")) { + + filterJpql1+= " p.title like '%" + search_word + "%'"; + } else if (sort_name.equals("제목+내용")) { + filterJpql1 += " ( (d.content like '%" + search_word + "%') " + "OR (p.title like '%" + search_word + "%') )"; + + } else if (sort_name.equals("내용")) { + filterJpql1 += " d.content like '%" + search_word + "%'"; + }else if (sort_name.equals("작성자")) { + + filterJpql1+="u.nickname like '%"+search_word+"%'"; + + } + List postList=em.createQuery(filterJpql1,Post.class).getResultList(); + for (Post post : postList) { + Long content_detail_id=post.getContent_detail().getContent_detail_id(); + Content_Detail content_detail=contentDetailRepository.findById(content_detail_id).get(); + + String nickname=post.getUser().getNickname(); + UserStatus status=userRepository.findByNickname(nickname).get().getUser_status(); + String title=post.getTitle(); + Long views=post.getViews(); + Long post_id=post.getPost_id(); + LocalDateTime written_date=content_detail.getWritten_date(); + searchList.add(makeInformationShareResponseSearch(nickname,title,views,post_id,written_date,status)); + + + + } + Collections.reverse(searchList); + return searchList; + + } + } + + + //상세조회 + public InformationShareResponseDetail detailInfo(User loginUser, InformationShareRequestDetail isrd){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + Long post_id=isrd.getPost_id(); + User user=loginUser; + Post post=postRepository.findById(post_id).get(); + List row=em.createQuery("select u.user_id, u.nickname, p.views,p.title,p.image_url,d.written_date," + + " d.content,c.name,c.area,c.branch from post p join p.content_detail d left join p.cinema c left join p.user u where p.post_id=:post_id ").setParameter("post_id",post_id).getResultList(); + Object[] result=row.get(0); + InformationShareDetailDTO ifsd= new InformationShareDetailDTO((Long)result[0],(String)result[1],(Long)result[2],(String)result[3],(String)result[4],(LocalDateTime)result[5],(String)result[6],(String)result[7],(String)result[8],(String)result[9]); + + InformationShareResponseDetail informationShareResponseDetail=new InformationShareResponseDetail(); + String nickname=(String)result[1]; + informationShareResponseDetail.setUser_status(userRepository.findByNickname(nickname).get().getUser_status()); + List row2=em.createQuery("select u.user_id, u.nickname, d.content, d.written_date ,c.comment_id from comment c join c.post p left join c.user u left join c.content_detail d where p.post_id=:post_id").setParameter("post_id",post_id).getResultList(); + List result2=new ArrayList<>(); + + for (Object[] objects : row2) { + Boolean check=false; + String nickname2=(String)objects[1]; + UserStatus status2=userRepository.findByNickname(nickname2).get().getUser_status(); + Comments comment=new Comments((Long)objects[0],(String)objects[1],(String)objects[2],(LocalDateTime)objects[3],(Long)objects[4],status2); + if(user_id==(Long)objects[0]){ + check=true; + } + comment.setIs_mine(check); + result2.add(comment); + } + Collections.reverse(result2); + + if(ifsd.getUser_id()==user_id){ + informationShareResponseDetail.setIs_mine(true); + }else{ + informationShareResponseDetail.setIs_mine(false); + } + informationShareResponseDetail.setCinema_area(ifsd.getArea()); + informationShareResponseDetail.setCinema_branch(ifsd.getBranch()); + informationShareResponseDetail.setCinema_name(ifsd.getName()); + informationShareResponseDetail.setContent(ifsd.getContent()); + informationShareResponseDetail.setImage_url(ifsd.getImage_url()); + informationShareResponseDetail.setNickname(ifsd.getNickname()); + informationShareResponseDetail.setPost_id(post_id); + informationShareResponseDetail.setViews(ifsd.getViews()+1); + informationShareResponseDetail.setWritten_date(ifsd.getWritten_date()); + informationShareResponseDetail.setTitle(ifsd.getTitle()); + + informationShareResponseDetail.setComment(result2); + + + post.setViews(post.getViews()+1); + postRepository.save(post); + + return informationShareResponseDetail; + + } + + public ResultResponseDto saveComment(User loginUser, InformationShareRequestSaveComment isrsc){ + ResultResponseDto resultResponseDto = new ResultResponseDto(); + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + + Long user_id = loginUser.getUser_id(); + + String content = isrsc.getContent(); + Long post_id = isrsc.getPost_id(); + Post post = postRepository.getById(post_id); + Content_Detail content_detail = contentDetailService.saveContentDetail(content); + Comment saveEntity = Comment.builder().post(post).user(loginUser).content_detail(content_detail).build(); + + + commentRepository.save(saveEntity); + if(post.getViews()>0){ + post.setViews(post.getViews()-1); + postRepository.save(post); + } + + resultResponseDto.setResult(true); + + return resultResponseDto; + + } + + public Boolean deleteDetail(User loginUser, InformationShareRequestDeleteDetail isrdd){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + Long post_id=isrdd.getPost_id(); + + + postRepository.deleteById(post_id); + + Boolean result=postRepository.existsById(post_id); + return result; + } + + public Boolean deleteComment(User loginUser, InformationShareRequestDeleteComment isrdc){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + Long comment_id=isrdc.getComment_id(); + + + commentRepository.deleteById(comment_id); + Boolean result=commentRepository.existsById(comment_id); + return result; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/LikeBasketsService.java b/backend/src/main/java/moviegoods/movie/service/LikeBasketsService.java new file mode 100644 index 0000000..1e88767 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/LikeBasketsService.java @@ -0,0 +1,79 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import moviegoods.movie.domain.entity.Like_Basket.LikeBasketRepository; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityManager; + +@RequiredArgsConstructor +@Service +public class LikeBasketsService { + private final EntityManager em; + private final LikeBasketRepository likeBasketRepository; + + public Boolean isLikeEvent(Long user_id, Long event_id) { + Boolean is_like = Boolean.FALSE; + + String likeJpql = "select count(l) from like_basket l where event_id = :event_id and user_id = :user_id"; + Object object = em.createQuery(likeJpql).setParameter("event_id", event_id) + .setParameter("user_id", user_id).setMaxResults(1).getSingleResult(); + + if (Integer.parseInt(object.toString()) == 1) { + is_like = Boolean.TRUE; + } + return is_like; + } + + public Long selectLikeEvent(Long user_id, Long event_id) { + String likeJpql = "select l from like_basket l where event_id = :event_id and user_id = :user_id"; + + Like_Basket like_basket = em.createQuery(likeJpql, Like_Basket.class).setParameter("event_id", event_id) + .setParameter("user_id", user_id).getSingleResult(); + Long like_basket_id = like_basket.getLike_basket_id(); + + return like_basket_id; + } + + public Boolean deleteLike(Long like_basket_id, Long user_id) { + Like_Basket like_basket = likeBasketRepository.findById(like_basket_id).orElseThrow(() -> + new IllegalArgumentException("해당 좋아요 내역이 없습니다. like_basket_id = {}"+ like_basket_id)); + + if (like_basket.getUser().getUser_id() == user_id) { + likeBasketRepository.deleteById(like_basket_id); + } + + Boolean is_exists=likeBasketRepository.existsById(like_basket_id); + Boolean result = false; + if (is_exists == false) { + result = true; + } + return result; + + } + + public Boolean isLikeTransaction(Long user_id, Long transaction_id) { + String likeJpql = "select count(l) from like_basket l where transaction_id = :transaction_id and user_id = :user_id"; + + Object object = em.createQuery(likeJpql).setParameter("transaction_id", transaction_id) + .setParameter("user_id",user_id).setMaxResults(1).getSingleResult(); + Boolean is_like = Boolean.FALSE; + if (Integer.parseInt(object.toString()) == 1) { + is_like = Boolean.TRUE; + } + return is_like; + + } + + public Long selectLikeTransaction(Long user_id, Long transaction_id) { + String likeJpql = "select l from like_basket l where transaction_id = :transaction_id and user_id = :user_id"; + + Like_Basket like_basket = em.createQuery(likeJpql, Like_Basket.class).setParameter("transaction_id", transaction_id) + .setParameter("user_id", user_id).getSingleResult(); + Long like_basket_id = like_basket.getLike_basket_id(); + + return like_basket_id; + } + +} diff --git a/backend/src/main/java/moviegoods/movie/service/LogOutService.java b/backend/src/main/java/moviegoods/movie/service/LogOutService.java new file mode 100644 index 0000000..554d736 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/LogOutService.java @@ -0,0 +1,34 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.configure.SessionConfig; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.entity.User.User; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpSession; + +@Slf4j +@Service +@RequiredArgsConstructor +public class LogOutService { + + public ResultResponseDto logout(User loginUser, HttpSession session) { + + ResultResponseDto resultResponseDto = new ResultResponseDto(); + + if (session != null) { + session.setAttribute(SessionConfig.SessionConst.LOGIN_MEMBER, null); + log.info("sessionId= {}", session.getId()); + session.invalidate(); + resultResponseDto.setResult(true); + } + else { + resultResponseDto.setResult(false); + } + + return resultResponseDto; + } +} + diff --git a/backend/src/main/java/moviegoods/movie/service/MainService.java b/backend/src/main/java/moviegoods/movie/service/MainService.java new file mode 100644 index 0000000..efec7a8 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/MainService.java @@ -0,0 +1,84 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.main.MainDailyCommunityRequestDto; +import moviegoods.movie.domain.dto.main.MainDailyCommunityResponseDto; +import moviegoods.movie.domain.dto.main.MainEventLimitResponseDto; +import moviegoods.movie.domain.entity.Event.Event; +import moviegoods.movie.domain.entity.Post.Post; +import moviegoods.movie.domain.entity.User.User; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityManager; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RequiredArgsConstructor +@Service +@Slf4j +public class MainService { + private final EntityManager em; + private final LikeBasketsService likeBasketsService; + + @Transactional(rollbackFor = Exception.class) + public List eventLimit(User loginUser) { + List cinemaNameList = new ArrayList(); + cinemaNameList.add("CGV"); + cinemaNameList.add("메가박스"); + cinemaNameList.add("롯데시네마"); + cinemaNameList.add("씨네큐"); + List searchList = new ArrayList<>(); + + for (String cinema_name : cinemaNameList) { + String searchJpql = "select e from event e join e.cinema c where c.name = '" + cinema_name + "' and e.end_date > STR_TO_DATE(NOW(), '%Y-%m-%d') "; + List eventList = em.createQuery(searchJpql, Event.class).setMaxResults(6).getResultList(); + for (Event event : eventList) { + Long event_id = event.getEvent_id(); + String search_cinema_name = event.getCinema().getName(); + String title = event.getTitle(); + String thumbnail_url = event.getThumbnail_url(); + Date start_date = event.getStart_date(); + Date end_date = event.getEnd_date(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + Boolean is_like = likeBasketsService.isLikeEvent(user_id, event_id); + + searchList.add(new MainEventLimitResponseDto(search_cinema_name, event_id, thumbnail_url, title, start_date, end_date, is_like)); + } + + } + return searchList; + } + + @Transactional(rollbackFor = Exception.class) + public List dailyCommunity(MainDailyCommunityRequestDto requestDto) { + List searchList = new ArrayList<>(); + + String community_category = requestDto.getCommunity_category(); + LocalDateTime startDatetime = LocalDateTime.of(LocalDate.now(), LocalTime.of(0,0,0)); //오늘 00:00:00 + LocalDateTime endDatetime = LocalDateTime.of(LocalDate.now(), LocalTime.of(23,59,59)); //오늘 23:59:59 + + String searchJpql = "select p from post p join p.content_detail c where p.category = '"+community_category+"' and c.written_date between '"+startDatetime+"' and '"+endDatetime+ "' order by p.views DESC"; + + List postList = em.createQuery(searchJpql, Post.class).setMaxResults(5).getResultList(); + for (Post post : postList) { + Long post_id = post.getPost_id(); + String title = post.getTitle(); + String content = post.getContent_detail().getContent(); + Long views = post.getViews(); + Long comments_num = Long.valueOf(post.getComments().size()); + LocalDateTime written_date = post.getContent_detail().getWritten_date(); + + searchList.add(new MainDailyCommunityResponseDto(post_id, title,content,views,comments_num,written_date)); + } + return searchList; + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/ManagerService.java b/backend/src/main/java/moviegoods/movie/service/ManagerService.java new file mode 100644 index 0000000..73531c8 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/ManagerService.java @@ -0,0 +1,96 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.manager.ManagerResponseDto; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Report.Report; +import moviegoods.movie.domain.entity.Report.ReportRepository; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import moviegoods.movie.domain.entity.User.UserStatus; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.*; + +import static moviegoods.movie.domain.entity.User.UserStatus.정상; +import static moviegoods.movie.domain.entity.User.UserStatus.정지; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ManagerService { + + private final ReportRepository reportRepository; + private final UserRepository userRepository; + + public List show() { + List reportsList = new ArrayList<>(); + List reports = reportRepository.findAll(); + for (Report report : reports) { + Content_Detail content_detail = report.getContent_detail(); + String content = content_detail.getContent(); //신고내용 + LocalDateTime written_date = content_detail.getWritten_date(); //신고시간 + User user = report.getUser(); //신고한 사용자 + Long user_id = user.getUser_id(); //신고자 아이디 + String nickname = user.getNickname(); //신고자 닉네임 + + Transaction transaction = report.getTransaction(); + User reportedUser = transaction.getUser(); //신고당한 사용자 + String reported_nickname = reportedUser.getNickname(); //신고당한 사용자 닉네임 + Long reported_user_id = reportedUser.getUser_id(); //신고당한 사용자 아이디 + String reported_content = transaction.getContent_detail().getContent(); //신고당한 내용 + + Boolean is_complete = false; + if(reportedUser.getUser_status() == 정지) { + is_complete = true; + } + + reportsList.add(new ManagerResponseDto(content, written_date, nickname, user_id, reported_user_id, reported_nickname, reported_content, is_complete)); + } + + Comp comp = new Comp(); + Collections.sort(reportsList, comp); + + return reportsList; + } + + public ResultResponseDto approve(Long user_id) { + Optional user = userRepository.findById(user_id); + ResultResponseDto result = new ResultResponseDto(); + UserStatus statusActive = 정상; + UserStatus statusDeActive = 정지; + if(user.isPresent()) { + User findedUser = user.get(); + if(findedUser.getUser_status() == 정상) { + findedUser.setUser_status(statusDeActive); + userRepository.save(findedUser); + } + else if (findedUser.getUser_status() == 정지) { + findedUser.setUser_status(statusActive); + userRepository.save(findedUser); + } + result.setResult(true); + } + else { + result.setResult(true); + } + return result; + } + + private static class Comp implements Comparator { + + @Override + public int compare(ManagerResponseDto responseDto1, ManagerResponseDto responseDto2) { + + LocalDateTime date1 = responseDto1.getWritten_date(); + LocalDateTime date2 = responseDto2.getWritten_date(); + + int result = date1.compareTo(date2); + return result; + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/MovieVideoService.java b/backend/src/main/java/moviegoods/movie/service/MovieVideoService.java new file mode 100644 index 0000000..fe9a23a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/MovieVideoService.java @@ -0,0 +1,71 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + + +@RequiredArgsConstructor +@Service +@Slf4j +public class MovieVideoService { + + private WebDriver driver; + private static String CHROMEDRIVER_PATH = "src/main/resources/chromedriver1.exe"; + + public String startDriver() throws IOException, WebDriverException { + System.out.println("Driver Start!!!"); + System.setProperty("webdriver.chrome.driver", CHROMEDRIVER_PATH); + + ChromeOptions options = new ChromeOptions(); + options.addArguments("headless"); + options.addArguments("--start-maximized"); // 전체화면으로 실행 + options.addArguments("--disable-popup-blocking"); // 팝업 무시 + options.addArguments("--disable-default-apps"); // 기본앱 사용안함 + //options.setCapability("ignoreProtected"); + //브라우저 로딩 타임아웃 5초 + // driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + + driver = new ChromeDriver(options); + driver.get("https://www.lottecinema.co.kr/NLCHS#"); + WebDriverWait wait = new WebDriverWait(driver, 100); + String CSS_SELECTOR="div[class=\"owl-item cloned\"] > div.item img"; + + Listvideos = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(CSS_SELECTOR))); + List videoList=new ArrayList<>(); + + + for (WebElement video : videos) { + String name= video.getAttribute("data-video"); + videoList.add(name); + + } + + driver.quit(); + if(videoList.size()>0){ + int num=videoList.size()-1; + Random random=new Random(); + int idx=random.nextInt(num); + + return videoList.get(idx); + } + return " "; + + + } + +} diff --git a/backend/src/main/java/moviegoods/movie/service/MyPageService.java b/backend/src/main/java/moviegoods/movie/service/MyPageService.java new file mode 100644 index 0000000..6ad245d --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/MyPageService.java @@ -0,0 +1,225 @@ +package moviegoods.movie.service; + + +import com.google.firebase.auth.FirebaseAuthException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.mypage.*; +import moviegoods.movie.domain.entity.Transaction.Status; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserRepository; +import moviegoods.movie.domain.entity.User.UserStatus; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.EntityManager; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import static moviegoods.movie.domain.entity.User.UserStatus.탈퇴; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MyPageService { + + private final EntityManager em; + private final UserRepository userRepository; + private final FireBaseService fireBaseService; + + public MyPageResponseSearch search(User loginUser,MyPageRequestSearch mprs){ + MyPageResponseSearch myPageResponseSearch=new MyPageResponseSearch(); + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + User user = userRepository.getById(user_id); + log.info("user_id={}", user_id); + log.info("user_profile={}", loginUser.getProfile_url()); + + MyPageUser myPageUserDto=new MyPageUser(); + myPageUserDto.setNickname(user.getNickname()); + myPageUserDto.setProfile_url(user.getProfile_url()); + myPageUserDto.setReliability(user.getReliability()); + myPageResponseSearch.setUser(myPageUserDto); + + + List row= em.createQuery("select c.comment_id , d.content, d.written_date,p.category,p.post_id from comment c join c.user u left join c.content_detail d left join c.post p where u.user_id =:user_id order by d.written_date DESC").setParameter("user_id",user_id).getResultList(); + + //작성 댓글 + for (Object[] objects : row) { + + Long comment_id=(Long)objects[0]; + String comment_content=(String)objects[1]; + LocalDateTime written_date=(LocalDateTime)objects[2]; + String category=(String)objects[3]; + Long post_id=(Long)objects[4]; + myPageResponseSearch.getComment().add(new MyPageComment(comment_id,comment_content,written_date,category,post_id)); + + + } + //작성한 글 + List row1= em.createQuery("select p.post_id, p.title, c.written_date , p.category, c.content from post p join p.content_detail c left join p.user u where u.user_id =:user_id order by c.written_date DESC").setParameter("user_id",user_id).getResultList(); + + + for (Object[] objects : row1) { + Long post_id=(Long)objects[0]; + String title=(String)objects[1]; + LocalDateTime written_date=(LocalDateTime)objects[2]; + String category=(String)objects[3]; + String content=(String)objects[4]; + + myPageResponseSearch.getContent().add(new MyPageContent(post_id,title,written_date,category,content)); + } + + + //작성한 대리구매글 + List row2= em.createQuery("select t.transaction_id , c.content , c.written_date , u.nickname ,u.reliability,u.user_id,t.status, u.profile_url,u.user_status from transaction t join t.content_detail c left join t.user u where u.user_id =:user_id order by c.written_date DESC").setParameter("user_id",user_id).getResultList(); + + + for (Object[] objects : row2) { + Boolean is_mine=false; + Long transaction_id=(Long)objects[0]; + String content=(String)objects[1]; + LocalDateTime written_date=(LocalDateTime)objects[2]; + String nickname=(String)objects[3]; + Long reliability=(Long)objects[4]; + Long user_id2=(Long)objects[5]; + if(user_id==user_id2){ + is_mine=true; + } + + Status status=(Status)objects[6]; + String profile_url=(String)objects[7]; + UserStatus user_status=(UserStatus)objects[8]; + + myPageResponseSearch.getWriteTransaction().add(new MyPageTransaction(transaction_id,content,written_date,nickname,reliability,is_mine,status,profile_url,user_status)); + } + + //좋아요한 대리구매글 + List row3= em.createQuery("select t.transaction_id ,u.nickname,u.reliability,u.user_id, u.profile_url, u.user_status from like_basket b join b.user u left join b.transaction t where u.user_id =:user_id order by t.transaction_id DESC").setParameter("user_id",user_id).getResultList(); + for (Object[] objects : row3) { + Boolean is_mine=false; + Long transaction_id=(Long)objects[0]; + String nickname=(String)objects[1]; + Long reliability=(Long)objects[2]; + Long user_id2=(Long)objects[3]; + String profile_url=(String)objects[4]; + UserStatus user_status=(UserStatus)objects[5]; + if(user_id==user_id2){ + is_mine=true; + } + List row4= em.createQuery("select c.content, c.written_date ,t.status from transaction t join t.content_detail c where t.transaction_id =:transaction_id ").setParameter("transaction_id",transaction_id).getResultList(); + if(row4.size()!=0){ + Object[] result4=row4.get(0); + String content=(String)result4[0]; + + LocalDateTime written_date=(LocalDateTime)result4[1]; + Status status=(Status)result4[2]; + myPageResponseSearch.getLikeTransaction().add(new MyPageTransaction(transaction_id,content,written_date,nickname,reliability,is_mine,status,profile_url,user_status)); + } + } + + //좋아요한 이벤트 + + List row5= em.createQuery("select e.event_id, e.title, e.thumbnail_url, e.start_date, e.end_date from like_basket b join b.event e left join b.user u where u.user_id=:user_id order by b.like_basket_id DESC").setParameter("user_id",user_id).getResultList(); + for (Object[] objects : row5) { + Long event_id=(Long)objects[0]; + String event_title=(String)objects[1]; + String thumbnail_url=(String)objects[2]; + Date start_date=(Date)objects[3]; + Date end_date=(Date)objects[4]; + myPageResponseSearch.getLikeEvent().add(new MyPageLikeEvent(event_id,event_title,thumbnail_url,start_date,end_date)); + } + + + + return myPageResponseSearch; + + } + + public String updateNickname(User loginUser,MyPageRequestNickname mprn){ + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + String nickname=mprn.getNickname(); + log.info("nickname={}", nickname); + User user=userRepository.findById(user_id).get(); + user.setNickname(nickname); + userRepository.save(user); + return userRepository.findById(user_id).get().getNickname(); + } + + public void updateProfile(User loginUser,MyPageRequestProfile mprp) throws IOException, FirebaseAuthException { + MultipartFile profile_image=mprp.getProfile_image(); + Long user_id = null; + if (loginUser != null) { + + user_id = loginUser.getUser_id(); + } + String firebaseUrl=""; + if(profile_image!=null){ + String nameFile= UUID.randomUUID().toString(); + fireBaseService.uploadFiles(profile_image,nameFile); + firebaseUrl+="https://firebasestorage.googleapis.com/v0/b/stroagetest-f0778.appspot.com/o/"+nameFile+"?alt=media"; + + } + User user=userRepository.findById(user_id).get(); + user.setProfile_url(firebaseUrl); + userRepository.save(user); + + } + + public Boolean withdrawal(User loginUser,MyPageRequestWithdrawal mrwd){ + Boolean check=false; + Long user_id = null; + if (loginUser != null) { + + user_id = loginUser.getUser_id(); + + } + String basicUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRlx2rvqRVwn6S5uXPkHl856CcYvV2z8bUMyw&usqp=CAU"; + User user=userRepository.findById(user_id).get(); + user.setUser_status(탈퇴); + user.setEmail("0"); + user.setNickname("0"); + user.setPassword("0"); + user.setProfile_url(basicUrl); + + + userRepository.save(user); + + + + if(userRepository.findById(user_id).get().getUser_status()== 탈퇴){ + check=true; + } + return check; + } + + public Result nicknameDuplicate(MyPageRequestNicknameDuplicateDto mpnd){ + + String nickname = mpnd.getNickname(); + User user = new User(); + + if (nickname != null) { + user = userRepository.findByNickname(nickname).orElse(null); + } + Result result = new Result(); + if (user == null) { + result.setResult(false); + } + else { + result.setResult(true); + } + + return result; + } + + + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/SignInService.java b/backend/src/main/java/moviegoods/movie/service/SignInService.java new file mode 100644 index 0000000..b4a6fb4 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/SignInService.java @@ -0,0 +1,300 @@ +package moviegoods.movie.service; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.configure.SessionConfig.SessionConst; +import moviegoods.movie.domain.dto.signin.SignInRequestDto; +import moviegoods.movie.domain.dto.signin.SignInResponseDto; +import moviegoods.movie.domain.dto.signup.SignUpRequestDto; +import moviegoods.movie.domain.entity.User.Method; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserStatus; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.validation.constraints.NotNull; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.stream.Collectors; + +import static moviegoods.movie.domain.entity.User.UserStatus.*; + + +@Slf4j +@Service +@RequiredArgsConstructor +public class SignInService { + + private final PasswordEncoder passwordEncoder; + private final SignUpService signUpService; + private final EntityManager em; + //private final GoogleConfigUtils googleConfigUtils; + + public SignInResponseDto login(SignInRequestDto requestDto, HttpServletRequest request) { + SignInResponseDto signInResponseDto; + String password = requestDto.getPassword(); + String email = requestDto.getEmail(); + String method = requestDto.getMethod(); + + String searchJpql = "select u from user u where u.email = '" + email + "' and u.method = '" + method + "'"; + User user; + try{ + user = em.createQuery(searchJpql, User.class).getSingleResult(); + + }catch (NoResultException e){ + signInResponseDto = new SignInResponseDto(null,null,정상, false, null); + return signInResponseDto; + } + + String existPassword = user.getPassword(); + + if(passwordEncoder.matches(password, existPassword)) { + HttpSession session = request.getSession(); + session.setMaxInactiveInterval(30*60); + session.setAttribute(SessionConst.LOGIN_MEMBER, user); + @NotNull UserStatus status = user.getUser_status(); + Enum authority = user.getAuthority(); + + signInResponseDto = new SignInResponseDto(user.getNickname(), user.getProfile_url(),status, true, authority.toString()); + + } + else { + signInResponseDto = new SignInResponseDto(null,null,정상,false, null); + } + + return signInResponseDto; + + } + + public String getKaKaoAccessToken(String code){ + + String access_Token=""; + String refresh_Token =""; + + String reqURL = "https://kauth.kakao.com/oauth/token"; + + try{ + URL url = new URL(reqURL); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream())); + StringBuilder sb = new StringBuilder(); + sb.append("grant_type=authorization_code"); + sb.append("&client_id=e64599af67aac20483ad02a14a8c5058"); // TODO REST_API_KEY 입력 + sb.append("&redirect_uri=http://localhost:3000/signin/oauth2/code/kakao"); // TODO 인가코드 받은 redirect_uri 입력 + sb.append("&code=" + code); + bw.write(sb.toString()); + bw.flush(); + + int responseCode = conn.getResponseCode(); + System.out.println("responseCode : " + responseCode); + + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line = ""; + String result = ""; + + while ((line = br.readLine()) != null) { + result += line; + } + + JsonParser parser = new JsonParser(); + JsonElement element = parser.parse(result); + + access_Token = element.getAsJsonObject().get("access_token").getAsString(); + refresh_Token = element.getAsJsonObject().get("refresh_token").getAsString(); + + br.close(); + bw.close(); + }catch (IOException e) { + e.printStackTrace(); + } + + return access_Token; + } + + public SignInRequestDto getUserInfo(String access_Token) { + + String reqURL = "https://kapi.kakao.com/v2/user/me"; + SignInRequestDto signInRequestDto = new SignInRequestDto(); + + try { + URL url = new URL(reqURL); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + + conn.setRequestProperty("Authorization", "Bearer " + access_Token); + + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + String line = ""; + String result = ""; + + while ((line = br.readLine()) != null) { + result += line; + } + + JsonParser parser = new JsonParser(); + JsonElement element = parser.parse(result); + + JsonObject properties = element.getAsJsonObject().get("properties").getAsJsonObject(); + JsonObject kakao_account = element.getAsJsonObject().get("kakao_account").getAsJsonObject(); + + Long lastUserId = getUserId(); + Long nxtUserId = lastUserId + 1; + + String originNickname = properties.getAsJsonObject().get("nickname").getAsString(); + String nickname = originNickname + nxtUserId.toString() + randomNumGen(); + String email = kakao_account.getAsJsonObject().get("email").getAsString(); + String password = email + "kakao"; + + SignUpRequestDto signUpRequestDto = new SignUpRequestDto(); + signUpRequestDto.setNickname(nickname); + signUpRequestDto.setEmail(email); + signUpRequestDto.setPassword(password); + String searchJpql = "select u from user u where u.email = '" + email + "' and u.method = '카카오'"; + List user = em.createQuery(searchJpql, User.class).getResultList(); + + if (user.size() == 0) { + signUpService.saveUser(signUpRequestDto, Method.카카오); + } + + signInRequestDto.setEmail(email); + signInRequestDto.setPassword(password); + signInRequestDto.setMethod("카카오"); + + } catch (IOException e) { + e.printStackTrace(); + } + return signInRequestDto; + } + + public String googleRequestAccessToken(String code) { + try { + URL url = new URL("https://www.googleapis.com/oauth2/v4/token"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + conn.setDoOutput(true); + + Map params = new HashMap<>(); + params.put("code", code); + params.put("client_id", "435089655733-6v1fo661d0dda2ue3ql61420dtquril1.apps.googleusercontent.com"); + params.put("client_secret", "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"); + params.put("redirect_uri", "http://localhost:3000/signin/auth/google/callback"); + params.put("grant_type", "authorization_code"); + params.put("state", "url_parameter"); + + String parameterString = params.entrySet().stream() + .map(x -> x.getKey() + "=" + x.getValue()) + .collect(Collectors.joining("&")); + + BufferedOutputStream bous = new BufferedOutputStream(conn.getOutputStream()); + bous.write(parameterString.getBytes()); + bous.flush(); + bous.close(); + + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + StringBuilder sb = new StringBuilder(); + String line; + while ((line = br.readLine()) != null) { + sb.append(line); + } + + if(conn.getResponseCode() == 200) { + return sb.toString(); + } + return "구글 로그인 요청 처리 실패"; + }catch (IOException e) { + throw new IllegalArgumentException("알 수 없는 구글 로그인 Access Token 요청 URL 입니다 :: " + "https://oauth2.googleapis.com/token"); + } + } + + public SignInRequestDto googleGetUserInfo(String access_Token) { + JsonParser accessTokenParser = new JsonParser(); + JsonElement getAccescTokenElement = accessTokenParser.parse(access_Token); + String accessToken = getAccescTokenElement.getAsJsonObject().get("access_token").getAsString(); + + String reqURL = "https://www.googleapis.com/oauth2/v2/userinfo?access_token=" + accessToken; + SignInRequestDto signInRequestDto = new SignInRequestDto(); + + try { + URL url = new URL(reqURL); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + String line = ""; + String result = ""; + + while ((line = br.readLine()) != null) { + result += line; + } + + JsonParser parser = new JsonParser(); + JsonElement element = parser.parse(result); + Long lastUserId = getUserId(); + Long nxtUserId = lastUserId + 1; + + String originNickname = element.getAsJsonObject().get("name").getAsString(); + String nickname = originNickname + nxtUserId.toString() + randomNumGen(); + System.out.println("nickname : " + nickname); + + String email = element.getAsJsonObject().get("email").getAsString(); + String password = email + "google"; + + SignUpRequestDto signUpRequestDto = new SignUpRequestDto(); + signUpRequestDto.setNickname(nickname); + signUpRequestDto.setEmail(email); + signUpRequestDto.setPassword(password); + String searchJpql = "select u from user u where u.email = '" + email + "' and u.method = '구글'"; + List user = em.createQuery(searchJpql, User.class).getResultList(); + + if (user.size() == 0) { + signUpService.saveUser(signUpRequestDto, Method.구글); + } + + signInRequestDto.setEmail(email); + signInRequestDto.setPassword(password); + signInRequestDto.setMethod("구글"); + + } catch (IOException e) { + e.printStackTrace(); + } + return signInRequestDto; + } + public static String randomNumGen() { + Random random = new Random(); + String numStr = ""; + + for(int i=0; i<4; i++) { + //0~9 난수 생성 + String ran = Integer.toString(random.nextInt(10)); + numStr += ran; + } + + return numStr; + } + + public Long getUserId() { + String getLastUserIdJpql = "select MAX(u.user_id) from user u"; + Object lastUserId = em.createQuery(getLastUserIdJpql).getSingleResult(); + return Long.valueOf(String.valueOf(lastUserId)); + } +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/SignUpService.java b/backend/src/main/java/moviegoods/movie/service/SignUpService.java new file mode 100644 index 0000000..33c111a --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/SignUpService.java @@ -0,0 +1,74 @@ +package moviegoods.movie.service; + +import lombok.RequiredArgsConstructor; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.dto.signup.SignUpDuplicateCheckRequestDto; +import moviegoods.movie.domain.dto.signup.SignUpRequestDto; +import moviegoods.movie.domain.entity.User.*; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +import static moviegoods.movie.domain.entity.User.Method.*; +import static moviegoods.movie.domain.entity.User.UserStatus.정상; + + +@Service +@RequiredArgsConstructor +public class SignUpService { + + private final UserRepository userRepository; + private final PasswordEncoder passwordEncoder; + private static String basicUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRlx2rvqRVwn6S5uXPkHl856CcYvV2z8bUMyw&usqp=CAU"; + private static Long basicReliability = 0L; + private static UserStatus basicStatus = 정상; + + public ResultResponseDto saveUser(SignUpRequestDto requestDto, Method method) { + String email = requestDto.getEmail(); + String nickname = requestDto.getNickname(); + String password = requestDto.getPassword(); + + String encodedPassword = passwordEncoder.encode(password); + User saveEntity = new User(); + + if (method==일반) { + saveEntity = User.builder().authority(Authority.일반).email(email).user_status(basicStatus).reliability(basicReliability). + nickname(nickname).password(encodedPassword).profile_url(basicUrl).method(일반).build(); + } + if (method==카카오) { + saveEntity = User.builder().authority(Authority.일반).email(email).user_status(basicStatus).reliability(basicReliability). + nickname(nickname).password(encodedPassword).profile_url(basicUrl).method(카카오).build(); + } + if (method==구글) { + saveEntity = User.builder().authority(Authority.일반).email(email).user_status(basicStatus).reliability(basicReliability). + nickname(nickname).password(encodedPassword).profile_url(basicUrl).method(구글).build(); + } + + ResultResponseDto resultResponseDto = new ResultResponseDto(); + userRepository.save(saveEntity); + resultResponseDto.setResult(true); + + return resultResponseDto; + } + + public ResultResponseDto duplicateCheck(SignUpDuplicateCheckRequestDto requestDto,Method method) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + String email = requestDto.getEmail(); + String nickname = requestDto.getNickname(); + + User user = new User(); + if (email != null) { + user = (User) userRepository.findByEmailAndMethod(email,method).orElse(null); + } + if (nickname != null) { + user = userRepository.findByNickname(nickname).orElse(null); + } + + resultResponseDto.setResult(true); + if (user == null) { + resultResponseDto.setResult(false); + } + + return resultResponseDto; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/moviegoods/movie/service/TransactionsService.java b/backend/src/main/java/moviegoods/movie/service/TransactionsService.java new file mode 100644 index 0000000..d6241e0 --- /dev/null +++ b/backend/src/main/java/moviegoods/movie/service/TransactionsService.java @@ -0,0 +1,237 @@ +package moviegoods.movie.service; + + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import moviegoods.movie.domain.dto.booleanResult.ResultResponseDto; +import moviegoods.movie.domain.entity.Content_Detail.Content_Detail; +import moviegoods.movie.domain.entity.Like_Basket.LikeBasketRepository; +import moviegoods.movie.domain.entity.Like_Basket.Like_Basket; +import moviegoods.movie.domain.entity.Report.Report; +import moviegoods.movie.domain.entity.Report.ReportRepository; +import moviegoods.movie.domain.entity.Transaction.Status; +import moviegoods.movie.domain.entity.Transaction.Transaction; +import moviegoods.movie.domain.entity.Transaction.TransactionRepository; +import moviegoods.movie.domain.entity.User.User; +import moviegoods.movie.domain.entity.User.UserStatus; +import moviegoods.movie.domain.entity.User.UserRepository; +import moviegoods.movie.domain.dto.transactions.*; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityManager; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static moviegoods.movie.domain.entity.Transaction.Status.*; + +@RequiredArgsConstructor +@Service +@Slf4j +public class TransactionsService { + + private final TransactionRepository transactionRepository; + private final UserRepository userRepository; + private final LikeBasketRepository likeBasketRepository; + private final ReportRepository reportRepository; + private final ContentDetailService contentDetailService; + private final LikeBasketsService likeBasketsService; + private final EntityManager em; + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto write(User loginUser,TransactionsSaveRequestDto requestDto) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + Long user_id = loginUser.getUser_id(); + + String content = requestDto.getContent(); + Status status = 진행중; + + User user = userRepository.getById(user_id); + Content_Detail content_detail = contentDetailService.saveContentDetail(content); + Transaction saveEntity = Transaction.builder().user(user).content_detail(content_detail).status(status).build(); + + transactionRepository.save(saveEntity); + resultResponseDto.setResult(true); + + return resultResponseDto; + } + + @Transactional(rollbackFor = Exception.class) + public List search(User loginUser, TransactionsSearchRequestDto requestDto) { + Long user_id = null; + if (loginUser != null) { + user_id = loginUser.getUser_id(); + } + + List searchList = new ArrayList<>(); + + Boolean is_proceed = requestDto.getIs_proceed(); // 모집중(1) , 전체(0) + String search_word = requestDto.getSearch_word(); // 검색어 + String search_criteria = requestDto.getSearch_criteria(); // 작성자/글내용 + Long start = requestDto.getStart(); + Long end = requestDto.getEnd(); + String linking_word = "where "; + + if (search_word == null) { + search_word = ""; + } + + String searchJpql = "select t from transaction t join t.user u join t.content_detail c where "; + Integer check = 0; + + // 작성자/글내용 (기본 값 줘야) + String criteriaJpql = ""; + if (search_criteria != null) { + check++; + if (Objects.equals(search_criteria, "작성자")) { + criteriaJpql = "u.nickname"; + } + if (Objects.equals(search_criteria, "글내용")) { + criteriaJpql= "c.content"; + } + searchJpql += criteriaJpql + " like '%" + search_word + "%' "; + } + + // 진행여부 + if (Objects.equals(is_proceed, true)) { + if (check == 1) { + linking_word = "and "; + } + log.info("check={},searchJpql={}", check, searchJpql); + searchJpql += linking_word+ "t.status = '진행중' "; + } + + // 정렬 기준(최신순) 기본 값 줘야 + searchJpql += "order by c.written_date desc"; + log.info("searchJpql={}", searchJpql); + + List transactionList = em.createQuery(searchJpql, Transaction.class).setFirstResult(start.intValue()).setMaxResults(end.intValue()).getResultList(); + for (Transaction transaction : transactionList) { + Long search_user_id = transaction.getUser().getUser_id(); + Long reliability = transaction.getUser().getReliability(); + String content = transaction.getContent_detail().getContent(); + String status2 = String.valueOf(transaction.getStatus()); + UserStatus user_status = transaction.getUser().getUser_status(); + Long transaction_id = transaction.getTransaction_id(); + LocalDateTime written_date = transaction.getContent_detail().getWritten_date(); + String nickname = transaction.getUser().getNickname(); + String profile_url = transaction.getUser().getProfile_url(); + + Boolean is_mine = Boolean.FALSE; + if (search_user_id == user_id) { + is_mine = Boolean.TRUE; + } + + Boolean is_like = likeBasketsService.isLikeTransaction(user_id, transaction_id); + + searchList.add(new TransactionsSearchResponseDto(search_user_id, content, status2, user_status, transaction_id, + reliability, written_date, is_mine, is_like,nickname,profile_url)); + } + return searchList; + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto changeStatus(User loginUser, TransactionsChangeStatusRequestDto requestDto) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + String status = requestDto.getStatus(); + Long transaction_id = requestDto.getTransaction_id(); + + Transaction transaction = transactionRepository.getById(transaction_id); + + if (transaction.getUser().getUser_id() != loginUser.getUser_id() || loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + + if (Objects.equals(status,"진행중")) { + transaction.setStatus(마감); + } + if (Objects.equals(status, "마감")) { + transaction.setStatus(진행중); + } + + transactionRepository.save(transaction); + resultResponseDto.setResult(true); + + return resultResponseDto; + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto delete(User loginUser, TransactionsDeleteRequestDto requestDto) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long transaction_id = requestDto.getTransaction_id(); + + Transaction transaction = transactionRepository.getById(transaction_id); + + if (transaction.getUser().getUser_id() != loginUser.getUser_id() || loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + transactionRepository.delete(transaction); + resultResponseDto.setResult(true); + + return resultResponseDto; + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto report(User loginUser, TransactionsReportRequestDto requestDto) { + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long transaction_id = requestDto.getTransaction_id(); + String content = requestDto.getContent(); + + Transaction transaction = transactionRepository.getById(transaction_id); + Content_Detail content_detail = contentDetailService.saveContentDetail(content); + + if (transaction.getUser() != loginUser || loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + Report saveEntity = Report.builder().user(loginUser).transaction(transaction).content_detail(content_detail).build(); + reportRepository.save(saveEntity); + + resultResponseDto.setResult(true); + + return resultResponseDto; + + } + + @Transactional(rollbackFor = Exception.class) + public ResultResponseDto like(User loginUser, TransactionsLikeRequestDto requestDto){ + ResultResponseDto resultResponseDto = new ResultResponseDto(); + Long transaction_id = requestDto.getTransaction_id(); + + Transaction transaction = transactionRepository.getById(transaction_id); + + if (loginUser == null) { + resultResponseDto.setResult(false); + return resultResponseDto; + } + + Long user_id = loginUser.getUser_id(); + Boolean is_like = likeBasketsService.isLikeTransaction(user_id, transaction_id); + + Boolean result = false; + if (Objects.equals(is_like,false)) { + Like_Basket saveEntity=Like_Basket.builder().user(loginUser).transaction(transaction).build(); + likeBasketRepository.save(saveEntity); + result = true; + } + if (Objects.equals(is_like, true)) { + Long like_basket_id = likeBasketsService.selectLikeTransaction(user_id,transaction_id); + result = likeBasketsService.deleteLike(like_basket_id,user_id); + } + + resultResponseDto.setResult(result); + + return resultResponseDto; + + } + +} diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties new file mode 100644 index 0000000..2c0462d --- /dev/null +++ b/backend/src/main/resources/application.properties @@ -0,0 +1,12 @@ +spring.profiles.include = aws + +#update the schema with the given values. +spring.jpa.hibernate.ddl-auto=update +#To beautify or pretty print the SQL +spring.jpa.properties.hibernate.format_sql=true +#show sql +spring.jpa.properties.hibernate.show-sql=true +#show parameter binding +logging.level.org.hibernate.type.descriptor.sql=DEBUG +logging.level.org.hibernate.SQL=DEBUG +server.servlet.session.tracking-modes=cookie \ No newline at end of file diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml new file mode 100644 index 0000000..13a5516 --- /dev/null +++ b/backend/src/main/resources/application.yml @@ -0,0 +1,9 @@ +spring: + + mvc: + + pathmatch: + + matching-strategy: ant_path_matcher + + diff --git a/backend/src/main/resources/chromedriver1.exe b/backend/src/main/resources/chromedriver1.exe new file mode 100644 index 0000000..57070d5 Binary files /dev/null and b/backend/src/main/resources/chromedriver1.exe differ diff --git a/backend/src/main/resources/serviceAccountKey.json b/backend/src/main/resources/serviceAccountKey.json new file mode 100644 index 0000000..091035d --- /dev/null +++ b/backend/src/main/resources/serviceAccountKey.json @@ -0,0 +1,13 @@ +{ + "type": "service_account", + "project_id": "stroagetest-f0778", + "private_key_id": "9fd65b6218951b3777f6eabd7a0455effec12c46", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDioVOozDvAWC4t\nJ3ViUVr/DEIcC9hQdCIjNrt973N713LIVL+9mpGpeQmvXKWyInaEumZrAfnjKYPy\n8aDxN4tZgbeuCt8wRXalLo6Ly7VkahVDja3iMkUF+7dyOKMwmqNRx5npg6P0YUN2\nOdQ9Nwb9tw9CwScBj8edhb/g5XDg+c6sNmhNbmZP1h/9eUR/ytlDLv9cAL9A/Rzf\nmfHDEtmSeUw5Z84Hv7QDaTbP9bXAX05lKNqASabpzvhlc/g2UO4NxTZJ9UKMKKKe\neUcn/H1orS+tlewd1BqFIj8vZUInPjLLy6TrbL0zXuydeZOFaD8KtX6lPRqMhZWl\n7aEuU83lAgMBAAECggEAKWUDNWE8hrj0kj3TVIZ8ovpXtuy48ZUMyTbNj0al5thm\n+E12ikjJ01Uu3i+DemKOGFc9rsz5GjNyjPTyiyy0kMA/TxRgSN5fOfOjiMhIFRPF\nV4Xw3VCGR/3+t2e98vpD24OkSsFHOLNtUZJlgFrlNYFy0aQbHk9nTA/qiMcP05+l\nS2gW9DaQBDfGPj5algJApY7mYTF41viKi+k8W1qeYFQrOkbXdWxqvG3JBrRU3jBe\nf4tiuL9GbVPAAwiUtL19kWN2lVdK1TBOqXTvue6W9vQ7QGX39Dtx5CR793Bo4ApU\nJn0bGDtIS/Q8DvWtYyijdp86YD5l+pdkEvInLkzKQQKBgQD2SDIguWfdGvRwqd/A\nOyaKstUEW5LSWcr5RP1YTadjzUKaPWHQzqbRjAg0uAdmUjLQNrBbrZBCoOJY2+7k\neoFhED2DUTawMWKVAsEv0YUCX4bSXTTwd7kMprfjFR8VWcs0RajMf4Qw80vPDXbw\nDNdxxrg+3TbqKYS65y2YWNmmxQKBgQDrkp58VK4ca9DVZ15uWbtWEE1oKf7++bU5\nP1zaX6j+OWm7RGGRu1cM0E/Qm1F5pU01lsL0l62CFXzHQWTVLEkk+M2Ze900CwtC\n2oGK4MB+isa+ZHzR5jZMFBuB8latnyI3MJkC7fKx4moXeV5Hywd1e0dGySxTdbgC\nso4o7Kj8oQKBgQCYRESx1M+xdUPiEDUlfayzniNzoUZiRV/nw8669K/kVXizMfYz\nCkE7V0+PgKQakAGYl+drlyCVATFQbRIDMvag01CkyuZ8AtyHcn+MmAabVAJgN35O\nmkbP2pfgjyN7qNuowtS9Mq3BMfsR1apOejINxyYMv+p+1hKZF+spwO04XQKBgFdg\n8iJh8pceMr8FcZRy+jbpIx0w/qGrE9phM1rYwsFRoHNS4PICUD6zgfd5tRXvB52K\nB1RccoJe4AK0secUXyk0lGaK+DjWo92vWP+fcCc/6Io0kcv1nUxI5Q8lSZtq/HEG\nOKtKgYwT1JBSd3Mfzut3x69s7WEjuBZgDrUFW4UhAoGAEpY+ZT3tH+XyBKrI//Vh\n6cU5SEO9Z4+ab57pDc8udYnh2plGY/SS+C+R4rXn0dxC5Ov8rDQwbk/fbh0Un1xc\ncQ0Dr30NhiMj4S+hmRkVtt3KnT/0tLAw4j+uuF9o8R52GT6u2ZPFWyDCRqhSsJw9\nlnPpfcuMGJmPMaMJQ7ociaE=\n-----END PRIVATE KEY-----\n", + "client_email": "firebase-adminsdk-eylqz@stroagetest-f0778.iam.gserviceaccount.com", + "client_id": "116140786617576509246", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-eylqz%40stroagetest-f0778.iam.gserviceaccount.com" +} + diff --git a/backend/src/test/java/moviegoods/movie/MovieApplicationTests.java b/backend/src/test/java/moviegoods/movie/MovieApplicationTests.java new file mode 100644 index 0000000..5a44a85 --- /dev/null +++ b/backend/src/test/java/moviegoods/movie/MovieApplicationTests.java @@ -0,0 +1,13 @@ +package moviegoods.movie; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MovieApplicationTests { + + @Test + void contextLoads() { + } + +}