-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ghojeong/feature/be/mock-api
[BE] 모킹한 데이터로 API 완성
- Loading branch information
Showing
21 changed files
with
627 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Backend | ||
|
||
백엔드를 위한 디렉토리 | ||
|
||
## API 배포 링크 | ||
|
||
http://3.37.26.82:8080/swagger-ui.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
plugins { | ||
id 'org.springframework.boot' version '2.4.5' | ||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | ||
id 'java' | ||
id 'org.springframework.boot' version '2.4.5' | ||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | ||
id 'java' | ||
} | ||
|
||
group = 'com.codesquad.sidedish' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
developmentOnly 'org.springframework.boot:spring-boot-devtools' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
runtimeOnly 'mysql:mysql-connector-java' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
developmentOnly 'org.springframework.boot:spring-boot-devtools' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
runtimeOnly 'mysql:mysql-connector-java' | ||
|
||
// swagger | ||
implementation 'io.springfox:springfox-swagger2:2.9.2' | ||
implementation 'io.springfox:springfox-swagger-ui:2.9.2' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.codesquad.sidedish.SideDish.controller; | ||
|
||
import com.codesquad.sidedish.SideDish.exception.DishNotFoundException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class DishExceptionHandler { | ||
private final Logger logger = LoggerFactory.getLogger(DishExceptionHandler.class); | ||
|
||
@ExceptionHandler(DishNotFoundException.class) | ||
public ResponseEntity handleDishNotFound(DishNotFoundException e) { | ||
logger.error(e.getMessage()); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("존재하지 않는 Dish 입니다."); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Category.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.codesquad.sidedish.SideDish.domain; | ||
|
||
public class Category { | ||
private final long id; | ||
private final String categoryName; | ||
private final String endPoint; | ||
|
||
public Category(long id, String categoryName, String endPoint) { | ||
this.id = id; | ||
this.categoryName = categoryName; | ||
this.endPoint = endPoint; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public String getCategoryName() { | ||
return categoryName; | ||
} | ||
|
||
public String getEndPoint() { | ||
return endPoint; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryMockRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.codesquad.sidedish.SideDish.domain; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CategoryMockRepository implements CategoryRepository { | ||
private final List<Category> categories = Arrays.asList( | ||
new Category(1, "모두가 좋아하는 든든한 메인요리", "/main"), | ||
new Category(2, "뜨끈하고 시원한 국물요리", "/soup"), | ||
new Category(3, "밥도둑이 여기있다! 반찬요리", "/side") | ||
); | ||
|
||
@Override | ||
public List<Category> findAll() { | ||
return categories; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.codesquad.sidedish.SideDish.domain; | ||
|
||
import java.util.List; | ||
|
||
public interface CategoryRepository { | ||
List<Category> findAll(); | ||
} |
Oops, something went wrong.