From 2e6776fd10f8e56b30374430009cf1c51754b4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Mon, 26 Aug 2024 21:55:58 +0900 Subject: [PATCH] =?UTF-8?q?Init:=20=EB=B0=B1=EC=97=94=EB=93=9C=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=A0=9D=ED=8A=B8=20=EC=B4=88=EA=B8=B0=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + backend/.gitignore | 195 ++++++++++++++ backend/HELP.md | 29 ++ backend/build.gradle | 40 +++ backend/gradlew | 249 ++++++++++++++++++ backend/gradlew.bat | 92 +++++++ backend/settings.gradle | 1 + .../com/worlabel/WorLabelApplication.java | 16 ++ .../domain/auth/entity/ProviderType.java | 6 + .../domain/comment/entity/Comment.java | 50 ++++ .../worlabel/domain/folder/entity/Folder.java | 54 ++++ .../worlabel/domain/image/entity/Image.java | 61 +++++ .../domain/image/entity/LabelStatus.java | 5 + .../worlabel/domain/label/entity/Label.java | 45 ++++ .../worlabel/domain/member/entity/Member.java | 59 +++++ .../domain/member/entity/RoleType.java | 5 + .../participant/entity/Participant.java | 32 +++ .../participant/entity/PrivilegeType.java | 8 + .../domain/project/entity/LabelCategory.java | 37 +++ .../domain/project/entity/Project.java | 47 ++++ .../domain/workspace/entity/Workspace.java | 45 ++++ .../worlabel/global/common/BaseEntity.java | 28 ++ .../worlabel/WorlabelApplicationTests.java | 13 + 23 files changed, 1119 insertions(+) create mode 100644 .gitignore create mode 100644 backend/.gitignore create mode 100644 backend/HELP.md create mode 100644 backend/build.gradle create mode 100644 backend/gradlew create mode 100644 backend/gradlew.bat create mode 100644 backend/settings.gradle create mode 100644 backend/src/main/java/com/worlabel/WorLabelApplication.java create mode 100644 backend/src/main/java/com/worlabel/domain/auth/entity/ProviderType.java create mode 100644 backend/src/main/java/com/worlabel/domain/comment/entity/Comment.java create mode 100644 backend/src/main/java/com/worlabel/domain/folder/entity/Folder.java create mode 100644 backend/src/main/java/com/worlabel/domain/image/entity/Image.java create mode 100644 backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java create mode 100644 backend/src/main/java/com/worlabel/domain/label/entity/Label.java create mode 100644 backend/src/main/java/com/worlabel/domain/member/entity/Member.java create mode 100644 backend/src/main/java/com/worlabel/domain/member/entity/RoleType.java create mode 100644 backend/src/main/java/com/worlabel/domain/participant/entity/Participant.java create mode 100644 backend/src/main/java/com/worlabel/domain/participant/entity/PrivilegeType.java create mode 100644 backend/src/main/java/com/worlabel/domain/project/entity/LabelCategory.java create mode 100644 backend/src/main/java/com/worlabel/domain/project/entity/Project.java create mode 100644 backend/src/main/java/com/worlabel/domain/workspace/entity/Workspace.java create mode 100644 backend/src/main/java/com/worlabel/global/common/BaseEntity.java create mode 100644 backend/src/test/java/com/worlabel/worlabel/WorlabelApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ca0973 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store + diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..4bec9a0 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,195 @@ +# Created by https://www.toptal.com/developers/gitignore/api/java,intellij+all,redis,macos,windows +# Edit at https://www.toptal.com/developers/gitignore?templates=java,intellij+all,redis,macos,windows + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle wrapper files +/gradle/wrapper/gradle-wrapper.properties +/gradle/wrapper/gradle-wrapper.jar + +# Local Gradle settings +.gradle/ +/build/ + +# Gradle project-specific caches +gradle-app.setting + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij+all Patch ### +# Ignore everything but code style settings and run configurations +# that are supposed to be shared within teams. + +.idea/* + +!.idea/codeStyles +!.idea/runConfigurations + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Redis ### +# Ignore redis binary dump (dump.rdb) files + +*.rdb + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +src/main/resources/application.properties + +# End of https://www.toptal.com/developers/gitignore/api/java,intellij+all,redis,macos,windows \ No newline at end of file diff --git a/backend/HELP.md b/backend/HELP.md new file mode 100644 index 0000000..9e32149 --- /dev/null +++ b/backend/HELP.md @@ -0,0 +1,29 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Gradle documentation](https://docs.gradle.org) +* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/3.3.3/gradle-plugin) +* [Create an OCI image](https://docs.spring.io/spring-boot/3.3.3/gradle-plugin/packaging-oci-image.html) +* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#web) +* [Spring Security](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#web.security) +* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) +* [Securing a Web Application](https://spring.io/guides/gs/securing-web/) +* [Spring Boot and OAuth2](https://spring.io/guides/tutorials/spring-boot-oauth2/) +* [Authenticating a User with LDAP](https://spring.io/guides/gs/authenticating-ldap/) +* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) + +### Additional Links +These additional references should also help you: + +* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) + diff --git a/backend/build.gradle b/backend/build.gradle new file mode 100644 index 0000000..af3bedb --- /dev/null +++ b/backend/build.gradle @@ -0,0 +1,40 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.3.3' + id 'io.spring.dependency-management' version '1.1.6' +} + +group = 'com.worlabel' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.security:spring-security-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/backend/gradlew b/backend/gradlew new file mode 100644 index 0000000..b740cf1 --- /dev/null +++ b/backend/gradlew @@ -0,0 +1,249 @@ +#!/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/HEAD/platforms/jvm/plugins-application/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 + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# 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 + if ! command -v java >/dev/null 2>&1 + then + 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 +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + 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 + + +# 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"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# 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..7101f8e --- /dev/null +++ b/backend/gradlew.bat @@ -0,0 +1,92 @@ +@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=. +@rem This is normally unused +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% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +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% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend/settings.gradle b/backend/settings.gradle new file mode 100644 index 0000000..7239aec --- /dev/null +++ b/backend/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'worlabel' diff --git a/backend/src/main/java/com/worlabel/WorLabelApplication.java b/backend/src/main/java/com/worlabel/WorLabelApplication.java new file mode 100644 index 0000000..150c80e --- /dev/null +++ b/backend/src/main/java/com/worlabel/WorLabelApplication.java @@ -0,0 +1,16 @@ +package com.worlabel; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.util.TimeZone; + +@SpringBootApplication +public class WorLabelApplication { + + public static void main(String[] args) { + // EC2 스프링 서버 설정을 위해 추가 + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + SpringApplication.run(WorLabelApplication.class, args); + } +} diff --git a/backend/src/main/java/com/worlabel/domain/auth/entity/ProviderType.java b/backend/src/main/java/com/worlabel/domain/auth/entity/ProviderType.java new file mode 100644 index 0000000..e17e36d --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/auth/entity/ProviderType.java @@ -0,0 +1,6 @@ +package com.worlabel.domain.auth.entity; + +// 확장 대비 +public enum ProviderType { + GOOGLE +} diff --git a/backend/src/main/java/com/worlabel/domain/comment/entity/Comment.java b/backend/src/main/java/com/worlabel/domain/comment/entity/Comment.java new file mode 100644 index 0000000..d905004 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/comment/entity/Comment.java @@ -0,0 +1,50 @@ +package com.worlabel.domain.comment.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.worlabel.domain.member.entity.Member; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name= "comment") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Comment extends BaseEntity { + + /** + * 코멘트 PK + */ + @Id + @Column(name = "comment_id",nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 코멘트 내용 + */ + @Column(name = "content",nullable = false) + private String content; + + /** + * 코멘트 위치(x) + */ + @Column(name = "positionX",nullable = true) + private double positionX; + + /** + * 코멘트 위치(y) + */ + @Column(name = "positionY",nullable = true) + private double positionY; + + /** + * 속한 사용자 + */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id",nullable = false) + @JsonIgnore + private Member member; +} diff --git a/backend/src/main/java/com/worlabel/domain/folder/entity/Folder.java b/backend/src/main/java/com/worlabel/domain/folder/entity/Folder.java new file mode 100644 index 0000000..4a642c7 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/folder/entity/Folder.java @@ -0,0 +1,54 @@ +package com.worlabel.domain.folder.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.worlabel.domain.image.entity.Image; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Table(name = "folder") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Folder extends BaseEntity { + + /** + * 폴더 PK + */ + @Id + @Column(name = "folder_id", nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 폴더 이름 + */ + @Column(name = "title",nullable = false) + private String title; + + /** + * 상위 폴더 + * 없다면 최상위 폴더 + */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_id") + @JsonIgnore + private Folder parent; + + /** + * 하위 폴더 리스트 + */ + @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true) + private List children = new ArrayList<>(); + + /** + * 폴더에 속한 이미지 + */ + @OneToMany(mappedBy = "folder", fetch = FetchType.LAZY, cascade = CascadeType.ALL,orphanRemoval = true) + private List imageList = new ArrayList<>(); +} diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/Image.java b/backend/src/main/java/com/worlabel/domain/image/entity/Image.java new file mode 100644 index 0000000..aff806e --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/image/entity/Image.java @@ -0,0 +1,61 @@ +package com.worlabel.domain.image.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.worlabel.domain.folder.entity.Folder; +import com.worlabel.domain.label.entity.Label; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Table(name = "project_image") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Image extends BaseEntity { + + /** + * 프로젝트 이미지 ID + */ + @Id + @Column(name = "project_image_id",nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 이미지 URL + */ + @Column(name = "image_url", nullable = false,length=255) + private String imageUrl; + + /** + * 이미지 순서 + */ + @Column(name = "image_order", nullable = false) + private Integer order; + + /** + * 이미지 레이블링 상태 + */ + @Enumerated(EnumType.STRING) + @Column(name = "status",nullable = false) + private LabelStatus status = LabelStatus.Pending; + + /** + * 속한 폴더 + */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "folder_id", nullable = false) + @JsonIgnore + private Folder folder; + + /** + * 이미지에 연결된 레이블 + */ + @OneToOne(mappedBy = "image",cascade = CascadeType.ALL, orphanRemoval = true) + private Label label; +} diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java b/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java new file mode 100644 index 0000000..55e8f0c --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java @@ -0,0 +1,5 @@ +package com.worlabel.domain.image.entity; + +public enum LabelStatus { + Pending, NEED_REVIEW, COMPLETED +} diff --git a/backend/src/main/java/com/worlabel/domain/label/entity/Label.java b/backend/src/main/java/com/worlabel/domain/label/entity/Label.java new file mode 100644 index 0000000..d47eb10 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/label/entity/Label.java @@ -0,0 +1,45 @@ +package com.worlabel.domain.label.entity; + +import com.worlabel.domain.image.entity.Image; +import com.worlabel.domain.project.entity.LabelCategory; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "label") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Label extends BaseEntity { + + /** + * 레이블 PK + */ + @Id + @Column(name ="label_id",nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 레이블 파일 URL + */ + @Column(name = "label_url",nullable = true,length = 255) + private String url; + + /** + * 속한 이미지 + */ + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "image_id") + private Image image; + + /** + * 속한 카테고리 + * TODO: 한 레이블 카테고리에 속한걸 찾는데에 Json파일에 담기 때문에 카테고리는 Label Entity에 없어도 될 것 같음 + */ +// @ManyToOne(fetch = FetchType.LAZY) +// @JoinColumn(name = "label_category_id") +// private LabelCategory labelCategory; +} diff --git a/backend/src/main/java/com/worlabel/domain/member/entity/Member.java b/backend/src/main/java/com/worlabel/domain/member/entity/Member.java new file mode 100644 index 0000000..4e09ed7 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/member/entity/Member.java @@ -0,0 +1,59 @@ +package com.worlabel.domain.member.entity; + +import com.worlabel.domain.auth.entity.ProviderType; +import com.worlabel.domain.comment.entity.Comment; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Table(name = "member") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Member extends BaseEntity { + + /** + * 사용자 PK + */ + @Id + @Column(name = "member_id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 제공받은 사용자 ID + */ + @Column(name = "provider_member_id", nullable = false, length = 255) + private String providerMemberId; + + /** + * oAuth 제공자 타입 + */ + @Column(name = "provider", nullable = false) + @Enumerated(EnumType.STRING) + private ProviderType provider = ProviderType.GOOGLE; + + /** + * 사용자 역할 + */ + @Column(name = "user_role", nullable = false) + @Enumerated(EnumType.STRING) + private RoleType role = RoleType.USER; + + /** + * 프로필 이미지 + */ + @Column(name = "profile_image", nullable = false) + private String profileImage; + + /** + * 작성한 코멘트 + */ + @OneToMany(mappedBy = "member", fetch = FetchType.LAZY,cascade = CascadeType.ALL, orphanRemoval = true) + private List commentList = new ArrayList<>(); +} diff --git a/backend/src/main/java/com/worlabel/domain/member/entity/RoleType.java b/backend/src/main/java/com/worlabel/domain/member/entity/RoleType.java new file mode 100644 index 0000000..0089413 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/member/entity/RoleType.java @@ -0,0 +1,5 @@ +package com.worlabel.domain.member.entity; + +public enum RoleType { + USER, ADMIN +} diff --git a/backend/src/main/java/com/worlabel/domain/participant/entity/Participant.java b/backend/src/main/java/com/worlabel/domain/participant/entity/Participant.java new file mode 100644 index 0000000..d956cff --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/participant/entity/Participant.java @@ -0,0 +1,32 @@ +package com.worlabel.domain.participant.entity; + +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * 프로젝트 참여 Entity + */ +@Getter +@Entity +@Table(name = "participant") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Participant extends BaseEntity { + + /** + * 프로젝트 PK + */ + @Id + @Column(name = "participant_id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 프로젝트 권한 + */ + @Column(name = "participant_privilege",nullable = false) + @Enumerated(EnumType.STRING) + private PrivilegeType privilege; +} diff --git a/backend/src/main/java/com/worlabel/domain/participant/entity/PrivilegeType.java b/backend/src/main/java/com/worlabel/domain/participant/entity/PrivilegeType.java new file mode 100644 index 0000000..c6ad16e --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/participant/entity/PrivilegeType.java @@ -0,0 +1,8 @@ +package com.worlabel.domain.participant.entity; + +/** + * 프로젝트 참여 권한 + */ +public enum PrivilegeType { + ADMIN, MANAGER, EDITOR, VIEWER +} diff --git a/backend/src/main/java/com/worlabel/domain/project/entity/LabelCategory.java b/backend/src/main/java/com/worlabel/domain/project/entity/LabelCategory.java new file mode 100644 index 0000000..370cac4 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/project/entity/LabelCategory.java @@ -0,0 +1,37 @@ +package com.worlabel.domain.project.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "label_category") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class LabelCategory extends BaseEntity { + + /** + * 카테고리 ID + */ + @Id + @Column(name = "label_category_id", nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 레이블 카테고리 이름 + */ + @Column(name = "label_category_name",nullable = false,length = 50) + private String name; + + /** + * 사용되는 프로젝트 + */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "project_id", nullable = false) + @JsonIgnore + private Project project; +} diff --git a/backend/src/main/java/com/worlabel/domain/project/entity/Project.java b/backend/src/main/java/com/worlabel/domain/project/entity/Project.java new file mode 100644 index 0000000..ffbf5b6 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/project/entity/Project.java @@ -0,0 +1,47 @@ +package com.worlabel.domain.project.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.worlabel.domain.workspace.entity.Workspace; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Table(name = "project") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Project extends BaseEntity { + + /** + * 프로젝트 ID + */ + @Id + @Column(name = "project_id", nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 프로젝트 제목 + */ + @Column(name = "title", length = 50) + private String title; + + /** + * 소속된 워크 스페이스 + */ + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "workspace_id", nullable = false) + @JsonIgnore + private Workspace workspace; + + /** + * 사용하는 레이블 카테고리 + */ + @OneToMany(mappedBy = "project", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + private List labelCategoryList = new ArrayList<>(); +} diff --git a/backend/src/main/java/com/worlabel/domain/workspace/entity/Workspace.java b/backend/src/main/java/com/worlabel/domain/workspace/entity/Workspace.java new file mode 100644 index 0000000..18b1dc9 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/workspace/entity/Workspace.java @@ -0,0 +1,45 @@ +package com.worlabel.domain.workspace.entity; + +import com.worlabel.domain.project.entity.Project; +import com.worlabel.global.common.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Table(name = "workspace") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Workspace extends BaseEntity { + + /** + * 워크 스페이스 PK + */ + @Id + @Column(name = "workspace_id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + /** + * 워크 스페이스 제목 + */ + @Column(name = "title",nullable = false, length = 50) + private String title; + + /** + * 워크 스페이스 설명 + */ + @Column(name = "description", nullable = false,length = 255) + private String description; + + /** + * 워크 스페이스에 속한 프로젝트 + */ + @OneToMany(mappedBy = "workspace", fetch = FetchType.LAZY,cascade = CascadeType.ALL, orphanRemoval = true) + private List projectList = new ArrayList<>(); + +} diff --git a/backend/src/main/java/com/worlabel/global/common/BaseEntity.java b/backend/src/main/java/com/worlabel/global/common/BaseEntity.java new file mode 100644 index 0000000..2686d98 --- /dev/null +++ b/backend/src/main/java/com/worlabel/global/common/BaseEntity.java @@ -0,0 +1,28 @@ +package com.worlabel.global.common; + +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; + +import java.time.LocalDateTime; + +@MappedSuperclass +@Getter +public class BaseEntity { + + /** + * 생성일시 + */ + @CreationTimestamp + @Column(name = "created_at", nullable = false, updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + private LocalDateTime createdAt; + + /** + * 수정일시 + */ + @UpdateTimestamp + @Column(name = "updated_at", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") + private LocalDateTime updatedAt; +} diff --git a/backend/src/test/java/com/worlabel/worlabel/WorlabelApplicationTests.java b/backend/src/test/java/com/worlabel/worlabel/WorlabelApplicationTests.java new file mode 100644 index 0000000..92132ad --- /dev/null +++ b/backend/src/test/java/com/worlabel/worlabel/WorlabelApplicationTests.java @@ -0,0 +1,13 @@ +package com.worlabel.worlabel; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class WorlabelApplicationTests { + + @Test + void contextLoads() { + } + +}