[whatssue] 스프링 인터셉터를 사용해 사용자 권한 체크하기
Dev/Spring2024. 4. 1. 23:10[whatssue] 스프링 인터셉터를 사용해 사용자 권한 체크하기

문제 상황모임 관리 프로젝트의 모임 관련 api를 개발하다가 다음과 같은 문제를 직면했다.1. 매번 club이 존재하는지 체크해주어야한다.2. 매번 로그인 유저가 이 club의 멤버인지 체크해주어야 한다.3. 매번 로그인 유저가 이 club의 관리자인지 체크해주어야 한다. (관리자 api인 경우)4. 매번 로그인 유저가 이 club에 가입 이후 처음 방문했는지 체크해주어야 한다. 클럽에 관련된 api마다 1, 2, 3, 4의 중복 코드가 발생한다. 해결방안중복되는 공통 관심사를 한번에 처리하고자 하였다.조금 찾아보니 필터, 스프링 인터셉터, AOP 로 공통관심사를 처리할 수 있었고,나는 스프링 인터셉터(Spring Interceptor)를 사용하여 이번 문제를 해결하고자 하였다.  스프링 인터셉터란 ?스..

백준_13251 조약돌 꺼내기
Algorithm/Algorithm 문제2024. 4. 1. 21:54백준_13251 조약돌 꺼내기

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_13251_조약돌꺼내기 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int m = Integer.parseInt(br.readLine()); int[] rock = new int[m]; int i; int total = 0; StringTokenizer st..

백준_1010 다리 놓기
Algorithm/Algorithm 문제2024. 4. 1. 21:53백준_1010 다리 놓기

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_1010_다리놓기 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); int[][] d= new int[31][31]; int i; for (i=1; i

백준_2775 부녀회장이 될테야 (조합)
Algorithm/Algorithm 문제2024. 3. 28. 14:33백준_2775 부녀회장이 될테야 (조합)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_2775_부녀회장이될테야 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); int [][] d = new int[15][15]; int i; for (i=0; i

백준_11051 이항 계수 2 (조합)
Algorithm/Algorithm 문제2024. 3. 26. 23:10백준_11051 이항 계수 2 (조합)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_11051_이항계수2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int n = Integer.parseInt(st.nextToken()); int..

백준_11050 이항 계수 1 (조합)
Algorithm/Algorithm 문제2024. 3. 24. 17:04백준_11050 이항 계수 1 (조합)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_11050_이항계수1 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int n = Integer.parseInt(st.nextToken()); int..

백준_11438 LCA2 (빠른 최소 공통 조상)
Algorithm/Algorithm 문제2024. 3. 19. 12:02백준_11438 LCA2 (빠른 최소 공통 조상)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class BJ_11438_LCA2 { static int kMax; static ArrayList[] tree; static int[][] parent; static int[] depth; static boolean[] visited; static StringBuilder result = new StringBuilder();..

백준_11437 LCA (최소공통조상 일반)
Algorithm/Algorithm 문제2024. 3. 18. 12:39백준_11437 LCA (최소공통조상 일반)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class BJ_11437_LCA { static ArrayList[] tree; static boolean[] visited; static int[] parent; static int[] depth; static StringBuilder result = new StringBuilder(); public static void ..

image