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

hotfix: InitData 설정 및 기존 좌표 추출 로직 수정 #21

Open
wants to merge 1 commit into
base: develop
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Coordinate extractCoordinate(final Image image) throws IOException
return Coordinate.of(latitude, longitude);
}
} catch (ImageProcessingException e) {
throw new RuntimeException(e);
return Coordinate.empty();
}
return Coordinate.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package keepsake.ourmemory.application.repository;

import keepsake.ourmemory.domain.member.Member;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MemberRepository extends JpaRepository<Member, Long> {
}
42 changes: 42 additions & 0 deletions our-memory/src/main/java/keepsake/ourmemory/config/InitData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package keepsake.ourmemory.config;

import keepsake.ourmemory.application.repository.MemberRepository;
import keepsake.ourmemory.domain.member.Email;
import keepsake.ourmemory.domain.member.Member;
import keepsake.ourmemory.domain.member.MemberName;
import keepsake.ourmemory.domain.member.Password;
import keepsake.ourmemory.domain.member.PhoneNumber;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Profile({"dev", "prod"})
@RequiredArgsConstructor
public class InitData implements CommandLineRunner {
private final InitService initService;

@Override
public void run(final String... args) {
initService.init();
}

@Component
@RequiredArgsConstructor
private static class InitService {
private final MemberRepository memberRepository;

@Transactional
public void init() {
Member member = new Member(
new MemberName("아이크"),
new Email("[email protected]"),
new Password("아이크짱"),
new PhoneNumber("01012341234")
);
memberRepository.save(member);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public ResponseEntity<Map<String, String>> handleMethodArgumentNotValidException
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleUnexpectedException(Exception e) {
log.error("error from handleUnexpectedException = ", e);
ErrorResponse errorResponse = new ErrorResponse(e.getMessage());
return ResponseEntity.internalServerError().body(errorResponse);
ErrorResponse errorResponse = new ErrorResponse("서버에서 예상치 못한 문제가 발생했습니다.");
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(errorResponse);
}
}
22 changes: 15 additions & 7 deletions our-memory/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
spring:
datasource:
url: jdbc:h2:mem:testdb;MODE=MySQL
h2:
console:
enabled: true
spring: # 전체 공통 설정
profiles:
active: dev # 기본 프로파일을 dev로 설정
jpa:
show-sql: true
hibernate:
ddl-auto: create
properties:
Expand All @@ -16,11 +14,21 @@ spring:
multipart:
maxFileSize: 10MB
maxRequestSize: 20MB
---
spring: # dev 프로파일에만 적용할 설정
config:
activate:
on-profile: dev
datasource:
url: jdbc:h2:mem:testdb;MODE=MySQL
h2:
console:
enabled: true
image:
directory-path: src/main/resources/static/images/
web-uri: localhost:8080/images/
---
spring:
spring: # prod 프로파일에만 적용할 설정
config:
activate:
on-profile: prod
Expand Down