diff --git a/daemawiki-api/src/main/resources/application.yml b/daemawiki-api/src/main/resources/application.yml index 3fa4ed2d..2371c8b7 100644 --- a/daemawiki-api/src/main/resources/application.yml +++ b/daemawiki-api/src/main/resources/application.yml @@ -34,11 +34,4 @@ cloud: region: static: ap-northeast-2 stack: - auto: false - -profile: - image: - url: ${DEFAULT_PROFILE_IMAGE} - id: ${DEFAULT_PROFILE_ID} - name: ${DEFAULT_PROFILE_NAME} - type: ${DEFAULT_PROFILE_TYPE} \ No newline at end of file + auto: false \ No newline at end of file diff --git a/daemawiki-service/src/main/java/org/daemawiki/config/DefaultProfileConfig.java b/daemawiki-service/src/main/java/org/daemawiki/config/DefaultProfileConfig.java new file mode 100644 index 00000000..7d57f70e --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/config/DefaultProfileConfig.java @@ -0,0 +1,35 @@ +package org.daemawiki.config; + +import lombok.Getter; +import org.daemawiki.domain.file.model.File; +import org.daemawiki.domain.file.model.FileDetail; +import org.daemawiki.domain.file.model.type.FileType; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Getter +@Component +@ConfigurationProperties(prefix = "profile.image") +public class DefaultProfileConfig { + private String url; + private UUID id; + private String name; + private String type; + + public final File defaultUserProfile() { + return File.create(id, + name, + type, + FileDetail.create(FileType.PROFILE, url)); + } + + public final File defaultDocumentImage() { + return File.create(id, + name, + type, + FileDetail.create(FileType.DOCUMENT, url)); + } + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/service/SignupService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/service/SignupService.java index c465a37a..50f307e3 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/service/SignupService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/service/SignupService.java @@ -1,8 +1,8 @@ package org.daemawiki.domain.auth.usecase.service; +import org.daemawiki.config.DefaultProfileConfig; import org.daemawiki.domain.auth.dto.request.SignupRequest; import org.daemawiki.domain.auth.usecase.SignupUsecase; -import org.daemawiki.domain.common.DefaultProfile; import org.daemawiki.domain.document.usecase.CreateDocumentUsecase; import org.daemawiki.domain.mail.application.mail.DeleteAuthMailPort; import org.daemawiki.domain.mail.application.mail.GetAuthMailPort; @@ -27,9 +27,9 @@ public class SignupService implements SignupUsecase { private final PasswordEncoder passwordEncoder; private final GetMajorType getMajorType; private final CreateDocumentUsecase createDocumentUsecase; - private final DefaultProfile defaultProfile; + private final DefaultProfileConfig defaultProfile; - public SignupService(GetUserPort getUserPort, SaveUserPort saveUserPort, GetAuthMailPort getAuthMailPort, DeleteAuthMailPort deleteAuthMailPort, PasswordEncoder passwordEncoder, GetMajorType getMajorType, CreateDocumentUsecase createDocumentUsecase, DefaultProfile defaultProfile) { + public SignupService(GetUserPort getUserPort, SaveUserPort saveUserPort, GetAuthMailPort getAuthMailPort, DeleteAuthMailPort deleteAuthMailPort, PasswordEncoder passwordEncoder, GetMajorType getMajorType, CreateDocumentUsecase createDocumentUsecase, DefaultProfileConfig defaultProfile) { this.getUserPort = getUserPort; this.saveUserPort = saveUserPort; this.getAuthMailPort = getAuthMailPort; @@ -90,7 +90,7 @@ private Mono createUser(SignupRequest request, String password) { .name(request.name()) .email(request.email()) .password(password) - .profile(defaultProfile.defaultProfile()) + .profile(defaultProfile.defaultUserProfile()) .detail(UserDetail.builder() .gen(request.gen()) .major(getMajorType.execute(request.major().toLowerCase())) diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfile.java b/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfile.java deleted file mode 100644 index c58fe92b..00000000 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfile.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.daemawiki.domain.common; - -import org.daemawiki.domain.file.model.File; - -public interface DefaultProfile { - File defaultProfile(); - File defaultDocumentImage(); - -} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfileImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfileImpl.java deleted file mode 100644 index e5ff110b..00000000 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/common/DefaultProfileImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.daemawiki.domain.common; - -import org.daemawiki.domain.file.model.File; -import org.daemawiki.domain.file.model.FileDetail; -import org.daemawiki.domain.file.model.type.FileType; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.util.UUID; - -@Component -public class DefaultProfileImpl implements DefaultProfile { - - @Value("${profile.image.url}") - private String defaultImageURL; - - @Value("${profile.image.id}") - private UUID defaultImageId; - - @Value("${profile.image.name}") - private String defaultImageName; - - @Value("${profile.image.type}") - private String defaultImageType; - - @Override - public final File defaultProfile() { - return File.create(defaultImageId, - defaultImageName, - defaultImageType, - FileDetail.create(FileType.PROFILE, defaultImageURL)); - } - - @Override - public final File defaultDocumentImage() { - return File.create(defaultImageId, - defaultImageName, - defaultImageType, - FileDetail.create(FileType.DOCUMENT, defaultImageURL)); - } - -} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java index c33e785e..05f20ed9 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java @@ -1,7 +1,7 @@ package org.daemawiki.domain.document.component.facade; +import org.daemawiki.config.DefaultProfileConfig; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.common.DefaultProfile; import org.daemawiki.domain.content.model.Content; import org.daemawiki.domain.document.dto.request.SaveDocumentRequest; import org.daemawiki.domain.document.model.DefaultDocument; @@ -20,9 +20,9 @@ @Component public class CreateDocumentFacadeImpl implements CreateDocumentFacade{ - private final DefaultProfile defaultProfile; + private final DefaultProfileConfig defaultProfile; - public CreateDocumentFacadeImpl(DefaultProfile defaultProfile) { + public CreateDocumentFacadeImpl(DefaultProfileConfig defaultProfile) { this.defaultProfile = defaultProfile; } diff --git a/daemawiki-service/src/main/resources/application.yml b/daemawiki-service/src/main/resources/application.yml new file mode 100644 index 00000000..30949ea3 --- /dev/null +++ b/daemawiki-service/src/main/resources/application.yml @@ -0,0 +1,6 @@ +profile: + image: + url: ${DEFAULT_PROFILE_IMAGE} + id: ${DEFAULT_PROFILE_ID} + name: ${DEFAULT_PROFILE_NAME} + type: ${DEFAULT_PROFILE_TYPE} \ No newline at end of file