Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9주차미션_제리 #20

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions 제리_신초은/week7/carrot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' //지금 사용X
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'junit:junit:4.13.1'
implementation 'org.springframework.boot:spring-boot-starter-validation'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'com.mysql:mysql-connector-j'
// implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' //지금 사용X
// testImplementation 'junit:junit:4.13.1'
// runtimeOnly 'com.h2database:h2'
// runtimeOnly 'com.mysql:mysql-connector-j'
// implementation 'com.mysql:mysql-connector-j'
//검증 validation
// implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '3.1.0'
implementation 'org.springframework.boot:spring-boot-starter-validation'
}

tasks.named('test') {
Expand Down
10 changes: 5 additions & 5 deletions 제리_신초은/week7/carrot/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/umc_week7_carrot
username: sa
password:
driver-class-name: org.h2.Driver
url: jdbc:mariadb://choeun-database-1.ccfgdtrf5skz.ap-northeast-2.rds.amazonaws.com:3306/carrot
username: admin
password: short0720
driver-class-name: org.mariadb.jdbc.Driver
output:
ansi:
enabled: always

jpa:
hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
# show_sql: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
//@SpringBootTest
class CarrotApplicationTests {

@Test
void contextLoads() {
}
// @Test
// void contextLoads() {
// }

}
3 changes: 3 additions & 0 deletions 제리_신초은/week8/naver/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ out/

### VS Code ###
.vscode/

### API KEY ###
resource/application-API-KEY.properties
1 change: 1 addition & 0 deletions 제리_신초은/week8/naver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//JSON
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
implementation 'org.springframework.boot:spring-boot-starter-validation'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package umc.naver.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import umc.naver.dto.NaverPlaceDto;
import umc.naver.dto.NaverRequestVariableDto;
import umc.naver.service.NaverPlaceService;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequiredArgsConstructor
public class NaverPlaceController {

private final NaverPlaceService naverPlaceService;

//물건 등록
@PostMapping("/search")
public ResponseEntity<Map<String, Object>> createProduct(@RequestBody NaverRequestVariableDto requestDto) throws IOException {
List<NaverPlaceDto> naverPlaceDtos = naverPlaceService.naverMapSearchAPI(requestDto);

Map<String, Object> result = new HashMap<>();
result.put("place", naverPlaceDtos);
result.put("count", naverPlaceDtos.size());

return ResponseEntity.ok().body(result);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package umc.naver.domain;

import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
public class PlaceInfo {

private String lastBuildDate;

private int total;

private int start;

private int display;

private List<Places> items;

@Builder
public PlaceInfo(String lastBuildDate, int total, int start, int display, List<Places> items) {
this.lastBuildDate = lastBuildDate;
this.total = total;
this.start = start;
this.display = display;
this.items = items;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package umc.naver.domain;

import lombok.Builder;
import lombok.Data;

@Data
public class Places {

private String title;

private String link;

private String category;

private String description;

private String telephone;

private String address;

private String roadAddress;

private String mapx;

private String mapy;

@Builder
public Places(String title, String link, String category, String description, String telephone, String address, String roadAddress, String mapx, String mapy) {
this.title = title;
this.link = link;
this.category = category;
this.description = description;
this.telephone = telephone;
this.address = address;
this.roadAddress = roadAddress;
this.mapx = mapx;
this.mapy = mapy;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package umc.naver.dto;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class NaverPlaceDto {

private String title;
private String link;
private String address;
private String roadAddress;

@Builder
public NaverPlaceDto(String title, String link, String address, String roadAddress) {
this.title = title;
this.link = link;
this.address = address;
this.roadAddress = roadAddress;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package umc.naver.dto;

import lombok.Data;

@Data
//Naver API 요청
public class NaverRequestVariableDto {

String query;
Integer display;
Integer start;
String sort;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package umc.naver.error;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ErrorCode { //Enum 타입

// Product
INTERNAL_SERVER_ERROR(500, "P001", "internal server error"),
INVALID_INPUT_VALUE(400, "P002", "invalid input type"),
METHOD_NOT_ALLOWED(405, "P003", "method not allowed"),
INVALID_TYPE_VALUE(400, "P004", "invalid type value"),
PRODUCT_NOT_EXIST(404, "P005", "product not exist"),

// User
USER_NOT_EXIST(404, "M001", "user not exist"),
USER_EMAIL_ALREADY_EXISTS(400, "M002", "user email already exists"),

// API
ENCODING_FAILED(404,"A001","unsupported encoding");

private int status;
private final String code;
private final String message;
}
Loading