diff --git a/ .coderabbit.yaml b/ .coderabbit.yaml new file mode 100644 index 00000000..20d4875d --- /dev/null +++ b/ .coderabbit.yaml @@ -0,0 +1,22 @@ +reviewer: "code-review-bot" +language: "ko-KR" +frameworks: + - "Spring Boot" + - "JPA" +rules: + - name: "Spring Boot Best Practices" + - name: "Avoid Field Injection" + - name: "Avoid N+1 Queries" + - name: "Use Constructor Injection" +style: "concise" +ignore: + - path: "src/test/" + - path: "**/*.md" +reviews: + review_status: true + profile: "chill" + auto_review: + enabled: true + drafts: false +chat: + auto_reply: true \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/.github/pull_request_template.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md rename to .github/pull_request_template.md diff --git a/.github/workflows/cd-develop.yml b/.github/workflows/cd-develop.yml new file mode 100644 index 00000000..f0a219dd --- /dev/null +++ b/.github/workflows/cd-develop.yml @@ -0,0 +1,82 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ develop ] # develop 브랜치에 push가 일어날 때 실행 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 # 저장소 코드 체크아웃 + + - name: Set up JDK 17 # Java 개발 킷 설정 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Make application.yml # application.yml 파일 생성 + run: | + cd ./src/main/resources + echo "${{ secrets.APPLICATION_YML }}" > ./application.yml + shell: bash + + - name: Grant execute permission for gradlew # gradlew 실행 권한 부여 + run: chmod +x gradlew + + - name: Build with Gradle # Gradle을 사용하여 프로젝트 빌드 + uses: gradle/gradle-build-action@v2 + with: + arguments: build + + - name: Upload build artifact # 빌드된 아티팩트 업로드 + uses: actions/upload-artifact@v3 + with: + name: umc7thServer + path: build/libs/*.jar + + deploy: + needs: build # build 작업이 성공적으로 완료된 후 실행 + runs-on: ubuntu-latest + + steps: + - name: Download build artifact # 이전 단계에서 업로드한 아티팩트 다운로드 + uses: actions/download-artifact@v3 + with: + name: umc7thServer + path: build/libs/ + + - name: Deploy to EC2 # EC2에 배포 + env: + EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }} + EC2_USERNAME: ${{ secrets.EC2_USERNAME }} + EC2_HOST: ${{ secrets.EC2_HOST }} + run: | + echo "$EC2_SSH_KEY" > private_key.pem + chmod 600 private_key.pem + jar_file=$(find build/libs -name '*.jar' ! -name '*plain.jar' | head -n 1) + scp -i private_key.pem -o StrictHostKeyChecking=no "$jar_file" $EC2_USERNAME@$EC2_HOST:/home/$EC2_USERNAME/umc7thServer.jar + ssh -i private_key.pem -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST " + pgrep java | xargs -r kill -15 # 기존에 실행 중인 Java 프로세스 종료 + sleep 10 + nohup java -jar /home/$EC2_USERNAME/umc7thServer.jar > app.log 2>&1 & # 새 버전 애플리케이션 실행 + " + rm -f private_key.pem # 민감한 정보 삭제 + + + + +# name: CD - DEVELOP + +# on: #이 워크플로우가 언제 실행될지 트리거를 정의함. +# pull_request: +# types : [closed] #누군가가 Pull request를 닫았을 때 실행됨. +# workflow_dispatch: #수동 실행도 가능하도록 + +# jobs: #실제 실행할 작업을 정의 +# build: #작업 이름 +# runs-on: ubuntu-latest #OS환경 +# if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' +# #닫힌 Pull Request 중에서, 병합된 것이고, 병합 대상 브랜치가 develop 브랜치일 경우에만 이 작업을 실행 diff --git a/build.gradle b/build.gradle index a1ab37b4..c6419c4f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.5.3' + id 'org.springframework.boot' version '3.5.3' // 또는 사용 중인 최신 버전 id 'io.spring.dependency-management' version '1.1.7' } @@ -24,10 +24,18 @@ repositories { } dependencies { - //implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-aop' + + runtimeOnly 'com.mysql:mysql-connector-j' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + + // ✅ QueryDSL 수동 설정 + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:jakarta' + testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } @@ -35,3 +43,18 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + + +def querydslDir = "src/main/generated" + +sourceSets { + main.java.srcDirs += [ querydslDir ] +} + +tasks.withType(JavaCompile) { + options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir) +} + +tasks.named('clean') { + delete fileTree(dir: querydslDir, include: '**/*.java') +} diff --git a/src/main/java/com/wayble/server/ServerApplication.java b/src/main/java/com/wayble/server/ServerApplication.java index a48c3df7..e52ba69d 100644 --- a/src/main/java/com/wayble/server/ServerApplication.java +++ b/src/main/java/com/wayble/server/ServerApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication +@EnableJpaAuditing public class ServerApplication { public static void main(String[] args) { diff --git a/src/main/java/com/wayble/server/common/MainController.java b/src/main/java/com/wayble/server/common/MainController.java new file mode 100644 index 00000000..3d70e244 --- /dev/null +++ b/src/main/java/com/wayble/server/common/MainController.java @@ -0,0 +1,36 @@ +package com.wayble.server.common; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.common.response.CommonResponse; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/main") +public class MainController { + + /** + * @return + * { + * "data": "main" + * } + */ + + @GetMapping("") + public CommonResponse mainTest() { + return CommonResponse.success("main"); + } + + /** + * @return + * { + * "errorCode": 1001, + * "message": "예외 메시지" + * } + */ + @GetMapping("/exception") + public CommonResponse exceptionTest() { + throw new ApplicationException(MainErrorCase.MAIN_TEST_ERROR); + } +} diff --git a/src/main/java/com/wayble/server/common/MainErrorCase.java b/src/main/java/com/wayble/server/common/MainErrorCase.java new file mode 100644 index 00000000..71f6b3f1 --- /dev/null +++ b/src/main/java/com/wayble/server/common/MainErrorCase.java @@ -0,0 +1,16 @@ +package com.wayble.server.common; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum MainErrorCase implements ErrorCase { + + MAIN_TEST_ERROR(400, 1001, "예외 메시지"); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} diff --git a/src/main/java/com/wayble/server/common/aop/LoggingAspect.java b/src/main/java/com/wayble/server/common/aop/LoggingAspect.java new file mode 100644 index 00000000..d664f57e --- /dev/null +++ b/src/main/java/com/wayble/server/common/aop/LoggingAspect.java @@ -0,0 +1,54 @@ +package com.wayble.server.common.aop; + +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Aspect +@Component +@Slf4j +class LoggingAspect { + private static final Logger logger = LoggerFactory.getLogger(LoggingAspect.class); + + // 예외 발생 시 로깅 + @AfterThrowing(pointcut = "execution(* com.wayble..service..*(..))", + throwing = "ex") + public void logAfterThrowing(JoinPoint joinPoint, Throwable ex) { + String methodName = joinPoint.getSignature().getName(); + String className = joinPoint.getSignature().getDeclaringTypeName(); + String layer = getLayerName(className); + logger.error("[{}] [Exception] {}.{}(): {}", layer, className, methodName, ex.getMessage()); + } + + // 메서드 실행 이전 로깅 + @Before("execution(* com.wayble..service..*(..))") + public void logBefore(JoinPoint joinPoint) { + String methodName = joinPoint.getSignature().getName(); + String className = joinPoint.getSignature().getDeclaringTypeName(); + String layer = getLayerName(className); + logger.info("[{}] [Executing] {}.{}()", layer, className, methodName); + } + + // 메서드 실행 이후 로깅 + @After("execution(* com.wayble..service..*(..))") + public void logAfter(JoinPoint joinPoint) { + String methodName = joinPoint.getSignature().getName(); + String className = joinPoint.getSignature().getDeclaringTypeName(); + String layer = getLayerName(className); + logger.info("[{}] [Completed] {}.{}()", layer, className, methodName); + } + + // 클래스 이름으로부터 계층(layer) 이름 추출 + private String getLayerName(String className) { + if (className.contains("service")) { + return "Service"; + } + return "Unknown"; + } +} diff --git a/src/main/java/com/wayble/server/common/entity/Address.java b/src/main/java/com/wayble/server/common/entity/Address.java new file mode 100644 index 00000000..31218efb --- /dev/null +++ b/src/main/java/com/wayble/server/common/entity/Address.java @@ -0,0 +1,37 @@ +package com.wayble.server.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.Getter; + +@Getter +@Embeddable +public class Address { + /** 시·도 */ + @Column(name = "state", length = 100, nullable = false) + private String state; + + /** 시·군·구 */ + @Column(name = "city", length = 100, nullable = false) + private String city; + + /** 동·읍·면 */ + @Column(name = "district", length = 100) + private String district; + + /** 도로명 주소 */ + @Column(name = "street_address", length = 200) + private String streetAddress; + + /** 상세 주소 */ + @Column(name = "detail_address", length = 200) + private String detailAddress; + + /** 위도 */ + @Column(name = "latitude", columnDefinition = "DECIMAL(10,7)", nullable = false) + private Double latitude; + + /** 경도 */ + @Column(name = "longitude", columnDefinition = "DECIMAL(10,7)", nullable = false) + private Double longitude; +} diff --git a/src/main/java/com/wayble/server/common/entity/BaseEntity.java b/src/main/java/com/wayble/server/common/entity/BaseEntity.java new file mode 100644 index 00000000..be3badb6 --- /dev/null +++ b/src/main/java/com/wayble/server/common/entity/BaseEntity.java @@ -0,0 +1,26 @@ +package com.wayble.server.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; + +import java.time.LocalDateTime; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@MappedSuperclass +@Getter +@EntityListeners(AuditingEntityListener.class) +public class BaseEntity { + + @CreatedDate + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; + + @Column(name = "deleted_at") + private LocalDateTime deletedAt; +} diff --git a/src/main/java/com/wayble/server/common/exception/ApplicationException.java b/src/main/java/com/wayble/server/common/exception/ApplicationException.java new file mode 100644 index 00000000..92fd793b --- /dev/null +++ b/src/main/java/com/wayble/server/common/exception/ApplicationException.java @@ -0,0 +1,14 @@ +package com.wayble.server.common.exception; + +import lombok.Getter; + +@Getter +public class ApplicationException extends RuntimeException { + + private final ErrorCase errorCase; + + public ApplicationException(ErrorCase errorCase) { + super(errorCase.getMessage()); + this.errorCase = errorCase; + } +} diff --git a/src/main/java/com/wayble/server/common/exception/ErrorCase.java b/src/main/java/com/wayble/server/common/exception/ErrorCase.java new file mode 100644 index 00000000..da85b993 --- /dev/null +++ b/src/main/java/com/wayble/server/common/exception/ErrorCase.java @@ -0,0 +1,10 @@ +package com.wayble.server.common.exception; + +public interface ErrorCase { + + Integer getHttpStatusCode(); + + Integer getErrorCode(); + + String getMessage(); +} diff --git a/src/main/java/com/wayble/server/common/exception/GlobalExceptionHandler.java b/src/main/java/com/wayble/server/common/exception/GlobalExceptionHandler.java new file mode 100644 index 00000000..2b512d25 --- /dev/null +++ b/src/main/java/com/wayble/server/common/exception/GlobalExceptionHandler.java @@ -0,0 +1,43 @@ +package com.wayble.server.common.exception; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.wayble.server.common.response.CommonResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.*; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.request.WebRequest; + +@ControllerAdvice +@RequiredArgsConstructor +public class GlobalExceptionHandler { + + private final ObjectMapper objectMapper; + + private final RestTemplate restTemplate = new RestTemplate(); + + @ExceptionHandler(ApplicationException.class) + public ResponseEntity handleApplicationException(ApplicationException e, WebRequest request) { + CommonResponse commonResponse = CommonResponse.error(e.getErrorCase()); + + HttpStatus status = HttpStatus.valueOf(e.getErrorCase().getHttpStatusCode()); + return ResponseEntity + .status(e.getErrorCase().getHttpStatusCode()) + .body(commonResponse); + } + + @ExceptionHandler(value = MethodArgumentNotValidException.class) + public ResponseEntity handleValidException(BindingResult bindingResult, + MethodArgumentNotValidException ex, + WebRequest request) { + String message = bindingResult.getAllErrors().get(0).getDefaultMessage(); + CommonResponse commonResponse = CommonResponse.error(400, message); + + return ResponseEntity + .status(HttpStatus.BAD_REQUEST) + .body(commonResponse); + } +} \ No newline at end of file diff --git a/src/main/java/com/wayble/server/common/response/CommonResponse.java b/src/main/java/com/wayble/server/common/response/CommonResponse.java new file mode 100644 index 00000000..9b444aa7 --- /dev/null +++ b/src/main/java/com/wayble/server/common/response/CommonResponse.java @@ -0,0 +1,42 @@ +package com.wayble.server.common.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.wayble.server.common.exception.ErrorCase; +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CommonResponse { + + private Integer errorCode; + private String message; + private T data; + + public static CommonResponse success(T data) { + return CommonResponse.builder() + .data(data) + .build(); + } + + public static CommonResponse success() { + return CommonResponse.builder() + .message("success") + .build(); + } + + public static CommonResponse error(ErrorCase errorCase) { + return CommonResponse.builder() + .errorCode(errorCase.getErrorCode()) + .message(errorCase.getMessage()) + .build(); + } + + public static CommonResponse error(Integer errorCode, String message) { + return CommonResponse.builder() + .errorCode(errorCode) + .message(message) + .build(); + } +} \ No newline at end of file diff --git a/src/main/java/com/wayble/server/direction/controller/DirectionController.java b/src/main/java/com/wayble/server/direction/controller/DirectionController.java new file mode 100644 index 00000000..2e0f99ab --- /dev/null +++ b/src/main/java/com/wayble/server/direction/controller/DirectionController.java @@ -0,0 +1,29 @@ +package com.wayble.server.direction.controller; + +import com.wayble.server.common.response.CommonResponse; +import com.wayble.server.direction.service.DirectionService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/directions") +public class DirectionController { + + private final DirectionService directionService; + + // 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/hello") + public CommonResponse hello() { + return CommonResponse.success("hello"); + } + + // 예외 사용 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/ex") + public CommonResponse exception() { + directionService.makeException(); + return CommonResponse.success("예외 발생!"); + } +} diff --git a/src/main/java/com/wayble/server/direction/exception/DirectionErrorCase.java b/src/main/java/com/wayble/server/direction/exception/DirectionErrorCase.java new file mode 100644 index 00000000..c5870a47 --- /dev/null +++ b/src/main/java/com/wayble/server/direction/exception/DirectionErrorCase.java @@ -0,0 +1,17 @@ +package com.wayble.server.direction.exception; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum DirectionErrorCase implements ErrorCase { + + PATH_NOT_FOUND(400, 4001, "해당하는 경로를 찾을 수 없습니다."); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} + diff --git a/src/main/java/com/wayble/server/direction/service/DirectionService.java b/src/main/java/com/wayble/server/direction/service/DirectionService.java new file mode 100644 index 00000000..05adf7e9 --- /dev/null +++ b/src/main/java/com/wayble/server/direction/service/DirectionService.java @@ -0,0 +1,15 @@ +package com.wayble.server.direction.service; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.direction.exception.DirectionErrorCase; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class DirectionService { + + public void makeException() { + throw new ApplicationException(DirectionErrorCase.PATH_NOT_FOUND); + } +} diff --git a/src/main/java/com/wayble/server/review/controller/ReviewController.java b/src/main/java/com/wayble/server/review/controller/ReviewController.java new file mode 100644 index 00000000..a1f41b80 --- /dev/null +++ b/src/main/java/com/wayble/server/review/controller/ReviewController.java @@ -0,0 +1,29 @@ +package com.wayble.server.review.controller; + +import com.wayble.server.common.response.CommonResponse; +import com.wayble.server.review.service.ReviewService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/reviews") +public class ReviewController { + + private final ReviewService reviewService; + + // 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/hello") + public CommonResponse hello() { + return CommonResponse.success("hello"); + } + + // 예외 사용 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/ex") + public CommonResponse exception() { + reviewService.makeException(); + return CommonResponse.success("예외 발생!"); + } +} diff --git a/src/main/java/com/wayble/server/review/dto/ReviewRegisterDto.java b/src/main/java/com/wayble/server/review/dto/ReviewRegisterDto.java new file mode 100644 index 00000000..39902ad8 --- /dev/null +++ b/src/main/java/com/wayble/server/review/dto/ReviewRegisterDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.review.dto; + +public record ReviewRegisterDto() { +} diff --git a/src/main/java/com/wayble/server/review/dto/ReviewResponseDto.java b/src/main/java/com/wayble/server/review/dto/ReviewResponseDto.java new file mode 100644 index 00000000..d99466e9 --- /dev/null +++ b/src/main/java/com/wayble/server/review/dto/ReviewResponseDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.review.dto; + +public record ReviewResponseDto() { +} diff --git a/src/main/java/com/wayble/server/review/entity/Review.java b/src/main/java/com/wayble/server/review/entity/Review.java new file mode 100644 index 00000000..d5e6f1f0 --- /dev/null +++ b/src/main/java/com/wayble/server/review/entity/Review.java @@ -0,0 +1,52 @@ +package com.wayble.server.review.entity; + +import com.wayble.server.common.entity.BaseEntity; +import com.wayble.server.user.entity.User; +import com.wayble.server.wayblezone.entity.WaybleZone; +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Builder(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@SQLDelete(sql = "UPDATE review SET deleted_at = now() WHERE id = ?") +@SQLRestriction("deleted_at IS NULL") +@Table(name = "review") +public class Review extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Lob + @Column(columnDefinition = "TEXT") + private String content; + + @Column(nullable = false) + private double rating = 0.0; + + @Column(nullable = false) + private Integer likeCount = 0; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "wayble_zone_id", nullable = false) + private WaybleZone waybleZone; + + @OneToMany(mappedBy = "review", cascade = CascadeType.ALL, orphanRemoval = true) + private List reviewImageList = new ArrayList<>(); + + /** + * TODO: 접근성 정보 관련 구현 필요 + */ +} diff --git a/src/main/java/com/wayble/server/review/entity/ReviewImage.java b/src/main/java/com/wayble/server/review/entity/ReviewImage.java new file mode 100644 index 00000000..a5bfd4ce --- /dev/null +++ b/src/main/java/com/wayble/server/review/entity/ReviewImage.java @@ -0,0 +1,29 @@ +package com.wayble.server.review.entity; + +import com.wayble.server.common.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; + +@Entity +@Getter +@Builder(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "review_image") +@SQLDelete(sql = "UPDATE review_image SET deleted_at = now() WHERE id = ?") +@SQLRestriction("deleted_at IS NULL") +public class ReviewImage extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "review_id", nullable = false) + private Review review; + + @Column(name = "image_url", nullable = false) + private String imageUrl; +} diff --git a/src/main/java/com/wayble/server/review/exception/ReviewErrorCase.java b/src/main/java/com/wayble/server/review/exception/ReviewErrorCase.java new file mode 100644 index 00000000..ac459a7d --- /dev/null +++ b/src/main/java/com/wayble/server/review/exception/ReviewErrorCase.java @@ -0,0 +1,16 @@ +package com.wayble.server.review.exception; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum ReviewErrorCase implements ErrorCase { + + REVIEW_NOT_FOUND(400, 3001, "리뷰를 찾을 수 없습니다."); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} diff --git a/src/main/java/com/wayble/server/review/repository/ReviewImageRepository.java b/src/main/java/com/wayble/server/review/repository/ReviewImageRepository.java new file mode 100644 index 00000000..5626ffc9 --- /dev/null +++ b/src/main/java/com/wayble/server/review/repository/ReviewImageRepository.java @@ -0,0 +1,7 @@ +package com.wayble.server.review.repository; + +import com.wayble.server.review.entity.ReviewImage; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReviewImageRepository extends JpaRepository { +} diff --git a/src/main/java/com/wayble/server/review/repository/ReviewRepository.java b/src/main/java/com/wayble/server/review/repository/ReviewRepository.java new file mode 100644 index 00000000..bffe95a4 --- /dev/null +++ b/src/main/java/com/wayble/server/review/repository/ReviewRepository.java @@ -0,0 +1,7 @@ +package com.wayble.server.review.repository; + +import com.wayble.server.review.entity.Review; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReviewRepository extends JpaRepository { +} diff --git a/src/main/java/com/wayble/server/review/service/ReviewService.java b/src/main/java/com/wayble/server/review/service/ReviewService.java new file mode 100644 index 00000000..3e3191d9 --- /dev/null +++ b/src/main/java/com/wayble/server/review/service/ReviewService.java @@ -0,0 +1,17 @@ +package com.wayble.server.review.service; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.review.exception.ReviewErrorCase; +import com.wayble.server.review.repository.ReviewRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ReviewService { + private final ReviewRepository reviewRepository; + + public void makeException() { + throw new ApplicationException(ReviewErrorCase.REVIEW_NOT_FOUND); + } +} diff --git a/src/main/java/com/wayble/server/search/controller/SearchController.java b/src/main/java/com/wayble/server/search/controller/SearchController.java new file mode 100644 index 00000000..4bc44e0f --- /dev/null +++ b/src/main/java/com/wayble/server/search/controller/SearchController.java @@ -0,0 +1,29 @@ +package com.wayble.server.search.controller; + +import com.wayble.server.common.response.CommonResponse; +import com.wayble.server.search.service.SearchService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/search") +public class SearchController { + + private final SearchService searchService; + + // 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/hello") + public CommonResponse hello() { + return CommonResponse.success("hello"); + } + + // 예외 사용 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/ex") + public CommonResponse exception() { + searchService.makeException(); + return CommonResponse.success("예외 발생!"); + } +} diff --git a/src/main/java/com/wayble/server/search/exception/SearchErrorCase.java b/src/main/java/com/wayble/server/search/exception/SearchErrorCase.java new file mode 100644 index 00000000..73d50906 --- /dev/null +++ b/src/main/java/com/wayble/server/search/exception/SearchErrorCase.java @@ -0,0 +1,16 @@ +package com.wayble.server.search.exception; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum SearchErrorCase implements ErrorCase { + + SEARCH_EXCEPTION(400, 5001, "검색 과정에서 오류가 발생했습니다."); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} diff --git a/src/main/java/com/wayble/server/search/service/SearchService.java b/src/main/java/com/wayble/server/search/service/SearchService.java new file mode 100644 index 00000000..71b0af31 --- /dev/null +++ b/src/main/java/com/wayble/server/search/service/SearchService.java @@ -0,0 +1,15 @@ +package com.wayble.server.search.service; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.search.exception.SearchErrorCase; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class SearchService { + + public void makeException() { + throw new ApplicationException(SearchErrorCase.SEARCH_EXCEPTION); + } +} diff --git a/src/main/java/com/wayble/server/user/controller/UserController.java b/src/main/java/com/wayble/server/user/controller/UserController.java new file mode 100644 index 00000000..0c875733 --- /dev/null +++ b/src/main/java/com/wayble/server/user/controller/UserController.java @@ -0,0 +1,29 @@ +package com.wayble.server.user.controller; + +import com.wayble.server.common.response.CommonResponse; +import com.wayble.server.user.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/users") +public class UserController { + + private final UserService userService; + + // 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/hello") + public CommonResponse hello() { + return CommonResponse.success("hello"); + } + + // 예외 사용 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/ex") + public CommonResponse exception() { + userService.makeException(); + return CommonResponse.success("예외 발생!"); + } +} diff --git a/src/main/java/com/wayble/server/user/dto/UserRegisterDto.java b/src/main/java/com/wayble/server/user/dto/UserRegisterDto.java new file mode 100644 index 00000000..6fa5474c --- /dev/null +++ b/src/main/java/com/wayble/server/user/dto/UserRegisterDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.user.dto; + +public record UserRegisterDto() { +} diff --git a/src/main/java/com/wayble/server/user/dto/UserResponseDto.java b/src/main/java/com/wayble/server/user/dto/UserResponseDto.java new file mode 100644 index 00000000..7e5a7123 --- /dev/null +++ b/src/main/java/com/wayble/server/user/dto/UserResponseDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.user.dto; + +public record UserResponseDto() { +} diff --git a/src/main/java/com/wayble/server/user/entity/Gender.java b/src/main/java/com/wayble/server/user/entity/Gender.java new file mode 100644 index 00000000..12b0484a --- /dev/null +++ b/src/main/java/com/wayble/server/user/entity/Gender.java @@ -0,0 +1,5 @@ +package com.wayble.server.user.entity; + +public enum Gender { + MALE, FEMALE, UNKNOWN +} diff --git a/src/main/java/com/wayble/server/user/entity/LoginType.java b/src/main/java/com/wayble/server/user/entity/LoginType.java new file mode 100644 index 00000000..1fa43bcf --- /dev/null +++ b/src/main/java/com/wayble/server/user/entity/LoginType.java @@ -0,0 +1,5 @@ +package com.wayble.server.user.entity; + +public enum LoginType { + BASIC, KAKAO, APPLE +} diff --git a/src/main/java/com/wayble/server/user/entity/User.java b/src/main/java/com/wayble/server/user/entity/User.java new file mode 100644 index 00000000..009f8280 --- /dev/null +++ b/src/main/java/com/wayble/server/user/entity/User.java @@ -0,0 +1,62 @@ +package com.wayble.server.user.entity; + +import com.wayble.server.common.entity.BaseEntity; +import com.wayble.server.review.entity.Review; +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +@Getter +@Entity +@Builder(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@SQLDelete(sql = "UPDATE user SET deleted_at = now() WHERE id = ?") +@SQLRestriction("deleted_at IS NULL") +@Table(name = "user") +public class User extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "nickname", length = 8, nullable = false) + private String nickname; + + private String username; + + @Column(nullable = false) + private String email; + + // TODO: 비밀번호 암호화 필요 + private String password; + + @Column(name = "birth_date", columnDefinition = "DATE") + private LocalDate birthDate; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private Gender gender; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private LoginType loginType; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private UserType userType; + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) + private List reviewList = new ArrayList<>(); + + // TODO 장애 종류 필드 등록 필요 + + // TODO 프로필 이미지 관련 작업 필요 + + // TODO 내가 저장한 장소 관련 작업 필요 +} diff --git a/src/main/java/com/wayble/server/user/entity/UserType.java b/src/main/java/com/wayble/server/user/entity/UserType.java new file mode 100644 index 00000000..3ef1ecf8 --- /dev/null +++ b/src/main/java/com/wayble/server/user/entity/UserType.java @@ -0,0 +1,12 @@ +package com.wayble.server.user.entity; + +public enum UserType { + /** 장애인 사용자 */ + DISABLED, + + /** 장애인 동행자 */ + COMPANION, + + /** 일반 사용자 */ + GENERAL +} diff --git a/src/main/java/com/wayble/server/user/exception/UserErrorCase.java b/src/main/java/com/wayble/server/user/exception/UserErrorCase.java new file mode 100644 index 00000000..24b7bd15 --- /dev/null +++ b/src/main/java/com/wayble/server/user/exception/UserErrorCase.java @@ -0,0 +1,16 @@ +package com.wayble.server.user.exception; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum UserErrorCase implements ErrorCase { + + USER_NOT_FOUND(400, 1001, "사용자를 찾을 수 없습니다."); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} diff --git a/src/main/java/com/wayble/server/user/repository/UserRepository.java b/src/main/java/com/wayble/server/user/repository/UserRepository.java new file mode 100644 index 00000000..1fcb4172 --- /dev/null +++ b/src/main/java/com/wayble/server/user/repository/UserRepository.java @@ -0,0 +1,7 @@ +package com.wayble.server.user.repository; + +import com.wayble.server.user.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UserRepository extends JpaRepository { +} diff --git a/src/main/java/com/wayble/server/user/service/UserService.java b/src/main/java/com/wayble/server/user/service/UserService.java new file mode 100644 index 00000000..f99c05f2 --- /dev/null +++ b/src/main/java/com/wayble/server/user/service/UserService.java @@ -0,0 +1,18 @@ +package com.wayble.server.user.service; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.user.exception.UserErrorCase; +import com.wayble.server.user.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class UserService { + + private final UserRepository userRepository; + + public void makeException() { + throw new ApplicationException(UserErrorCase.USER_NOT_FOUND); + } +} diff --git a/src/main/java/com/wayble/server/wayblezone/controller/WaybleZoneController.java b/src/main/java/com/wayble/server/wayblezone/controller/WaybleZoneController.java new file mode 100644 index 00000000..b0357796 --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/controller/WaybleZoneController.java @@ -0,0 +1,29 @@ +package com.wayble.server.wayblezone.controller; + +import com.wayble.server.common.response.CommonResponse; +import com.wayble.server.wayblezone.service.WaybleZoneService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/wayble-zones") +public class WaybleZoneController { + + private final WaybleZoneService waybleZoneService; + + // 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/hello") + public CommonResponse hello() { + return CommonResponse.success("hello"); + } + + // 예외 사용 참고용 컨트롤러(지우셔도 돼요) + @GetMapping("/ex") + public CommonResponse exception() { + waybleZoneService.makeException(); + return CommonResponse.success("예외 발생!"); + } +} diff --git a/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneRegisterDto.java b/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneRegisterDto.java new file mode 100644 index 00000000..971ec816 --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneRegisterDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.wayblezone.dto; + +public record WaybleZoneRegisterDto() { +} diff --git a/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneResponseDto.java b/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneResponseDto.java new file mode 100644 index 00000000..fb98693e --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/dto/WaybleZoneResponseDto.java @@ -0,0 +1,4 @@ +package com.wayble.server.wayblezone.dto; + +public record WaybleZoneResponseDto() { +} diff --git a/src/main/java/com/wayble/server/wayblezone/entity/WaybleZone.java b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZone.java new file mode 100644 index 00000000..04478f1a --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZone.java @@ -0,0 +1,60 @@ +package com.wayble.server.wayblezone.entity; + +import com.wayble.server.common.entity.Address; +import com.wayble.server.common.entity.BaseEntity; +import com.wayble.server.review.entity.Review; +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Builder(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@SQLDelete(sql = "UPDATE wayble_zone SET deleted_at = now() WHERE id = ?") +@SQLRestriction("deleted_at IS NULL") +@Table(name = "wayble_zone") +public class WaybleZone extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String zoneName; + + private String contactNumber; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private WaybleZoneType zoneType; + + @Embedded + private Address address; + + @OneToMany(mappedBy = "waybleZone", cascade = CascadeType.ALL, orphanRemoval = true) + private List waybleZoneImageList = new ArrayList<>(); + + @OneToMany(mappedBy = "waybleZone", cascade = CascadeType.ALL, orphanRemoval = true) + private List reviewList = new ArrayList<>(); + + /** + * TODO: 영업 시간 구현 필요 + */ + + /** + * TODO: 장애 시설 정보 구현 필요 + */ + + /** + * TODO: Review 관련 엔티티 구현 필요 + */ + + /** + * TODO: 내가 저장한 장소 관련 엔티티 구현 필요 + */ +} diff --git a/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneImage.java b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneImage.java new file mode 100644 index 00000000..96260f0e --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneImage.java @@ -0,0 +1,29 @@ +package com.wayble.server.wayblezone.entity; + +import com.wayble.server.common.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; + +@Entity +@Getter +@Builder(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "wayble_zone_image") +@SQLDelete(sql = "UPDATE wayble_zone_image SET deleted_at = now() WHERE id = ?") +@SQLRestriction("deleted_at IS NULL") +public class WaybleZoneImage extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "wayble_zone_id", nullable = false) + private WaybleZone waybleZone; + + @Column(name = "image_url", nullable = false) + private String imageUrl; +} diff --git a/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneType.java b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneType.java new file mode 100644 index 00000000..4c84cafb --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/entity/WaybleZoneType.java @@ -0,0 +1,12 @@ +package com.wayble.server.wayblezone.entity; + +public enum WaybleZoneType { + // 음식점 + RESTAURANT, + + // 카페 + CAFE, + + // 편의점 + CONVENIENCE +} diff --git a/src/main/java/com/wayble/server/wayblezone/exception/WaybleZoneErrorCase.java b/src/main/java/com/wayble/server/wayblezone/exception/WaybleZoneErrorCase.java new file mode 100644 index 00000000..df25ddf9 --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/exception/WaybleZoneErrorCase.java @@ -0,0 +1,16 @@ +package com.wayble.server.wayblezone.exception; + +import com.wayble.server.common.exception.ErrorCase; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum WaybleZoneErrorCase implements ErrorCase { + + WAYBLE_ZONE_NOT_FOUND(400, 2001, "웨이블존을 찾을 수 없습니다."); + + private final Integer httpStatusCode; + private final Integer errorCode; + private final String message; +} diff --git a/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneImageRepository.java b/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneImageRepository.java new file mode 100644 index 00000000..95ad6649 --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneImageRepository.java @@ -0,0 +1,7 @@ +package com.wayble.server.wayblezone.repository; + +import com.wayble.server.wayblezone.entity.WaybleZoneImage; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface WaybleZoneImageRepository extends JpaRepository { +} diff --git a/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneRepository.java b/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneRepository.java new file mode 100644 index 00000000..2a74f57f --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/repository/WaybleZoneRepository.java @@ -0,0 +1,7 @@ +package com.wayble.server.wayblezone.repository; + +import com.wayble.server.wayblezone.entity.WaybleZone; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface WaybleZoneRepository extends JpaRepository { +} diff --git a/src/main/java/com/wayble/server/wayblezone/service/WaybleZoneService.java b/src/main/java/com/wayble/server/wayblezone/service/WaybleZoneService.java new file mode 100644 index 00000000..c3c67aef --- /dev/null +++ b/src/main/java/com/wayble/server/wayblezone/service/WaybleZoneService.java @@ -0,0 +1,21 @@ +package com.wayble.server.wayblezone.service; + +import com.wayble.server.common.exception.ApplicationException; +import com.wayble.server.wayblezone.exception.WaybleZoneErrorCase; +import com.wayble.server.wayblezone.repository.WaybleZoneImageRepository; +import com.wayble.server.wayblezone.repository.WaybleZoneRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class WaybleZoneService { + + private final WaybleZoneRepository waybleZoneRepository; + + private final WaybleZoneImageRepository imageRepository; + + public void makeException() { + throw new ApplicationException(WaybleZoneErrorCase.WAYBLE_ZONE_NOT_FOUND); + } +} diff --git a/wayble-spring/.gitattributes b/wayble-spring/.gitattributes new file mode 100644 index 00000000..8af972cd --- /dev/null +++ b/wayble-spring/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/wayble-spring/.github/ISSUE_TEMPLATE/bug-report-template.md b/wayble-spring/.github/ISSUE_TEMPLATE/bug-report-template.md new file mode 100644 index 00000000..9ee70937 --- /dev/null +++ b/wayble-spring/.github/ISSUE_TEMPLATE/bug-report-template.md @@ -0,0 +1,22 @@ +--- +name: Bug Report Template +about: 버그 이슈 템플릿입니다. +title: "[bug] 제목을 입력하세요." +labels: bug +assignees: '' + +--- + +## ⚙️ 어떤 버그인가요? + +> 어떤 버그인지 간결하게 설명해주세요 + +### 스크린샷(선택) + +## 🔎 어떤 상황에서 발생한 버그인가요? + +> (가능하면) Given-When-Then 형식으로 서술해주세요 + +## ✅ 예상 결과 + +> 예상했던 정상적인 결과가 어떤 것이었는지 설명해주세요 diff --git a/wayble-spring/.github/ISSUE_TEMPLATE/common-issue-template.md b/wayble-spring/.github/ISSUE_TEMPLATE/common-issue-template.md new file mode 100644 index 00000000..dfbaef96 --- /dev/null +++ b/wayble-spring/.github/ISSUE_TEMPLATE/common-issue-template.md @@ -0,0 +1,21 @@ +--- +name: Common Issue Template +about: 기본 이슈 템플릿입니다. (feature, refactor, chore 등) +title: "[타입] 제목을 작성하세요" +labels: '' +assignees: '' + +--- + +## 📝 Description + +> 작업에 대한 간략한 설명을 작성하세요. + +## ✅ TODO + +- [ ] todo1 +- [ ] todo2 + +## 💡 ETC (선택) + +> 기타 참고 사항, 고려할 점 또는 논의가 필요한 사항을 작성하세요. diff --git a/wayble-spring/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/wayble-spring/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..0bc873a4 --- /dev/null +++ b/wayble-spring/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ +## ✔️ 연관 이슈 + +- close #이슈번호 + +## 📝 작업 내용 + +> 이번 PR에서 작업한 내용을 간략히 설명해주세요 + +### 스크린샷 (선택) diff --git a/wayble-spring/.gitignore b/wayble-spring/.gitignore new file mode 100644 index 00000000..b335a8f5 --- /dev/null +++ b/wayble-spring/.gitignore @@ -0,0 +1,40 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### 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/ + +### application.yml ### +application.yml diff --git a/wayble-spring/build.gradle b/wayble-spring/build.gradle new file mode 100644 index 00000000..a1ab37b4 --- /dev/null +++ b/wayble-spring/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.5.3' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'com.wayble' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + //implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/wayble-spring/gradle/wrapper/gradle-wrapper.jar b/wayble-spring/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..1b33c55b Binary files /dev/null and b/wayble-spring/gradle/wrapper/gradle-wrapper.jar differ diff --git a/wayble-spring/gradle/wrapper/gradle-wrapper.properties b/wayble-spring/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ff23a68d --- /dev/null +++ b/wayble-spring/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/wayble-spring/gradlew b/wayble-spring/gradlew new file mode 100644 index 00000000..23d15a93 --- /dev/null +++ b/wayble-spring/gradlew @@ -0,0 +1,251 @@ +#!/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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || 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="\\\"\\\"" + + +# 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, 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" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# 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/wayble-spring/gradlew.bat b/wayble-spring/gradlew.bat new file mode 100644 index 00000000..db3a6ac2 --- /dev/null +++ b/wayble-spring/gradlew.bat @@ -0,0 +1,94 @@ +@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 +@rem SPDX-License-Identifier: Apache-2.0 +@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= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +: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/wayble-spring/settings.gradle b/wayble-spring/settings.gradle new file mode 100644 index 00000000..096502d2 --- /dev/null +++ b/wayble-spring/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'server' diff --git a/wayble-spring/src/main/java/com/wayble/server/ServerApplication.java b/wayble-spring/src/main/java/com/wayble/server/ServerApplication.java new file mode 100644 index 00000000..a48c3df7 --- /dev/null +++ b/wayble-spring/src/main/java/com/wayble/server/ServerApplication.java @@ -0,0 +1,13 @@ +package com.wayble.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ServerApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerApplication.class, args); + } + +} diff --git a/wayble-spring/src/test/java/com/wayble/server/ServerApplicationTests.java b/wayble-spring/src/test/java/com/wayble/server/ServerApplicationTests.java new file mode 100644 index 00000000..80ee7875 --- /dev/null +++ b/wayble-spring/src/test/java/com/wayble/server/ServerApplicationTests.java @@ -0,0 +1,13 @@ +package com.wayble.server; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ServerApplicationTests { + + @Test + void contextLoads() { + } + +}