Skip to content

Commit

Permalink
[CHORE] 병합 및 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Jun 18, 2024
2 parents a664b7f + 158ad5c commit 71365f2
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.smeem.domain.member.adapter.member.MemberDeleter;
import com.smeem.domain.member.adapter.member.MemberFinder;
import com.smeem.domain.member.adapter.member.MemberSaver;
import com.smeem.domain.visit.adapter.VisitDeleter;
import com.smeem.external.oauth.exception.TokenException;
import com.smeem.domain.member.model.Member;
import com.smeem.domain.member.model.SocialType;
Expand All @@ -19,9 +20,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import static com.smeem.common.code.failure.AuthFailureCode.INVALID_TOKEN;
import static java.util.Objects.nonNull;

Expand All @@ -34,6 +32,7 @@ public class AuthService {
private final MemberSaver memberSaver;
private final MemberDeleter memberDeleter;
private final DiaryDeleter diaryDeleter;
private final VisitDeleter visitDeleter;

private final TokenService tokenService;
private final AppleService appleService;
Expand All @@ -42,7 +41,7 @@ public class AuthService {
private final TrainingTimeService trainingTimeService;

@Transactional
public SignInServiceResponse signIn(final String socialAccessToken, final SignInServiceRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException {
public SignInServiceResponse signIn(final String socialAccessToken, final SignInServiceRequest request) {
val socialType = request.socialType();
val socialId = socialLogin(socialType, socialAccessToken);
val existMember = isMemberBySocialAndSocialId(socialType, socialId);
Expand Down Expand Up @@ -71,6 +70,7 @@ public void withdraw(final long memberId) {
trainingTimeService.deleteAllByMember(member);
memberBadgeService.deleteAllByMember(member);
memberDeleter.deleteById(memberId);
visitDeleter.deleteByMember(member);
}

private Member getMemberBySocialAndSocialId(final SocialType socialType, final String socialId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
public record ClientVersionGetResponse(
String title,
String content,
VersionResponse iosVersion
VersionResponse iosVersion,
VersionResponse androidVersion
) {

public static ClientVersionGetResponse of(ClientVersionGetServiceResponse response) {
return ClientVersionGetResponse.builder()
.title(response.title())
.content(response.content())
.iosVersion(VersionResponse.of(response.iosVersion(), response.iosForceVersion()))
.androidVersion(VersionResponse.of(response.androidVersion(), response.androidForceVersion()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public record ClientVersionGetServiceResponse(
String title,
String content,
String iosVersion,
String iosForceVersion
String iosForceVersion,
String androidVersion,
String androidForceVersion
) {

public static ClientVersionGetServiceResponse of(ValueConfig valueConfig) {
Expand All @@ -19,6 +21,8 @@ public static ClientVersionGetServiceResponse of(ValueConfig valueConfig) {
.content(valueConfig.getCLIENT_VERSION_UPDATE_CONTENT())
.iosVersion(valueConfig.getCLIENT_VERSION_IOS_VERSION())
.iosForceVersion(valueConfig.getCLIENT_VERSION_IOS_FORCE_VERSION())
.androidVersion(valueConfig.getCLIENT_VERSION_ANDROID_VERSION())
.androidVersion(valueConfig.getCLIENT_VERSION_ANDROID_FORCE_VERSION())
.build();
}
}
5 changes: 4 additions & 1 deletion smeem-api/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ smeem:
title: "업데이트 알림"
content: "보다 나아진 스밈의 최신 버전을 준비했어요! 새로운 버전으로 업데이트 후 이용해주세요."
ios:
app: 2.0.2
force: 3.0.0
android:
app: 2.0.0
force: 2.0.0
notification:
Expand All @@ -63,4 +66,4 @@ sentry:
dsn: ${SENTRY.DSN}
environment: dev
enable-tracing: true
exception-resolver-order: -2147483647
exception-resolver-order: -2147483647
9 changes: 6 additions & 3 deletions smeem-api/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ smeem:
title: "업데이트 알림"
content: "보다 나아진 스밈의 최신 버전을 준비했어요! 새로운 버전으로 업데이트 후 이용해주세요."
ios:
app: 2.0.1
force: 2.0.0 # 심사 통과 후 3.0.0 업데이트 필요
app: 2.0.2
force: 3.0.0
android:
app: 2.0.0
force: 2.0.0
notification:
title: "오늘의 영어 훈련, 딱 5분 걸려요!"
body: "지금 눌러서 일기 쓰기 ✍️"
Expand All @@ -64,4 +67,4 @@ sentry:
dsn: ${SENTRY.DSN}
environment: prod
enable-tracing: true
exception-resolver-order: -2147483647
exception-resolver-order: -2147483647
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.smeem.diary.service;

import com.smeem.api.diary.service.DiaryCommandService;
import com.smeem.api.diary.service.dto.request.DiaryModifyServiceRequest;
import com.smeem.domain.diary.adapter.DiaryFinder;
import com.smeem.support.fixture.DiaryFixture;
import lombok.val;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;

@ExtendWith(MockitoExtension.class)
public class DiaryCommandServiceTest {

@InjectMocks
private DiaryCommandService diaryService;

@Mock
private DiaryFinder diaryFinder;

@Test
@DisplayName("[성공] 유효한 일기를 수정할 수 있다.")
void modifyValidDiary() {
// given
val contentBeforeModified = "content";
val contentAfterModified = "modifiedContent";
val diary = DiaryFixture.diary().id(1L).content(contentBeforeModified).build();
val request = new DiaryModifyServiceRequest(diary.getId(), contentAfterModified);

doReturn(diary).when(diaryFinder).findById(diary.getId());

// when
diaryService.modifyDiary(request);

// then
assertThat(diary.getContent()).isEqualTo(contentAfterModified);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smeem.diary.service;
package com.smeem.diary.service.integration;

import com.smeem.api.diary.service.DiaryCommandService;
import com.smeem.api.diary.service.dto.request.DiaryCreateServiceRequest;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class DiaryCommandServiceIntegrationTest extends ServiceIntegrationTest {

@Nested
@DisplayName("일기 저장 테스트")
class SaveTest {
class SaveDiaryTest {

private Member member;
private final String diaryContent = "test-diary-content";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.smeem.goal.service;

import com.smeem.api.goal.service.GoalService;
import com.smeem.api.goal.service.dto.request.GoalGetServiceRequest;
import com.smeem.api.goal.service.dto.response.GoalGetServiceResponse;
import com.smeem.domain.goal.model.Goal;
import com.smeem.domain.goal.model.GoalType;
import com.smeem.domain.goal.repository.GoalRepository;
import com.smeem.support.ServiceIntegrationTest;
import com.smeem.support.fixture.GoalFixture;
import lombok.val;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class GoalServiceIntegrationTest extends ServiceIntegrationTest {

@Autowired
GoalService goalService;

@Autowired
GoalRepository goalRepository;

@AfterEach
void tearDown() {
goalRepository.deleteAllInBatch();
}

@Test
@DisplayName("[성공] 모든 학습 목표를 조회할 수 있다.")
void getAllGoals() throws Exception {
// given
val goal1 = GoalFixture.goal().type(GoalType.DEVELOP).build();
val goal2 = GoalFixture.goal().type(GoalType.APPLY).build();
val goal3 = GoalFixture.goal().type(GoalType.BUSINESS).build();
val goal4 = GoalFixture.goal().type(GoalType.EXAM).build();
val goal5 = GoalFixture.goal().type(GoalType.NONE).build();
val goal6 = GoalFixture.goal().type(GoalType.HOBBY).build();
goalRepository.saveAll(List.of(goal1, goal2, goal3, goal4, goal5, goal6));

// when
val response = goalService.getAllGoals();

// then
Assertions.assertThat(response.goals())
.extracting("goalType", "goalDescription")
.containsExactlyInAnyOrder(
Assertions.tuple(GoalType.DEVELOP.name(), GoalType.DEVELOP.getDescription()),
Assertions.tuple(GoalType.APPLY.name(), GoalType.APPLY.getDescription()),
Assertions.tuple(GoalType.EXAM.name(), GoalType.EXAM.getDescription()),
Assertions.tuple(GoalType.BUSINESS.name(), GoalType.BUSINESS.getDescription()),
Assertions.tuple(GoalType.NONE.name(), GoalType.NONE.getDescription()),
Assertions.tuple(GoalType.HOBBY.name(), GoalType.HOBBY.getDescription())
);
}

@Test
@DisplayName("[성공] 학습 목표 유형으로 학습 목표를 조회할 수 있다.")
void getByType() throws Exception {
// given

goalRepository.save(GoalFixture.goal().type(GoalType.DEVELOP).build());

val request = GoalGetServiceRequest.of(GoalType.DEVELOP);

// when
final GoalGetServiceResponse response = goalService.getByType(request);

// then
Assertions.assertThat(response)
.extracting("goalType", "way", "detail")
.containsExactly(GoalType.DEVELOP, "test-goal-way", "test-goal-detail");

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.smeem.support.fixture;

import com.smeem.domain.diary.model.Diary;
import com.smeem.domain.member.model.LangType;
import lombok.NoArgsConstructor;

import static com.smeem.domain.member.model.LangType.en;
import static lombok.AccessLevel.PRIVATE;

@NoArgsConstructor(access = PRIVATE)
public class DiaryFixture {

private Long id;
private String content;
private final LangType targetLang = en;
private final boolean isPublic = false;

public static DiaryFixture diary() {
return new DiaryFixture();
}

public DiaryFixture id(Long id) {
this.id = id;
return this;
}

public DiaryFixture content(String content) {
this.content = content;
return this;
}

public Diary build() {
return new Diary(id, content, targetLang, isPublic);
}
}
30 changes: 30 additions & 0 deletions smeem-api/src/test/java/com/smeem/support/fixture/GoalFixture.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.smeem.support.fixture;

import com.smeem.domain.goal.model.Goal;
import com.smeem.domain.goal.model.GoalType;

public class GoalFixture {

private GoalType type;

private String way = "test-goal-way";
private String detail = "test-goal-detail";

public static GoalFixture goal() {
return new GoalFixture();
}

public GoalFixture type(GoalType type) {
this.type = type;
return this;
}

public Goal build() {
return Goal.builder()
.type(type)
.way(way)
.detail(detail)
.build();
}

}
5 changes: 4 additions & 1 deletion smeem-api/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ smeem:
ios:
app: 2.0.0
force: 2.0.0
android:
app: 2.0.0
force: 2.0.0
notification:
title: "오늘의 영어 훈련, 딱 5분 걸려요!"
body: "지금 눌러서 일기 쓰기 ✍️"
Expand All @@ -64,4 +67,4 @@ smeem:
discord:
webhook:
error-url: ${DISCORD.WEBHOOK_ERROR_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public class ValueConfig {
@Value("${smeem.client.version.ios.force}")
private String CLIENT_VERSION_IOS_FORCE_VERSION;

@Value("${smeem.client.version.android.app}")
private String CLIENT_VERSION_ANDROID_VERSION;

@Value("${smeem.client.version.android.force}")
private String CLIENT_VERSION_ANDROID_FORCE_VERSION;

public static final String SIGN_IN_MESSAGE = "새로운 유저 %s 가 가입했습니다! ✍️ \n 현재 회원 수: %d 명";

public static final boolean DEFAULT_IS_PUBLIC_VALUE = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public Diary(String content, Member member) {
setMember(member);
}

public Diary(Long id, String content, LangType targetLang, boolean isPublic) {
this.id = id;
this.content = content;
this.targetLang = targetLang;
this.isPublic = isPublic;
}

public void updateContent(String content) {
this.content = content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.smeem.domain.visit.adapter;

import com.smeem.domain.member.model.Member;
import com.smeem.domain.support.RepositoryAdapter;
import com.smeem.domain.visit.repository.VisitRepository;
import lombok.RequiredArgsConstructor;

@RepositoryAdapter
@RequiredArgsConstructor
public class VisitDeleter {

private final VisitRepository visitRepository;

public void deleteByMember(Member member) {
visitRepository.deleteByMember(member);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface VisitRepository extends JpaRepository<Visit, Long> {

boolean existsByMemberAndVisitedAtBetween(Member member, LocalDateTime start, LocalDateTime end);
int countByMember(Member member);
void deleteByMember(Member member);
}

0 comments on commit 71365f2

Please sign in to comment.