Skip to content

Commit

Permalink
sprint 1 (#13)
Browse files Browse the repository at this point in the history
* test: add helper class (persister)

* feat: add api of seeing context of workout

* feat: add api of seeing workout records of workoutHistory

* refactor: rename package and delete legacy exception class

* feat: add api of registering favorite mission in workspace

* feat: add api of seeing favorite missions

* refactor: rename class and enum name

* refactor: merge method into persister

* feat: add api of getting presigned url

* feat: modify api of working mission

* refactor: modify response

* fix: fix calculate best workout score method

* refactor: s3 upload
  • Loading branch information
aiaiaiai1 authored Nov 3, 2024
1 parent 3fcbc2e commit 3449d48
Show file tree
Hide file tree
Showing 135 changed files with 1,496 additions and 583 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies {
implementation 'org.mindrot:jbcrypt:0.4'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'

implementation "org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE"

testImplementation "org.testcontainers:testcontainers:1.20.1"
testImplementation "org.testcontainers:mysql:1.20.1"
testImplementation "org.testcontainers:junit-jupiter:1.20.1"
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/gymmi/controller/S3Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package gymmi.controller;

import gymmi.response.PresignedUrlResponse;
import gymmi.service.S3Service;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class S3Controller {

private final S3Service s3Service;

@GetMapping("/images/workout-proof/presignedUrl")
public ResponseEntity<PresignedUrlResponse> s3(
) {
PresignedUrlResponse response = s3Service.getPresingedUrlWithPut();
return ResponseEntity.ok().body(response);
}

@GetMapping("/images/workout-proof/presignedUrl/get")
public ResponseEntity<String> s3(
@RequestParam("imageUrl") String filenmae
) {
String presignedUrl = s3Service.getPresignedUrl(filenmae);
return ResponseEntity.ok().body(presignedUrl);
}


}
4 changes: 3 additions & 1 deletion src/main/java/gymmi/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static gymmi.utils.Regexpressions.REGEX_영어_한글_초성_숫자_만;
import static gymmi.utils.Regexpressions.SPECIAL_CHARACTER;

import gymmi.exception.InvalidPatternException;
import gymmi.exceptionhandler.legacy.InvalidPatternException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
Expand All @@ -19,6 +19,7 @@
import lombok.AccessLevel;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.mindrot.jbcrypt.BCrypt;
Expand All @@ -28,6 +29,7 @@
@Table(name = "uuser")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = {"id"}, callSuper = false)
@Getter
public class User extends TimeEntity {

private static final Pattern REGEX_LOGIN_ID = REGEX_영어_숫자_만;
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/NotMatchedException.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/gymmi/exception/class1/AlreadyExistException.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/gymmi/exception/class1/FileException.java

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/java/gymmi/exception/class1/GymmiException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/InvalidFileException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/InvalidNumberException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/InvalidPatternException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/InvalidRangeException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/InvalidStateException.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/NotFoundException.java

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/gymmi/exception/class1/UnsupportedException.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gymmi.exception;
package gymmi.exceptionhandler;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gymmi.exception;
package gymmi.exceptionhandler;

import gymmi.exception.class1.GymmiException;
import gymmi.exceptionhandler.exception.GymmiException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gymmi.exceptionhandler.exception;

import gymmi.exceptionhandler.message.ErrorCode;
import gymmi.exceptionhandler.message.ExceptionType;

public class AlreadyExistException extends GymmiException {

public static final ExceptionType EXCEPTION_CODE = ExceptionType.ALREADY_EXISTS;

public AlreadyExistException(ErrorCode errorCode) {
super(errorCode, EXCEPTION_CODE);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package gymmi.exception.class1;
package gymmi.exceptionhandler.exception;

import gymmi.exception.message.ErrorCode;
import gymmi.exception.message.ExceptionCode;
import gymmi.exceptionhandler.message.ErrorCode;
import gymmi.exceptionhandler.message.ExceptionType;

public class AuthenticationFailException extends NotMatchedException {

public static final ExceptionCode EXCEPTION_CODE = ExceptionCode.AUTHENTICATION_FAIL;
public static final ExceptionType EXCEPTION_CODE = ExceptionType.AUTHENTICATION_FAIL;

public AuthenticationFailException(ErrorCode errorCode) {
super(errorCode, EXCEPTION_CODE);
}

protected AuthenticationFailException(ErrorCode errorCode, ExceptionCode exceptionCode) {
super(errorCode, exceptionCode);
protected AuthenticationFailException(ErrorCode errorCode, ExceptionType exceptionType) {
super(errorCode, exceptionType);
}

public AuthenticationFailException(ErrorCode errorCode, Throwable throwable) {
super(errorCode, EXCEPTION_CODE, throwable);
}

protected AuthenticationFailException(ErrorCode errorCode, ExceptionCode exceptionCode, Throwable throwable) {
super(errorCode, exceptionCode, throwable);
protected AuthenticationFailException(ErrorCode errorCode, ExceptionType exceptionType, Throwable throwable) {
super(errorCode, exceptionType, throwable);
}
}
26 changes: 26 additions & 0 deletions src/main/java/gymmi/exceptionhandler/exception/FileException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gymmi.exceptionhandler.exception;

import gymmi.exceptionhandler.message.ErrorCode;
import gymmi.exceptionhandler.message.ExceptionType;

public class FileException extends GymmiException {

public static final ExceptionType EXCEPTION_CODE = ExceptionType.FILE_RELATED;

public FileException(ErrorCode errorCode) {
super(errorCode, EXCEPTION_CODE);
}

public FileException(ErrorCode errorCode, Throwable throwable) {
super(errorCode, EXCEPTION_CODE, throwable);
}

protected FileException(ErrorCode errorCode, ExceptionType exceptionType) {
super(errorCode, exceptionType);
}

protected FileException(ErrorCode errorCode, ExceptionType exceptionType, Throwable throwable) {
super(errorCode, exceptionType, throwable);
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package gymmi.exception.class1;
package gymmi.exceptionhandler.exception;

import gymmi.exception.message.ErrorCode;
import gymmi.exception.message.ExceptionCode;
import gymmi.exceptionhandler.message.ErrorCode;
import gymmi.exceptionhandler.message.ExceptionType;

public class FileIOFailException extends FileException {
public static final ExceptionCode EXCEPTION_CODE = ExceptionCode.FILE_IO_FAIL;
public static final ExceptionType EXCEPTION_CODE = ExceptionType.FILE_IO_FAIL;

public FileIOFailException(ErrorCode errorCode) {
super(errorCode, EXCEPTION_CODE);
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/gymmi/exceptionhandler/exception/GymmiException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package gymmi.exceptionhandler.exception;

import gymmi.exceptionhandler.message.ErrorCode;
import gymmi.exceptionhandler.message.ExceptionType;

public class GymmiException extends RuntimeException {

private final ErrorCode errorCode;
private final ExceptionType exceptionType;

protected GymmiException(ErrorCode errorCode, ExceptionType exceptionType) {
super(errorCode.getMessage());
this.errorCode = errorCode;
this.exceptionType = exceptionType;
}

protected GymmiException(ErrorCode errorCode, ExceptionType exceptionType, Throwable throwable) {
super(errorCode.getMessage(), throwable);
this.errorCode = errorCode;
this.exceptionType = exceptionType;
}

public int getStatusCode() {
return errorCode.getStatusCode();
}

public ExceptionType getExceptionCode() {
return exceptionType;
}
}
Loading

0 comments on commit 3449d48

Please sign in to comment.