diff --git a/.gitignore b/.gitignore index bbc6bc5..eb52a64 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ out/ !**/src/main/**/out/ !**/src/test/**/out/ src/main/resources/application.properties +src/main/resources/test +src/main/resources/initial_region_data.sql +src/main/resources/update_region_data.sql ### NetBeans ### /nbproject/private/ /nbbuild/ diff --git a/src/main/java/com/SafeNet/Backend/domain/member/controller/MemberController.java b/src/main/java/com/SafeNet/Backend/domain/member/controller/MemberController.java index 71b52f7..b8760bb 100644 --- a/src/main/java/com/SafeNet/Backend/domain/member/controller/MemberController.java +++ b/src/main/java/com/SafeNet/Backend/domain/member/controller/MemberController.java @@ -3,6 +3,7 @@ import com.SafeNet.Backend.domain.member.dto.*; import com.SafeNet.Backend.domain.member.entity.UserDetailsImpl; import com.SafeNet.Backend.domain.member.service.EmailService; +import com.SafeNet.Backend.domain.member.service.JwtBlacklistService; import com.SafeNet.Backend.domain.member.service.MemberService; import com.SafeNet.Backend.global.exception.CustomException; import io.swagger.v3.oas.annotations.Operation; @@ -28,6 +29,7 @@ public class MemberController { private final MemberService memberService; private final EmailService mailService; + private final JwtBlacklistService jwtBlacklistService; @Operation(summary = "회원가입", description = "회원가입을 승인합니다.") @PostMapping("/signup") @@ -91,7 +93,7 @@ public ResponseEntity logout( @RequestHeader(name = "ACCESS_TOK UserDetailsImpl userDetails = (UserDetailsImpl) principal; String email = userDetails.getUsername(); log.info("토큰으로부터 이메일을 추출하였습니다.: "+email); - memberService.logout(email); + memberService.logout(email, accessToken); return ResponseEntity.ok().build(); } diff --git a/src/main/java/com/SafeNet/Backend/domain/member/service/JwtBlacklistService.java b/src/main/java/com/SafeNet/Backend/domain/member/service/JwtBlacklistService.java new file mode 100644 index 0000000..876e841 --- /dev/null +++ b/src/main/java/com/SafeNet/Backend/domain/member/service/JwtBlacklistService.java @@ -0,0 +1,26 @@ +package com.SafeNet.Backend.domain.member.service; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.concurrent.TimeUnit; + +@Service +public class JwtBlacklistService { + private RedisTemplate redisTemplate; + + public JwtBlacklistService(@Qualifier("tokenRedisTemplate") RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + public void addToBlacklist(String token, long expirationTime) { + redisTemplate.opsForValue().set(token, "logout", expirationTime, TimeUnit.MILLISECONDS); + } + + public boolean isBlacklisted(String token) { + return redisTemplate.hasKey(token); + } +} diff --git a/src/main/java/com/SafeNet/Backend/domain/member/service/MemberService.java b/src/main/java/com/SafeNet/Backend/domain/member/service/MemberService.java index aa42dc6..b207b98 100644 --- a/src/main/java/com/SafeNet/Backend/domain/member/service/MemberService.java +++ b/src/main/java/com/SafeNet/Backend/domain/member/service/MemberService.java @@ -118,10 +118,10 @@ public TokenResponseDto login(LoginRequestDto loginRequestDto) throws Exception /* ** 로그아웃 */ - public void logout(String email) { + public void logout(String email, String atk) { //Token에서 로그인한 사용자 정보 get해 로그아웃 처리 try { - jwtTokenProvider.logout("JWT_TOKEN:" + email); //Token 삭제 + jwtTokenProvider.logout(email, atk); //Token 삭제 }catch (CustomException ex) { throw new CustomException("이미 로그아웃된 유저입니다"); } diff --git a/src/main/java/com/SafeNet/Backend/global/auth/JwtFilter.java b/src/main/java/com/SafeNet/Backend/global/auth/JwtFilter.java index 403370a..2ecba55 100644 --- a/src/main/java/com/SafeNet/Backend/global/auth/JwtFilter.java +++ b/src/main/java/com/SafeNet/Backend/global/auth/JwtFilter.java @@ -13,6 +13,7 @@ import org.springframework.security.core.Authentication; import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.filter.OncePerRequestFilter; @@ -44,23 +45,24 @@ protected void doFilterInternal( // 2. validateToken 으로 토큰 유효성 검사 if (token != null && jwtTokenProvider.validateToken(token)) { log.info("dofilterInternal : [토큰유효성 검사 통과.]"); - Authentication auth = jwtTokenProvider.getAuthentication(token); - SecurityContextHolder.getContext().setAuthentication(auth); // 정상 토큰이면 SecurityContext에 저장 //Redis 에 해당 accessToken logout 여부 확인 : Logout이면 Redis에 특정값이 저장되어있음 String isLogout = (String)redisTemplate.opsForValue().get(token); - if (ObjectUtils.isEmpty(isLogout)) { //로그아웃 상태라면, + if (ObjectUtils.isEmpty(isLogout)) { // 로그아웃 상태가 아니라면 // 토큰이 유효할 경우 토큰에서 Authentication 객체를 가지고 와서 SecurityContext 에 저장 Authentication authentication = jwtTokenProvider.getAuthentication(token); SecurityContextHolder.getContext().setAuthentication(authentication); + }else { + log.info("유효한 JWT 토큰이 없습니다. (로그아웃된 토큰) "); + throw new AuthenticationException("로그아웃된 토큰입니다.") {}; } } } catch (RedisConnectionFailureException e) { SecurityContextHolder.clearContext(); writeErrorResponse(response, HttpStatus.INTERNAL_SERVER_ERROR, "REDIS_ERROR", e); - } catch (Exception e) { - writeErrorResponse(response, HttpStatus.BAD_REQUEST, "INVALID_JWT", e); + } catch (AuthenticationException e) { + SecurityContextHolder.clearContext(); + writeErrorResponse(response, HttpStatus.UNAUTHORIZED, "로그아웃된 계정입니다.", e); } - try { filterChain.doFilter(request, response); } catch (Exception e) { diff --git a/src/main/java/com/SafeNet/Backend/global/auth/JwtTokenProvider.java b/src/main/java/com/SafeNet/Backend/global/auth/JwtTokenProvider.java index 1e0c2c6..02210bb 100644 --- a/src/main/java/com/SafeNet/Backend/global/auth/JwtTokenProvider.java +++ b/src/main/java/com/SafeNet/Backend/global/auth/JwtTokenProvider.java @@ -1,5 +1,6 @@ package com.SafeNet.Backend.global.auth; +import ch.qos.logback.core.status.Status; import com.SafeNet.Backend.domain.member.dto.TokenResponseDto; import com.SafeNet.Backend.domain.member.service.UserDetailsServiceImpl; import com.SafeNet.Backend.global.exception.CustomException; @@ -9,12 +10,14 @@ import jakarta.annotation.PostConstruct; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; +import jdk.jshell.Snippet; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.userdetails.UserDetails; @@ -22,6 +25,7 @@ import java.security.Key; +import java.time.Duration; import java.util.Date; import java.util.concurrent.TimeUnit; @Component @@ -142,8 +146,9 @@ public boolean validateToken(String token){ throw new CustomException("INVALID_JWT"); } } - - // 모든 토큰 헤더 설정 + /* + * 모든 토큰 헤더 설정 + */ public void setHeaderToken(HttpServletResponse response, TokenResponseDto dto) { response.setHeader("Access_Token", dto.getAccessToken()); response.setHeader("Refresh_Token", dto.getRefreshToken()); @@ -152,9 +157,30 @@ public void setHeaderToken(HttpServletResponse response, TokenResponseDto dto) { /* * 로그아웃 로직 - Refresh 토큰을 redis에서 삭제 */ - public void logout(String email) { - if(tokenRedisTemplate.opsForValue().get("JWT_TOKEN:" + email) != null) { + public ResponseEntity logout(String email, String token) { + String atk= token.substring(7); + Long expiration = getExpiration(atk); + if(tokenRedisTemplate.opsForValue().get(email) != null) { tokenRedisTemplate.delete(email); } + // [ 블랙리스트 생성 단계 ] redis에 가져온 key(JWT 토큰) : value("logout")으로 저장 + tokenRedisTemplate.opsForValue().set(atk, "logout", Duration.ofMillis(expiration)); + + return new ResponseEntity<>(HttpStatus.OK); + } + /* + * 유효기간 가져오기 + */ + public Long getExpiration(String accessToken) { + // accessToken 남은 유효시간 + Date expiration = Jwts.parserBuilder() + .setSigningKey(key) + .build() + .parseClaimsJws(accessToken) + .getBody() + .getExpiration(); + // 현재 시간 + Long now = new Date().getTime(); + return (expiration.getTime() - now); } } diff --git a/src/main/resources/initial_region_data.sql b/src/main/resources/initial_region_data.sql deleted file mode 100644 index 8313af5..0000000 --- a/src/main/resources/initial_region_data.sql +++ /dev/null @@ -1,472 +0,0 @@ --- 종로구 -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '청운효자동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '사직동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '삼청동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '부암동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '평창동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '무악동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '교남동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '가회동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '종로1가'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '종로2가'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '종로3가'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '누상동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '누하동'); -INSERT INTO region (city, county, district) VALUES ('서울', '종로구', '창성동'); - --- 중구 -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '소공동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '회현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '명동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '필동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '장충동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '광희동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '을지로동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '신당동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '다산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '약수동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '청구동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '신당5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '동화동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '황학동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중구', '중림동'); - --- 용산구 -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '후암동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '용산2가동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '남영동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '청파동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '원효로1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '원효로2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '효창동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '용문동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '한강로동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '이촌1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '이촌2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '이태원1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '이태원2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '한남동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '서빙고동'); -INSERT INTO region (city, county, district) VALUES ('서울', '용산구', '보광동'); - --- 성동구 -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '왕십리도선동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '왕십리2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '마장동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '사근동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '행당1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '행당2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '응봉동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '금호1가동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '금호2·3가동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '금호4가동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '옥수동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '성수1가1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '성수1가2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '성수2가1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '성수2가3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '송정동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성동구', '용답동'); - --- 광진구 -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '중곡1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '중곡2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '중곡3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '중곡4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '능동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '구의1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '구의2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '구의3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '광장동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '자양1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '자양2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '자양3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '자양4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '화양동'); -INSERT INTO region (city, county, district) VALUES ('서울', '광진구', '군자동'); - --- 동대문구 -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '용신동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '제기동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '전농1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '전농2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '답십리1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '답십리2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '장안1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '장안2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '청량리동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '회기동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '휘경1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '휘경2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '이문1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동대문구', '이문2동'); - --- 중랑구 -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목3·8동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '면목7동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '상봉1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '상봉2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '중화1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '중화2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '묵1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '묵2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '망우본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '망우3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '신내1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '중랑구', '신내2동'); - --- 성북구 -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '성북동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '삼선동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '동선동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '돈암1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '돈암2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '안암동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '보문동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '정릉1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '정릉2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '정릉3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '정릉4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '길음1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '길음2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '종암동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '월곡1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '월곡2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '장위1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '장위2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '장위3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '성북구', '석관동'); - --- 강북구 -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '삼양동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '미아동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '송중동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '송천동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '삼각산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '번1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '번2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '번3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '수유1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '수유2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '수유3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '우이동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강북구', '인수동'); - --- 도봉구 -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '쌍문1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '쌍문2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '쌍문3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '쌍문4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '방학1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '방학2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '방학3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '창1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '창2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '창3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '창4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '창5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '도봉1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '도봉구', '도봉2동'); - --- 노원구 -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '월계1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '월계2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '월계3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '공릉1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '공릉2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '하계1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '하계2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '중계본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '중계1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '중계2·3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '중계4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계3·4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계6·7동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계8동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계9동'); -INSERT INTO region (city, county, district) VALUES ('서울', '노원구', '상계10동'); - --- 은평구 -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '녹번동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '불광1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '불광2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '갈현1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '갈현2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '구산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '대조동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '응암1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '응암2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '응암3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '역촌동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '신사1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '신사2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '증산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '수색동'); -INSERT INTO region (city, county, district) VALUES ('서울', '은평구', '진관동'); - --- 서대문구 -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '충현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '천연동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '북아현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '신촌동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '연희동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '홍제1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '홍제2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '홍제3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '홍은1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '홍은2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '남가좌1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '남가좌2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '북가좌1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서대문구', '북가좌2동'); - --- 마포구 -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '공덕동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '아현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '도화동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '용강동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '대흥동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '염리동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '신수동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '서강동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '서교동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '합정동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '망원1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '망원2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '연남동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '성산1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '성산2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '마포구', '상암동'); - --- 양천구 -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '목1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '목2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '목3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '목4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '목5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월6동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신월7동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정6동'); -INSERT INTO region (city, county, district) VALUES ('서울', '양천구', '신정7동'); - --- 강서구 -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '염창동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '등촌1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '등촌2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '등촌3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡6동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '화곡8동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '우장산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '가양1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '가양2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '가양3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '발산1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '공항동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '방화1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '방화2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강서구', '방화3동'); - --- 구로구 -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '신도림동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '구로1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '구로2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '구로3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '구로4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '구로5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '가리봉동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '수궁동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '고척1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '고척2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '개봉1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '개봉2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '개봉3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '오류1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '오류2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '구로구', '항동'); - --- 금천구 -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '가산동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '독산1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '독산2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '독산3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '독산4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '시흥1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '시흥2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '시흥3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '시흥4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '금천구', '시흥5동'); - --- 영등포구 -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '영등포본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '영등포동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '여의동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '당산1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '당산2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '도림동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '문래동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '양평1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '양평2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길6동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '신길7동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '대림1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '대림2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '영등포구', '대림3동'); - --- 동작구 -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '노량진1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '노량진2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '상도1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '상도2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '상도3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '상도4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '흑석동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '사당1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '사당2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '사당3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '사당4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '사당5동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '대방동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '신대방1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '동작구', '신대방2동'); - --- 관악구 -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '보라매동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '은천동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '성현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '중앙동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '청림동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '행운동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '청룡동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '낙성대동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '인헌동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '남현동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '신림동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '신사동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '조원동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '미성동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '난곡동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '난향동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '서원동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '신원동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '서림동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '삼성동'); -INSERT INTO region (city, county, district) VALUES ('서울', '관악구', '대학동'); - --- 서초구 -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '서초1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '서초2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '서초3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '서초4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '잠원동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '반포본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '반포1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '반포2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '반포3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '반포4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '방배본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '방배1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '방배2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '방배3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '방배4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '양재1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '양재2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '서초구', '내곡동'); - --- 강남구 -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '신사동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '압구정동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '청담동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '논현1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '논현2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '삼성1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '삼성2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '대치1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '대치2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '대치4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '역삼1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '역삼2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '도곡1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '도곡2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '개포1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '개포2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '개포4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '일원본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '일원1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '일원2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '수서동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강남구', '세곡동'); - --- 송파구 -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '풍납1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '풍납2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '거여1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '거여2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '마천1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '마천2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '방이1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '방이2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '오륜동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '오금동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '송파1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '송파2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '석촌동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '삼전동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '가락본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '가락1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '가락2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '문정1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '문정2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '장지동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '위례동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실본동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실4동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실6동'); -INSERT INTO region (city, county, district) VALUES ('서울', '송파구', '잠실7동'); - --- 강동구 -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '강일동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '상일1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '상일2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '명일1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '명일2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '고덕1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '고덕2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '암사1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '암사2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '암사3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '천호1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '천호2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '천호3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '성내1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '성내2동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '성내3동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '길동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '둔촌1동'); -INSERT INTO region (city, county, district) VALUES ('서울', '강동구', '둔촌2동'); diff --git a/src/main/resources/update_region_data.sql b/src/main/resources/update_region_data.sql deleted file mode 100644 index f2c0c30..0000000 --- a/src/main/resources/update_region_data.sql +++ /dev/null @@ -1,12 +0,0 @@ --- 현재 프론트에서 region을 등록하는 과정이 구현이 안 되었기에, 임의의 값을 넣어놓습니다. --- 현제 데이터가 많이 없는 관계로 통일성 있게 넣어줍니다. -update member set region_id = 1 where member_id = 5; -update member set region_id = 1 where member_id = 6; -update member set region_id = 1 where member_id = 7; -update member set region_id = 356 where member_id = 8; -update member set region_id = 356 where member_id = 9; - --- 기존에 등록된 post는 지역 정보 넣기 -update post set region_id = 1 where member_id = 5; -update post set region_id = 1 where member_id = 6; -update post set region_id = 356 where member_id = 9;