Skip to content

Commit

Permalink
#1 [refactor] Web adapter Annotation Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SeorinY committed Oct 16, 2023
1 parent dadf8b8 commit 2d61d1d
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.qdang.adapter.auth.response.TokenResponse;
import com.qdang.application.user.domain.User;
import com.qdang.global.argument.AuthUser;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.pathmatch.V1;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -17,10 +18,9 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

@V1
@RequestMapping("/auth")
@WebAdapter(path = "/auth")
@SecurityRequirement(name = "JWT Auth")
@Tag(name = "Auth", description = "Auth API Document")
public interface AuthAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.qdang.application.user.port.in.LogoutUseCase;
import com.qdang.application.user.port.in.RefreshTokenUseCase;
import com.qdang.global.http.HeaderTokenExtractor;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.response.HttpResponse;
import com.qdang.global.response.SuccessType;
import com.qdang.adapter.auth.request.LoginRequest;
Expand All @@ -18,7 +17,6 @@
import org.springframework.http.ResponseEntity;

@Slf4j
@WebAdapter
@RequiredArgsConstructor
public class AuthController implements AuthAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.qdang.application.match.port.in.RecordMatchProcessUseCase;
import com.qdang.application.match.port.in.StartMatchUseCase;
import com.qdang.application.user.domain.User;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.response.HttpResponse;
import com.qdang.global.response.SuccessType;
import com.qdang.adapter.match.request.StartMatchRequest;
Expand All @@ -18,7 +17,6 @@
import org.springframework.http.ResponseEntity;

@Slf4j
@WebAdapter
@RequiredArgsConstructor
public class MatchController implements MatchWebAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.qdang.adapter.match.response.StartMatchResponse;
import com.qdang.application.user.domain.User;
import com.qdang.global.argument.AuthUser;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.pathmatch.V1;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -18,10 +19,9 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@V1
@RequestMapping("/matches")
@WebAdapter(path = "/matches")
@SecurityRequirement(name = "JWT Auth")
@Tag(name = "Match", description = "Match API Document")
public interface MatchWebAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import com.qdang.application.noticeboard.port.in.GetNoticeBoardPinnedListUseCase;
import com.qdang.application.noticeboard.port.in.PinNoticeBoardUseCase;
import com.qdang.application.user.domain.User;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.response.HttpResponse;
import com.qdang.global.response.SuccessType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;

@Slf4j
@WebAdapter
@RequiredArgsConstructor
public class NoticeBoardController implements NoticeBoardWebAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.qdang.adapter.noticeboard.response.GetNoticeBoardListResponse;
import com.qdang.application.user.domain.User;
import com.qdang.global.argument.AuthUser;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.pathmatch.V1;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -14,10 +15,9 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@V1
@RequestMapping("/notice-boards")
@WebAdapter(path = "/notice-boards")
@SecurityRequirement(name = "JWT Auth")
@Tag(name = "Notice Board", description = "Notice Board API Document")
public interface NoticeBoardWebAdapter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.qdang.adapter.post;

import com.qdang.global.http.WebAdapter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@WebAdapter
@RequiredArgsConstructor
public class PostController implements PostWebAdapter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.qdang.adapter.post;

import com.qdang.global.http.WebAdapter;
import com.qdang.global.pathmatch.V1;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;

@V1
@RequestMapping("/posts")
@WebAdapter(path = "/posts")
@SecurityRequirement(name = "JWT Auth")
@Tag(name = "Post", description = "Post API Document")
public interface PostWebAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.qdang.application.user.domain.User;
import com.qdang.application.user.port.in.GetUserProfileUseCase;
import com.qdang.application.user.port.in.SearchUserByUsernameUseCase;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.response.HttpResponse;
import com.qdang.global.response.SuccessType;
import com.qdang.adapter.user.request.UpdateUserProfileRequest;
Expand All @@ -19,7 +18,6 @@
import org.springframework.http.ResponseEntity;

@Slf4j
@WebAdapter
@RequiredArgsConstructor
public class UserController implements UserWebAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.qdang.adapter.user.response.UserValidationResponse;
import com.qdang.application.user.domain.User;
import com.qdang.global.argument.AuthUser;
import com.qdang.global.http.WebAdapter;
import com.qdang.global.pathmatch.V1;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -17,11 +18,10 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@V1
@RequestMapping("/users")
@WebAdapter(path = "/users")
@SecurityRequirement(name = "JWT Auth")
@Tag(name = "User", description = "User API Document")
public interface UserWebAdapter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package com.qdang.global.http;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
@ResponseBody
@RequestMapping
public @interface WebAdapter {

@AliasFor(annotation = Component.class)
String value() default "";

@AliasFor(annotation = RequestMapping.class, attribute = "path")
String path() default "";
}

0 comments on commit 2d61d1d

Please sign in to comment.