diff --git a/src/main/kotlin/upbrella/be/config/DevCorsConfig.kt b/src/main/kotlin/upbrella/be/config/DevCorsConfig.kt index 4ef35aab..953c1cb8 100644 --- a/src/main/kotlin/upbrella/be/config/DevCorsConfig.kt +++ b/src/main/kotlin/upbrella/be/config/DevCorsConfig.kt @@ -1,43 +1,33 @@ package upbrella.be.config +import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Profile -import org.springframework.stereotype.Component -import javax.servlet.* -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import org.springframework.http.HttpMethod +import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer -@Profile("dev") -@Component -class DevCorsConfig : Filter { - - override fun init(filterConfig: FilterConfig) { - // No initialization needed - } - - override fun doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) { - val request = req as HttpServletRequest - val response = res as HttpServletResponse - - if (request.getHeader("Origin") != null) { - if (request.getHeader("Origin").contains("upbrella-dev.site")) { - response.setHeader("Access-Control-Allow-Origin", "http://upbrella-dev.site") - } else { - response.setHeader("Access-Control-Allow-Origin", "http://localhost:3000") - } - } else { - response.setHeader("Access-Control-Allow-Origin", "http://localhost:3000") - } - response.setHeader("Access-Control-Allow-Credentials", "true") - response.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE, HEAD, OPTIONS") - response.setHeader("Access-Control-Max-Age", "10") - response.setHeader("Access-Control-Allow-Headers", - "Origin, X-Requested-With, Content-Type, Accept, Authorization") - - chain.doFilter(request, response) - } - - override fun destroy() { - // No cleanup needed +@Profile("dev") +@Configuration +class DevCorsConfig : WebMvcConfigurer { + + override fun addCorsMappings(registry: CorsRegistry) { + registry.addMapping("/**") + .allowedOrigins( + "http://localhost:3000", + "https://upbrella-front.vercel.app", + "https://dev.upbrella.link" + ) + .allowedMethods( + HttpMethod.GET.name, + HttpMethod.POST.name, + HttpMethod.PATCH.name, + HttpMethod.DELETE.name, + HttpMethod.HEAD.name, + HttpMethod.OPTIONS.name + ) + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(3600) } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index aadf2f60..eb3e919c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -2,9 +2,9 @@ spring: config: import: "classpath:application.properties" datasource: - url: ${DATABASE_URL} - username: ${DATABASE_USERNAME} - password: ${DATABASE_PASSWORD} + url: jdbc:mysql://localhost:3306/upbrella_dev?useSSL=false&serverTimezone=Asia/Seoul&characterEncoding=utf8 + username: root + password: ${DEV_DATABASE_PASSWORD} driver-class-name: com.mysql.cj.jdbc.Driver jpa: properties: diff --git a/src/main/resources/db/init.sql b/src/main/resources/db/init.sql new file mode 100644 index 00000000..cf0b0738 --- /dev/null +++ b/src/main/resources/db/init.sql @@ -0,0 +1,262 @@ +-- MySQL dump 10.13 Distrib 8.4.4, for macos15.2 (arm64) +-- +-- Host: upbrella-production-db.ccjiaacly7wf.ap-northeast-2.rds.amazonaws.com Database: upbrella_prod +-- ------------------------------------------------------ +-- Server version 8.0.40 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN; +SET @@SESSION.SQL_LOG_BIN= 0; + +-- +-- GTID state at the beginning of the backup +-- + +SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ ''; + +-- +-- Table structure for table `black_list` +-- + +DROP TABLE IF EXISTS `black_list`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `black_list` ( + `id` int NOT NULL AUTO_INCREMENT, + `social_id` bigint DEFAULT NULL, + `blocked_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `business_hour` +-- + +DROP TABLE IF EXISTS `business_hour`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `business_hour` ( + `id` int NOT NULL AUTO_INCREMENT, + `store_meta_id` int DEFAULT NULL, + `date` varchar(45) DEFAULT NULL, + `open_at` time DEFAULT NULL, + `close_at` time DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=391 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `classification` +-- + +DROP TABLE IF EXISTS `classification`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `classification` ( + `id` int NOT NULL AUTO_INCREMENT, + `type` varchar(45) DEFAULT NULL, + `name` varchar(45) DEFAULT NULL, + `latitude` double DEFAULT NULL, + `longitude` double DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `condition_report` +-- + +DROP TABLE IF EXISTS `condition_report`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `condition_report` ( + `id` int NOT NULL AUTO_INCREMENT, + `content` varchar(401) DEFAULT NULL, + `etc` varchar(255) DEFAULT NULL, + `history_id` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=523 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `history` +-- + +DROP TABLE IF EXISTS `history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `history` ( + `id` int NOT NULL AUTO_INCREMENT, + `etc` varchar(255) DEFAULT NULL, + `rented_at` datetime DEFAULT NULL, + `returned_at` datetime DEFAULT NULL, + `rent_store_meta_id` int DEFAULT NULL, + `return_store_meta_id` int DEFAULT NULL, + `umbrella_id` int DEFAULT NULL, + `user_id` int DEFAULT NULL, + `bank` varchar(45) DEFAULT NULL, + `account_number` varchar(45) DEFAULT NULL, + `refunded_at` datetime DEFAULT NULL, + `refunded_by` int DEFAULT NULL, + `paid_at` datetime DEFAULT NULL, + `paid_by` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=523 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `improvement_report` +-- + +DROP TABLE IF EXISTS `improvement_report`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `improvement_report` ( + `id` int NOT NULL AUTO_INCREMENT, + `content` varchar(401) DEFAULT NULL, + `etc` varchar(255) DEFAULT NULL, + `history_id` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=434 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `locker` +-- + +DROP TABLE IF EXISTS `locker`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `locker` ( + `id` int NOT NULL AUTO_INCREMENT, + `count` int DEFAULT NULL, + `secret_key` varchar(2000) DEFAULT NULL, + `last_access` timestamp NULL DEFAULT NULL, + `store_meta_id` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `store_detail` +-- + +DROP TABLE IF EXISTS `store_detail`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `store_detail` ( + `id` int NOT NULL AUTO_INCREMENT, + `address` varchar(255) DEFAULT NULL, + `address_detail` varchar(255) DEFAULT NULL, + `contact_info` varchar(255) DEFAULT NULL, + `content` varchar(255) DEFAULT NULL, + `insta_url` varchar(255) DEFAULT NULL, + `working_hour` varchar(255) DEFAULT NULL, + `store_meta_id` int DEFAULT NULL, + `umbrella_location` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `store_image` +-- + +DROP TABLE IF EXISTS `store_image`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `store_image` ( + `id` int NOT NULL AUTO_INCREMENT, + `image_url` varchar(2000) DEFAULT NULL, + `store_detail_id` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `store_meta` +-- + +DROP TABLE IF EXISTS `store_meta`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `store_meta` ( + `id` int NOT NULL AUTO_INCREMENT, + `classification_id` bigint DEFAULT NULL, + `sub_classification_id` bigint DEFAULT NULL, + `activated` tinyint DEFAULT NULL, + `deleted` tinyint DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `category` varchar(255) DEFAULT NULL, + `latitude` double DEFAULT NULL, + `longitude` double DEFAULT NULL, + `password` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `umbrella` +-- + +DROP TABLE IF EXISTS `umbrella`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `umbrella` ( + `id` int NOT NULL AUTO_INCREMENT, + `deleted` tinyint DEFAULT NULL, + `rentable` tinyint DEFAULT NULL, + `uuid` bigint DEFAULT NULL, + `store_meta_id` int DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `etc` varchar(255) DEFAULT NULL, + `missed` tinyint DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=209 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` int NOT NULL AUTO_INCREMENT, + `admin_status` tinyint DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `phone_number` varchar(255) DEFAULT NULL, + `social_id` varchar(500) DEFAULT NULL, + `bank` varchar(500) DEFAULT NULL, + `account_number` varchar(500) DEFAULT NULL, + `email` varchar(500) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=743 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping routines for database 'upbrella_prod' +-- +SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2025-05-18 21:02:45