Skip to content

Commit

Permalink
Merge pull request #15 from Best-offer-finder/BOF-52-refactor-rest-en…
Browse files Browse the repository at this point in the history
…dpoint

Bof 52 refactor rest endpoint
  • Loading branch information
Vertonowsky authored May 22, 2024
2 parents dc27ef3 + e813eab commit fe59494
Show file tree
Hide file tree
Showing 26 changed files with 452 additions and 393 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'mysql:mysql-connector-java:8.0.28'
implementation 'com.google.protobuf:protobuf-java:3.25.2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/example/backend/common/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
public enum ErrorCode {

APPLICATION_SETTING_NOT_FOUND("APPLICATION_SETTING_NOT_FOUND"),
FILTER_DATA_REQUIRED("FILTER_DATA_REQUIRED"),
FILTER_NOT_FOUND("FILTER_NOT_FOUND"),
FILTER_ID_REQUIRED("FILTER_ID_REQUIRED"),
FILTER_NAME_REQUIRED("FILTER_NAME_REQUIRED"),
INPUT_DATA_INVALID("INPUT_DATA_INVALID"),
JSON_FORMAT_INVALID("JSON_FORMAT_INVALID"),
SCHEME_DATA_REQUIRED("SCHEME_DATA_REQUIRED"),
SCHEME_NOT_FOUND("SCHEME_NOT_FOUND"),
SCHEME_NAME_REQUIRED("SCHEME_NAME_REQUIRED"),
USER_NOT_FOUND("USER_NOT_FOUND");

private String message;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/example/backend/common/UserEmail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.backend.common;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserEmail {
}
26 changes: 26 additions & 0 deletions src/main/java/com/example/backend/common/UserEmailResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.backend.common;

import org.springframework.core.MethodParameter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.context.request.NativeWebRequest;

@Component
public class UserEmailResolver implements HandlerMethodArgumentResolver {

@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterAnnotation(UserEmail.class) != null;
}

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
Jwt jwt = (Jwt) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return jwt.getClaim("email").toString();
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

123 changes: 0 additions & 123 deletions src/main/java/com/example/backend/filter/service/FilterService.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.backend.filter;
package com.example.backend.scheme;

public enum CarStatus {

Expand Down
Loading

0 comments on commit fe59494

Please sign in to comment.