[#5] Refactor: kotlin 베이스로 프로젝트 구성

- build.gradle 코틀린 설정 추가
- 불필요한 내용 삭제(flyway, docker 관련 내용)
- 일부 코드 kotlin migration(진행중)
This commit is contained in:
beaniejoy
2022-06-22 00:24:04 +09:00
parent 14f4000b44
commit 162533389d
49 changed files with 130 additions and 449 deletions

View File

@@ -1,34 +0,0 @@
FROM adoptopenjdk/openjdk11:latest as BUILD_IMAGE
ENV WORK_DIR=/usr/app/
# app 작업 디렉토리 설정
WORKDIR $WORK_DIR
# gradle 실행을 위한 필수 디렉토리 준비
COPY gradlew $WORK_DIR
COPY build.gradle $WORK_DIR
COPY settings.gradle $WORK_DIR
COPY gradle $WORK_DIR/gradle
RUN ./gradlew -x test build || return 0
COPY src src
# jar 파일 build
RUN ./gradlew bootjar
FROM adoptopenjdk/openjdk11:latest
ENV WORK_DIR=/usr/app/
WORKDIR $WORK_DIR
COPY --from=BUILD_IMAGE $WORK_DIR/build/libs/*.jar app-server.jar
ENTRYPOINT ["java", \
"-jar", \
"-Dspring.profiles.active=${PROFILE_OPTION}", \
"-Dspring.datasource.url=${SPRING_DATASOURCE_URL}", \
"-Dredis.host=${REDIS_HOST}", \
"app-server.jar"]

View File

@@ -1,24 +1,40 @@
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
buildscript {
ext {
springBootVersion = '2.7.0'
dependencyManagementVersion = '1.0.11.RELEASE'
kotlinVersion = '1.6.21'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:${dependencyManagementVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}"
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'io.beaniejoy.dongecafe'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
@@ -33,16 +49,16 @@ dependencies {
// MySQL
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
// annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
configurations {
all {
// log4j2 적용을 위해 기존 spring boot에서 제공하는 logging exclude
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
//configurations {
// all {
// // log4j2 적용을 위해 기존 spring boot에서 제공하는 logging exclude
// exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
// }
//}
test {
useJUnitPlatform()

View File

@@ -1,45 +0,0 @@
version: "3.8"
services:
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
volumes:
- ./nginx/:/etc/nginx/conf.d/
depends_on:
- app-server-1
- app-server-2
app-server-1:
build:
context: .
dockerfile: Dockerfile
env_file:
- env/app.env
depends_on:
- db-mysql
app-server-2:
build:
context: .
dockerfile: Dockerfile
env_file:
- env/app.env
depends_on:
- db-mysql
migration:
build:
context: ./flyway
dockerfile: Dockerfile
environment:
FLYWAY_EDITION: community
volumes:
- ${PWD}/flyway/db-migration:/flyway/sql
- ${PWD}/flyway/conf:/flyway/conf
depends_on:
- db-mysql
db-mysql:
image: mysql:5.7
ports:
- "3306:3306"
env_file:
- env/mysql.env

4
env/app.env vendored
View File

@@ -1,4 +0,0 @@
PROFILE_OPTION=dev
SPRING_DATASOURCE_URL=jdbc:mysql://db-mysql:3306/dongnecafe?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul
SPRING_DATASOURCE_USERNAME=root
SPRING_DATASOURCE_PASSWORD=dev

2
env/mysql.env vendored
View File

@@ -1,2 +0,0 @@
MYSQL_DATABASE=dongnecafe
MYSQL_ROOT_PASSWORD=dev

View File

@@ -1,17 +0,0 @@
FROM flyway/flyway:7-alpine
USER root
RUN apk add --no-cache openssl
# run flyway in order through dockerize utility.
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
COPY ./docker-entrypoint.sh docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT ["./docker-entrypoint.sh"]

View File

@@ -1,4 +0,0 @@
flyway.url=jdbc:mysql://db-mysql:3306/dongnecafe?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul
flyway.user=root
flyway.password=dev
flyway.driver=com.mysql.cj.jdbc.Driver

View File

@@ -1,4 +0,0 @@
flyway.url=jdbc:mysql://db-mysql:3306/dongnecafe?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul
flyway.user=root
flyway.password=dev
flyway.driver=com.mysql.cj.jdbc.Driver

View File

@@ -1,11 +0,0 @@
CREATE TABLE `cafe` (
`cafe_id` binary(16) NOT NULL COMMENT '카페식별번호',
`name` varchar(20) NOT NULL COMMENT '카페명',
`address` varchar(100) NOT NULL COMMENT '카페 주소',
`phone_number` varchar(11) NOT NULL COMMENT '카페 전화번호',
`total_rate` float NOT NULL COMMENT '카페 종합 평가 점수',
`description` varchar(255) COMMENT '카페 상세설명',
`created_date` datetime NOT NULL COMMENT '카페 등록날짜',
`updated_date` datetime COMMENT '카페 수정날짜',
PRIMARY KEY (`cafe_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,11 +0,0 @@
CREATE TABLE `cafe_menu` (
`menu_id` binary(16) NOT NULL COMMENT '카페 메뉴 식별번호',
`name` varchar(50) NOT NULL COMMENT '카페 메뉴명',
`price` int NOT NULL COMMENT '메뉴 가격',
`created_date` datetime NOT NULL COMMENT '메뉴 등록날짜',
`updated_date` datetime COMMENT '메뉴 수정날짜',
`cafe_id` binary(16) NOT NULL COMMENT '연관된 카페식별번호',
PRIMARY KEY (`menu_id`),
KEY `cafe_id` (`cafe_id`),
FOREIGN KEY (`cafe_id`) REFERENCES `cafe` (`cafe_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,10 +0,0 @@
CREATE TABLE `cafe_image` (
`cafe_img_id` binary(16) NOT NULL COMMENT '카페 이미지 식별번호',
`img_url` varchar(255) NOT NULL COMMENT '이미지 경로',
`created_date` datetime NOT NULL COMMENT '이미지 등록날짜',
`updated_date` datetime COMMENT '이미지 수정날짜',
`cafe_id` binary(16) NOT NULL COMMENT '연관된 카페식별번호',
PRIMARY KEY (`cafe_img_id`),
KEY `cafe_id` (`cafe_id`),
FOREIGN KEY (`cafe_id`) REFERENCES `cafe` (`cafe_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,10 +0,0 @@
CREATE TABLE `menu_option`(
`option_id` binary(16) NOT NULL COMMENT '옵션 식별번호',
`title`varchar(50) NOT NULL COMMENT '메뉴 옵션 이름',
`created_date` datetime NOT NULL COMMENT '옵션 등록날짜',
`updated_date` datetime COMMENT '옵션 수정날짜',
`menu_id` binary(16) NOT NULL COMMENT '연관된 카페 메뉴 식별번호',
PRIMARY KEY (`option_id`),
KEY `menu_id` (`menu_id`),
FOREIGN KEY (`menu_id`) REFERENCES `cafe_menu` (`menu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,11 +0,0 @@
CREATE TABLE `option_detail` (
`option_detail_id` bigint NOT NULL COMMENT '옵션 상세 번호',
`name` varchar(50) NOT NULL COMMENT '옵션 상세명',
`extra` int NOT NULL COMMENT '옵션 추가 요금',
`created_date` datetime NOT NULL COMMENT '옵션 상세 등록날짜',
`updated_date` datetime COMMENT '옵션 상세 수정날짜',
`option_id` binary(16) NOT NULL COMMENT '연관된 옵션 식별번호',
PRIMARY KEY (`option_detail_id`),
KEY `option_id` (`option_id`),
FOREIGN KEY (`option_id`) REFERENCES `menu_option` (`option_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,11 +0,0 @@
CREATE TABLE `user` (
`user_id` binary(16) NOT NULL COMMENT '사용자 식별번호',
`email`varchar(50) NOT NULL COMMENT '사용자 이메일',
`password` varchar(100) NOT NULL COMMENT '계정 비밀번호',
`address` varchar(100) NOT NULL COMMENT '사용자 주소',
`phone_number` varchar(11) NOT NULL COMMENT '사용자 전화번호',
`role` varchar(20) NOT NULL COMMENT '사용자 권한',
`created_date` datetime NOT NULL COMMENT '사용자 등록날짜',
`updated_date` datetime COMMENT '사용자 수정날짜',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,15 +0,0 @@
CREATE TABLE `review` (
`review_id` binary(16) NOT NULL COMMENT '리뷰 식별번호',
`content`varchar(255) NOT NULL COMMENT '리뷰 내용',
`img_url` varchar(255) NOT NULL COMMENT '리뷰 첨부사진 주소',
`rate` tinyint NOT NULL COMMENT '평가점수(0 ~ 5점)',
`created_date` datetime NOT NULL COMMENT '리뷰 등록날짜',
`updated_date` datetime COMMENT '리뷰 수정날짜',
`user_id` binary(16) NOT NULL COMMENT '리뷰 작성한 사용자 식별번호',
`cafe_id` binary(16) NOT NULL COMMENT '리뷰 대상 카페 식별번호',
PRIMARY KEY (`review_id`),
KEY `user_id` (`user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`),
KEY `cafe_id` (`cafe_id`),
FOREIGN KEY (`cafe_id`) REFERENCES `cafe` (`cafe_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,13 +0,0 @@
CREATE TABLE `cart` (
`cart_id` binary(16) NOT NULL COMMENT '장바구니 식별번호',
`cafe_name` varchar(20) NOT NULL COMMENT '장바구니에 담긴 카페 이름',
`check_ordered` tinyint NOT NULL COMMENT '장바구니의 주문 여부',
`total_price` int NOT NULL COMMENT '장바구니에 담긴 총 금액',
`created_date` datetime NOT NULL COMMENT '장바구니 등록날짜',
`updated_date` datetime COMMENT '장바구니 수정날짜',
`cafe_id` binary(16) NOT NULL COMMENT '장바구니에 담긴 카페 식별번호',
`user_id` binary(16) NOT NULL COMMENT '장바구니 주인 사용자 식별번호',
PRIMARY KEY (`cart_id`),
KEY `user_id` (`user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,12 +0,0 @@
CREATE TABLE `basket` (
`basket_id` binary(16) NOT NULL COMMENT '장바구니 품목 식별번호',
`menu_name` varchar(50) NOT NULL COMMENT '장바구니 품목 이름',
`menu_count` int NOT NULL COMMENT '장바구니 품목 개수',
`menu_price` int NOT NULL COMMENT '장바구니 품목 가격',
`created_date` datetime NOT NULL COMMENT '장바구니 품목 등록날짜',
`updated_date` datetime COMMENT '장바구니 품목 수정날짜',
`cart_id` binary(16) NOT NULL COMMENT '해당 품목이 담긴 장바구니 식별번호',
PRIMARY KEY (`basket_id`),
KEY `cart_id` (`cart_id`),
FOREIGN KEY (`cart_id`) REFERENCES `cart` (`cart_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,11 +0,0 @@
CREATE TABLE `basket_option` (
`basket_option_id` binary(16) NOT NULL COMMENT '품목 추가옵션 식별번호',
`option_name`varchar(50) NOT NULL COMMENT '품목 추가옵션 내용',
`option_extra` int NOT NULL COMMENT '품목 추가옵션 추가요금',
`created_date` datetime NOT NULL COMMENT '품목 추가옵션 등록날짜',
`updated_date` datetime COMMENT '품목 추가옵션 수정날짜',
`basket_id` binary(16) NOT NULL COMMENT '추가옵션 대상 장바구니 품목 식별번호',
PRIMARY KEY (`basket_option_id`),
KEY `basket_id` (`basket_id`),
FOREIGN KEY (`basket_id`) REFERENCES `basket` (`basket_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,14 +0,0 @@
CREATE TABLE `menu_order` (
`order_id` binary(16) NOT NULL COMMENT '주문 식별번호',
`order_status` varchar(20) NOT NULL COMMENT '주문 상태',
`request_message` varchar(255) NOT NULL COMMENT '주문 요청사항',
`created_date` datetime NOT NULL COMMENT '주문 등록날짜',
`updated_date` datetime COMMENT '주문 수정날짜',
`cart_id` binary(16) NOT NULL COMMENT '주문된 카트 식별번호',
`user_id` binary(16) NOT NULL COMMENT '주문한 사용자 식별번호',
PRIMARY KEY (`order_id`),
KEY `cart_id` (`cart_id`),
FOREIGN KEY (`cart_id`) REFERENCES `cart` (`cart_id`),
KEY `user_id` (`user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -1,20 +0,0 @@
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), '비니카페', '서울시 동대문구 전농로', '01011112222', 3.98, '언제나 상쾌한 비니카페', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), '조이카페', '서울시 영등포구', '01033334444', 4.67, '언제나 상쾌한 조이카페', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), 'abc카페', '서울시 서대문구', '01025341432', 4.89, '언제나 상쾌한 abc카페', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), '동네주변카페', '서울시 송파구', '01022223333', 4.23, '언제나 상쾌한 동네주변카페', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), '방긋카페', '서울시 광진구', '01099998888', 4.35, '언제나 상쾌한 방긋카페', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), 'example cafe1', '서울시 종로구', '01077779999', 2.85, '언제나 상쾌한 example cafe1', now());
INSERT IGNORE INTO `cafe` (cafe_id, name, address, phone_number, total_rate, description, created_date)
VALUES (unhex(replace(uuid(), '-', '')), 'example cafe2', '서울시', '01044445555', 3.12, '언제나 상쾌한 example cafe2', now());

View File

@@ -1,26 +0,0 @@
DROP PROCEDURE IF EXISTS insertCafeImages;
DELIMITER $$
CREATE PROCEDURE insertCafeImages()
BEGIN
DECLARE i INT DEFAULT 0;
DECLARE j INT;
DECLARE idx_img INT DEFAULT 1;
DECLARE var_cafe_id binary(16);
DECLARE count_cafe INT;
SET count_cafe = (SELECT COUNT(*) FROM `cafe`);
WHILE(i <= count_cafe) DO
SET j = 1;
SET var_cafe_id = (SELECT cafe_id FROM `cafe` LIMIT i, 1);
WHILE(j <= 3) DO
INSERT IGNORE INTO `cafe_image` (cafe_img_id, img_url, cafe_id, created_date)
VALUES (unhex(replace(uuid(), '-', '')), CONCAT('test_img_url_', idx_img), var_cafe_id, now());
SET j = j + 1;
SET idx_img = idx_img + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
CALL insertCafeImages();

View File

@@ -1,22 +0,0 @@
DROP PROCEDURE IF EXISTS insertMenus;
DELIMITER $$
CREATE PROCEDURE insertCafeMenus()
BEGIN
DECLARE i INT DEFAULT 0;
DECLARE j INT;
DECLARE var_cafe_id binary(16);
WHILE(i <= 4) DO
SET j = 1;
SET var_cafe_id = (SELECT cafe_id FROM `cafe` LIMIT i, 1);
WHILE(j <= 10) DO
INSERT IGNORE INTO `cafe_menu` (menu_id, name, price, cafe_id, created_date)
VALUES (unhex(replace(uuid(), '-', '')), CONCAT('커피', j), FLOOR(RAND() * 10 + 1) * 1000, var_cafe_id, now());
SET j = j + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
CALL insertCafeMenus();

View File

@@ -1,11 +0,0 @@
#!/bin/bash
echo "wait DB container up"
dockerize -wait tcp://db-mysql:3306 -timeout 20s
# DB Migration
echo "run database migration"
flyway -configFiles=/flyway/conf/flyway_main.conf -locations=filesystem:/flyway/sql/main migrate
# Seed Migration
echo "insert seed data"
flyway -configFiles=/flyway/conf/flyway_seed.conf -locations=filesystem:/flyway/sql/seed migrate

View File

@@ -1,10 +0,0 @@
upstream appserver {
server app-server-1:8080;
server app-server-2:8080;
}
server {
listen 80;
location / {
proxy_pass http://appserver;
}
}

View File

@@ -1,13 +0,0 @@
package io.beaniejoy.dongnecafe;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DongneCafeSirenOrderApplication {
public static void main(String[] args) {
SpringApplication.run(DongneCafeSirenOrderApplication.class, args);
}
}

View File

@@ -0,0 +1,11 @@
package io.beaniejoy.dongnecafe
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class DongneCafeSirenOrderApplication
fun main(args: Array<String>) {
runApplication<DongneCafeSirenOrderApplication>(*args)
}

View File

@@ -1,48 +0,0 @@
package io.beaniejoy.dongnecafe.cafe.controller;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeInfoResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeSearchResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeUpdateRequestDto;
import io.beaniejoy.dongnecafe.cafe.service.CafeService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
@RestController
@RequiredArgsConstructor
@RequestMapping("/cafes")
public class CafeController {
private final CafeService cafeService;
@GetMapping(value = "")
public ResponseEntity<List<CafeSearchResponseDto>> searchCafeList(
@PageableDefault(sort = "name", direction = Sort.Direction.ASC, size = 10) Pageable pageable) {
List<CafeSearchResponseDto> cafeResponseList = cafeService.getCafeList(pageable);
return ResponseEntity.ok(cafeResponseList);
}
@GetMapping("/{cafeId}")
public ResponseEntity<CafeInfoResponseDto> getCafeDetailedInfo(@PathVariable("cafeId") UUID cafeId) {
CafeInfoResponseDto cafeResponse = cafeService.getCafeInfoByCafeId(cafeId);
return ResponseEntity.ok(cafeResponse);
}
@PutMapping("/{cafeId}")
public ResponseEntity<String> updateCafeInfo(
@PathVariable("cafeId") UUID cafeId,
@RequestBody CafeUpdateRequestDto resource) {
cafeService.updateCafe(cafeId, resource);
return ResponseEntity.ok("Successfully Cafe[" + cafeId + "] Info Updated");
}
}

View File

@@ -0,0 +1,43 @@
package io.beaniejoy.dongnecafe.domain.cafe.controller
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeInfoResponseDto
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeSearchResponseDto
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeUpdateRequestDto
import io.beaniejoy.dongnecafe.domain.cafe.service.CafeService
import lombok.RequiredArgsConstructor
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Sort
import org.springframework.data.web.PageableDefault
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.util.*
@RestController
@RequiredArgsConstructor
@RequestMapping("/cafes")
class CafeController(
private val cafeService: CafeService
) {
@GetMapping
fun searchCafeList(
@PageableDefault(sort = ["name"], direction = Sort.Direction.ASC, size = 10) pageable: Pageable
): ResponseEntity<List<CafeSearchResponseDto>> {
val cafeResponseList = cafeService.getCafeList(pageable)
return ResponseEntity.ok(cafeResponseList)
}
@GetMapping("/{cafeId}")
fun getCafeDetailedInfo(@PathVariable("cafeId") cafeId: UUID?): ResponseEntity<CafeInfoResponseDto> {
val cafeResponse = cafeService.getCafeInfoByCafeId(cafeId)
return ResponseEntity.ok(cafeResponse)
}
@PutMapping("/{cafeId}")
fun updateCafeInfo(
@PathVariable("cafeId") cafeId: UUID,
@RequestBody resource: CafeUpdateRequestDto?
): ResponseEntity<String> {
cafeService.updateCafe(cafeId, resource)
return ResponseEntity.ok("Successfully Cafe[$cafeId] Info Updated")
}
}

View File

@@ -1,7 +1,7 @@
package io.beaniejoy.dongnecafe.cafe.controller;
package io.beaniejoy.dongnecafe.domain.cafe.controller;
import io.beaniejoy.dongnecafe.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.cafe.service.CafeMenuService;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.service.CafeMenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;

View File

@@ -1,7 +1,7 @@
package io.beaniejoy.dongnecafe.cafe.domain;
package io.beaniejoy.dongnecafe.domain.cafe.domain;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeInfoResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeSearchResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeInfoResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeSearchResponseDto;
import io.beaniejoy.dongnecafe.common.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.domain;
package io.beaniejoy.dongnecafe.domain.cafe.domain;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeImageResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeImageResponseDto;
import io.beaniejoy.dongnecafe.common.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,7 +1,7 @@
package io.beaniejoy.dongnecafe.cafe.domain;
package io.beaniejoy.dongnecafe.domain.cafe.domain;
import io.beaniejoy.dongnecafe.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.menu.CafeMenuListResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.CafeMenuListResponseDto;
import io.beaniejoy.dongnecafe.common.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.domain;
package io.beaniejoy.dongnecafe.domain.cafe.domain;
import io.beaniejoy.dongnecafe.cafe.dto.menu.MenuOptionResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.MenuOptionResponseDto;
import io.beaniejoy.dongnecafe.common.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.domain;
package io.beaniejoy.dongnecafe.domain.cafe.domain;
import io.beaniejoy.dongnecafe.cafe.dto.menu.OptionDetailResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.OptionDetailResponseDto;
import io.beaniejoy.dongnecafe.common.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.cafe;
package io.beaniejoy.dongnecafe.domain.cafe.dto.cafe;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.dto.cafe;
package io.beaniejoy.dongnecafe.domain.cafe.dto.cafe;
import io.beaniejoy.dongnecafe.cafe.dto.menu.CafeMenuListResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.CafeMenuListResponseDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.cafe;
package io.beaniejoy.dongnecafe.domain.cafe.dto.cafe;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.cafe;
package io.beaniejoy.dongnecafe.domain.cafe.dto.cafe;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.menu;
package io.beaniejoy.dongnecafe.domain.cafe.dto.menu;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.menu;
package io.beaniejoy.dongnecafe.domain.cafe.dto.menu;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.menu;
package io.beaniejoy.dongnecafe.domain.cafe.dto.menu;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.dto.menu;
package io.beaniejoy.dongnecafe.domain.cafe.dto.menu;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.error;
package io.beaniejoy.dongnecafe.domain.cafe.error;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.error;
package io.beaniejoy.dongnecafe.domain.cafe.error;
import java.util.UUID;

View File

@@ -1,4 +1,4 @@
package io.beaniejoy.dongnecafe.cafe.error;
package io.beaniejoy.dongnecafe.domain.cafe.error;
import java.util.UUID;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.repository;
package io.beaniejoy.dongnecafe.domain.cafe.repository;
import io.beaniejoy.dongnecafe.cafe.domain.CafeMenu;
import io.beaniejoy.dongnecafe.domain.cafe.domain.CafeMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID;

View File

@@ -1,6 +1,6 @@
package io.beaniejoy.dongnecafe.cafe.repository;
package io.beaniejoy.dongnecafe.domain.cafe.repository;
import io.beaniejoy.dongnecafe.cafe.domain.Cafe;
import io.beaniejoy.dongnecafe.domain.cafe.domain.Cafe;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

View File

@@ -1,9 +1,9 @@
package io.beaniejoy.dongnecafe.cafe.service;
package io.beaniejoy.dongnecafe.domain.cafe.service;
import io.beaniejoy.dongnecafe.cafe.domain.CafeMenu;
import io.beaniejoy.dongnecafe.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.cafe.error.CafeMenuNotFoundException;
import io.beaniejoy.dongnecafe.cafe.repository.CafeMenuRepository;
import io.beaniejoy.dongnecafe.domain.cafe.domain.CafeMenu;
import io.beaniejoy.dongnecafe.domain.cafe.dto.menu.CafeMenuDetailResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.error.CafeMenuNotFoundException;
import io.beaniejoy.dongnecafe.domain.cafe.repository.CafeMenuRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@@ -1,11 +1,11 @@
package io.beaniejoy.dongnecafe.cafe.service;
package io.beaniejoy.dongnecafe.domain.cafe.service;
import io.beaniejoy.dongnecafe.cafe.domain.Cafe;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeInfoResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeSearchResponseDto;
import io.beaniejoy.dongnecafe.cafe.dto.cafe.CafeUpdateRequestDto;
import io.beaniejoy.dongnecafe.cafe.error.CafeNotFoundException;
import io.beaniejoy.dongnecafe.cafe.repository.CafeRepository;
import io.beaniejoy.dongnecafe.domain.cafe.domain.Cafe;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeInfoResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeSearchResponseDto;
import io.beaniejoy.dongnecafe.domain.cafe.dto.cafe.CafeUpdateRequestDto;
import io.beaniejoy.dongnecafe.domain.cafe.error.CafeNotFoundException;
import io.beaniejoy.dongnecafe.domain.cafe.repository.CafeRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;