Skip to content

Commit 5890ed1

Browse files
authored
[#28] hotfix: 생일 미저장, push 알림 동의 삭제 (#29)
* fix: push 알림 동의 삭제, 생일 저장하도록 fix * fix: image url 노출 변경
1 parent 44972ba commit 5890ed1

File tree

13 files changed

+40
-62
lines changed

13 files changed

+40
-62
lines changed

src/main/java/com/tnt/application/member/MemberService.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.tnt.application.member;
22

3-
import static com.tnt.domain.constant.Constant.*;
4-
import static com.tnt.global.error.model.ErrorMessage.*;
5-
import static io.hypersistence.tsid.TSID.Factory.*;
6-
import static io.micrometer.common.util.StringUtils.*;
3+
import static com.tnt.domain.constant.Constant.TRAINEE;
4+
import static com.tnt.domain.constant.Constant.TRAINEE_DEFAULT_IMAGE;
5+
import static com.tnt.domain.constant.Constant.TRAINER;
6+
import static com.tnt.domain.constant.Constant.TRAINER_DEFAULT_IMAGE;
7+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_CONFLICT;
8+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_NOT_FOUND;
9+
import static com.tnt.global.error.model.ErrorMessage.UNSUPPORTED_MEMBER_TYPE;
10+
import static io.hypersistence.tsid.TSID.Factory.getTsid;
11+
import static io.micrometer.common.util.StringUtils.isNotBlank;
712

813
import java.util.List;
914

@@ -77,10 +82,10 @@ private Member createMember(SignUpRequest request, String defaultImageUrl) {
7782
.email(request.socialEmail())
7883
.name(request.name())
7984
.profileImageUrl(defaultImageUrl)
85+
.birthday(request.birthday())
8086
.serviceAgreement(request.serviceAgreement())
8187
.collectionAgreement(request.collectionAgreement())
8288
.advertisementAgreement(request.advertisementAgreement())
83-
.pushAgreement(request.pushAgreement())
8489
.socialType(SocialType.valueOf(request.socialType()))
8590
.build();
8691

src/main/java/com/tnt/domain/constant/Constant.java

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class Constant {
1212
public static final String TRAINEE = "trainee";
1313
public static final String TRAINER_DEFAULT_IMAGE = "https://images.tntapp.co.kr/profiles/trainers/basic_profile_trainer.svg";
1414
public static final String TRAINEE_DEFAULT_IMAGE = "https://images.tntapp.co.kr/profiles/trainees/basic_profile_trainee.svg";
15+
public static final String IMAGE_BASE_URL = "https://images.tntapp.co.kr/";
1516
public static final String TRAINER_S3_PROFILE_PATH = "profiles/trainers";
1617
public static final String TRAINEE_S3_PROFILE_PATH = "profiles/trainees";
1718
}

src/main/java/com/tnt/domain/member/Member.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.tnt.domain.member;
22

3-
import static com.tnt.global.error.model.ErrorMessage.*;
3+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_COLLECTION_AGREEMENT;
4+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_EMAIL;
5+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_NAME;
6+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_PROFILE_IMAGE_URL;
7+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_SERVICE_AGREEMENT;
8+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_SOCIAL_ID;
9+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_INVALID_SOCIAL_TYPE;
10+
import static com.tnt.global.error.model.ErrorMessage.MEMBER_NULL_ADVERTISEMENT_AGREEMENT;
411
import static io.micrometer.common.util.StringUtils.isBlank;
512
import static java.lang.Boolean.FALSE;
613
import static java.util.Objects.isNull;
@@ -67,9 +74,6 @@ public class Member extends BaseTimeEntity {
6774
@Column(name = "advertisement_agreement", nullable = false)
6875
private Boolean advertisementAgreement;
6976

70-
@Column(name = "push_agreement", nullable = false)
71-
private Boolean pushAgreement;
72-
7377
@Column(name = "deleted_at", nullable = true)
7478
private LocalDateTime deletedAt;
7579

@@ -80,7 +84,7 @@ public class Member extends BaseTimeEntity {
8084
@Builder
8185
public Member(Long id, String socialId, String fcmToken, String email, String name, String profileImageUrl,
8286
LocalDate birthday, Boolean serviceAgreement, Boolean collectionAgreement, Boolean advertisementAgreement,
83-
Boolean pushAgreement, SocialType socialType) {
87+
SocialType socialType) {
8488
validateRequiredAgreements(serviceAgreement, collectionAgreement);
8589

8690
this.id = id;
@@ -94,7 +98,6 @@ public Member(Long id, String socialId, String fcmToken, String email, String na
9498
this.collectionAgreement = collectionAgreement;
9599
this.advertisementAgreement = requireNonNull(advertisementAgreement,
96100
MEMBER_NULL_ADVERTISEMENT_AGREEMENT.getMessage());
97-
this.pushAgreement = requireNonNull(pushAgreement, MEMBER_NULL_PUSH_AGREEMENT.getMessage());
98101
this.socialType = validateSocialType(socialType);
99102
}
100103

src/main/java/com/tnt/dto/member/request/SignUpRequest.java

-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public record SignUpRequest(
4646
@NotNull(message = "광고성 알림 수신 동의 여부는 필수입니다.")
4747
Boolean advertisementAgreement,
4848

49-
@Schema(description = "푸쉬 알림 수신 동의 여부", example = "true", nullable = false)
50-
@NotNull(message = "푸쉬 알림 수신 동의 여부는 필수입니다.")
51-
Boolean pushAgreement,
52-
5349
@Schema(description = "회원 이름", example = "홍길동", nullable = false)
5450
@NotBlank(message = "회원 이름은 필수입니다.")
5551
String name,

src/main/java/com/tnt/infrastructure/s3/S3Adapter.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tnt.infrastructure.s3;
22

3+
import static com.tnt.domain.constant.Constant.IMAGE_BASE_URL;
34
import static com.tnt.global.error.model.ErrorMessage.S3_UPLOAD_ERROR;
45

56
import org.springframework.beans.factory.annotation.Value;
@@ -11,7 +12,6 @@
1112
import lombok.RequiredArgsConstructor;
1213
import software.amazon.awssdk.core.sync.RequestBody;
1314
import software.amazon.awssdk.services.s3.S3Client;
14-
import software.amazon.awssdk.services.s3.model.GetUrlRequest;
1515
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
1616
import software.amazon.awssdk.services.s3.model.S3Exception;
1717

@@ -37,18 +37,9 @@ public String uploadFile(byte[] fileData, String folderPath, String extension) {
3737

3838
s3Client.putObject(request, RequestBody.fromBytes(fileData));
3939

40-
return getUrl(s3Key);
40+
return IMAGE_BASE_URL + s3Key;
4141
} catch (S3Exception e) {
4242
throw new ImageException(S3_UPLOAD_ERROR, e);
4343
}
4444
}
45-
46-
private String getUrl(String key) {
47-
GetUrlRequest urlRequest = GetUrlRequest.builder()
48-
.bucket(bucketName)
49-
.key(key)
50-
.build();
51-
52-
return s3Client.utilities().getUrl(urlRequest).toString();
53-
}
5445
}

src/test/java/com/tnt/application/member/MemberServiceTest.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,16 @@ private Member createMockMember(Long id, String profileImageUrl) {
7979
.serviceAgreement(true)
8080
.collectionAgreement(true)
8181
.advertisementAgreement(true)
82-
.pushAgreement(true)
8382
.socialType(SocialType.KAKAO)
8483
.build();
8584
}
8685

8786
@BeforeEach
8887
void setUp() {
8988
trainerRequest = new SignUpRequest(MOCK_FCM_TOKEN, TRAINER, "KAKAO", MOCK_SOCIAL_ID, MOCK_EMAIL, true, true,
90-
true, true, MOCK_NAME, null, null, null, null, null);
89+
true, MOCK_NAME, null, null, null, null, null);
9190
traineeRequest = new SignUpRequest(MOCK_FCM_TOKEN, TRAINEE, "KAKAO", MOCK_SOCIAL_ID, MOCK_EMAIL, true, true,
92-
true, true, MOCK_NAME, null, 180.0, 75.0, MOCK_CAUTION, MOCK_GOALS);
91+
true, MOCK_NAME, null, 180.0, 75.0, MOCK_CAUTION, MOCK_GOALS);
9392

9493
mockTrainerMember = createMockMember(1L, TRAINER_DEFAULT_IMAGE);
9594
mockTraineeMember = createMockMember(2L, TRAINEE_DEFAULT_IMAGE);
@@ -169,7 +168,7 @@ void save_member_already_exists_fail() {
169168
void save_member_unsupported_type_fail() {
170169
// given
171170
SignUpRequest invalidRequest = new SignUpRequest(MOCK_FCM_TOKEN, "invalid_type", "KAKAO", MOCK_SOCIAL_ID,
172-
MOCK_EMAIL, true, true, true, true, MOCK_NAME, null, null, null, null, null);
171+
MOCK_EMAIL, true, true, true, MOCK_NAME, null, null, null, null, null);
173172

174173
// when & then
175174
assertThrows(IllegalArgumentException.class, () -> memberService.signUp(invalidRequest));

src/test/java/com/tnt/application/trainer/TrainerServiceTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void get_invitation_code_success() {
5454
.serviceAgreement(true)
5555
.collectionAgreement(true)
5656
.advertisementAgreement(true)
57-
.pushAgreement(true)
5857
.socialType(SocialType.KAKAO)
5958
.build();
6059

@@ -108,7 +107,6 @@ void reissue_invitation_code_success() {
108107
.serviceAgreement(true)
109108
.collectionAgreement(true)
110109
.advertisementAgreement(true)
111-
.pushAgreement(true)
112110
.socialType(SocialType.KAKAO)
113111
.build();
114112

@@ -152,7 +150,6 @@ void verify_invitation_code_success() {
152150
.serviceAgreement(true)
153151
.collectionAgreement(true)
154152
.advertisementAgreement(true)
155-
.pushAgreement(true)
156153
.socialType(SocialType.KAKAO)
157154
.build();
158155

src/test/java/com/tnt/domain/member/MemberIntegrationTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void save_member_to_db_success() {
3333
.serviceAgreement(true)
3434
.collectionAgreement(true)
3535
.advertisementAgreement(true)
36-
.pushAgreement(true)
3736
.socialType(SocialType.KAKAO)
3837
.build();
3938

src/test/java/com/tnt/domain/member/MemberTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void create_member_success() {
4040
.serviceAgreement(true)
4141
.collectionAgreement(true)
4242
.advertisementAgreement(true)
43-
.pushAgreement(true)
4443
.socialType(SocialType.KAKAO)
4544
.build();
4645

@@ -65,7 +64,6 @@ void verify_tsid_duplication_success() {
6564
.serviceAgreement(true)
6665
.collectionAgreement(true)
6766
.advertisementAgreement(true)
68-
.pushAgreement(true)
6967
.socialType(SocialType.KAKAO)
7068
.build())
7169
.map(Member::getId)
@@ -95,7 +93,6 @@ void verify_tsid_timestamp_success() {
9593
.serviceAgreement(true)
9694
.collectionAgreement(true)
9795
.advertisementAgreement(true)
98-
.pushAgreement(true)
9996
.socialType(SocialType.KAKAO)
10097
.build();
10198
TSID tsid = TSID.from(member.getId());
@@ -120,7 +117,6 @@ void update_fcm_token_success() {
120117
.serviceAgreement(true)
121118
.collectionAgreement(true)
122119
.advertisementAgreement(true)
123-
.pushAgreement(true)
124120
.socialType(SocialType.KAKAO)
125121
.build();
126122

src/test/java/com/tnt/fixture/MemberFixture.java

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public static Member getMember1() {
2525
.serviceAgreement(true)
2626
.collectionAgreement(true)
2727
.advertisementAgreement(true)
28-
.pushAgreement(true)
2928
.socialType(SocialType.KAKAO)
3029
.build();
3130
}
@@ -48,7 +47,6 @@ public static Member getMember2() {
4847
.serviceAgreement(true)
4948
.collectionAgreement(true)
5049
.advertisementAgreement(true)
51-
.pushAgreement(true)
5250
.socialType(SocialType.KAKAO)
5351
.build();
5452
}

src/test/java/com/tnt/infrastructure/s3/S3AdapterTest.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import static org.mockito.BDDMockito.given;
77
import static org.mockito.Mockito.verify;
88

9-
import java.net.URI;
10-
import java.net.URL;
11-
129
import org.junit.jupiter.api.BeforeEach;
1310
import org.junit.jupiter.api.DisplayName;
1411
import org.junit.jupiter.api.Test;
@@ -23,7 +20,6 @@
2320
import software.amazon.awssdk.core.sync.RequestBody;
2421
import software.amazon.awssdk.services.s3.S3Client;
2522
import software.amazon.awssdk.services.s3.S3Utilities;
26-
import software.amazon.awssdk.services.s3.model.GetUrlRequest;
2723
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
2824
import software.amazon.awssdk.services.s3.model.S3Exception;
2925

@@ -51,16 +47,12 @@ void upload_file_success() throws Exception {
5147
byte[] fileData = "test data".getBytes();
5248
String folderPath = "test/folder";
5349
String extension = "jpg";
54-
URL mockUrl = URI.create("https://test-bucket.s3.amazonaws.com/test/folder/123.jpg").toURL();
55-
56-
given(s3Client.utilities()).willReturn(s3Utilities);
57-
given(s3Utilities.getUrl(any(GetUrlRequest.class))).willReturn(mockUrl);
5850

5951
// when
6052
String result = s3Adapter.uploadFile(fileData, folderPath, extension);
6153

6254
// then
63-
assertThat(result).startsWith("https://test-bucket.s3.amazonaws.com/test/folder/");
55+
assertThat(result).startsWith("https://images.tntapp.co.kr/test/folder/");
6456
verify(s3Client).putObject(any(PutObjectRequest.class), any(RequestBody.class));
6557
}
6658

src/test/java/com/tnt/presentation/member/MemberControllerTest.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package com.tnt.presentation.member;
22

3-
import static com.tnt.domain.constant.Constant.*;
4-
import static org.springframework.http.MediaType.*;
5-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
6-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
3+
import static com.tnt.domain.constant.Constant.TRAINEE;
4+
import static com.tnt.domain.constant.Constant.TRAINEE_DEFAULT_IMAGE;
5+
import static com.tnt.domain.constant.Constant.TRAINER;
6+
import static com.tnt.domain.constant.Constant.TRAINER_DEFAULT_IMAGE;
7+
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
8+
import static org.springframework.http.MediaType.IMAGE_JPEG_VALUE;
9+
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
10+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
11+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
12+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
713

814
import java.time.LocalDate;
915
import java.util.List;
@@ -40,7 +46,7 @@ class MemberControllerTest extends AbstractContainerBaseTest {
4046
void sign_up_trainer_success() throws Exception {
4147
// given
4248
SignUpRequest request = new SignUpRequest("fcm-token-test", TRAINER, "KAKAO", "12345", "[email protected]", true,
43-
true, true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
49+
true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
4450

4551
// when
4652
var jsonRequest = new MockMultipartFile("request", "", APPLICATION_JSON_VALUE,
@@ -63,7 +69,7 @@ void sign_up_trainer_success() throws Exception {
6369
void sign_up_trainee_success() throws Exception {
6470
// given
6571
SignUpRequest request = new SignUpRequest("fcm-token-test", TRAINEE, "KAKAO", "12345", "[email protected]", true,
66-
true, true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
72+
true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
6773

6874
// when
6975
var jsonRequest = new MockMultipartFile("request", "", APPLICATION_JSON_VALUE,
@@ -87,7 +93,7 @@ void sign_up_invalid_member_type_fail() throws Exception {
8793
// given
8894
SignUpRequest request = new SignUpRequest("fcm-token-test", "invalid_type", "KAKAO", "12345", "[email protected]",
8995
true,
90-
true, true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
96+
true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
9197

9298
// when
9399
var jsonRequest = new MockMultipartFile("request", "", APPLICATION_JSON_VALUE,
@@ -106,7 +112,7 @@ void sign_up_invalid_member_type_fail() throws Exception {
106112
void sign_up_missing_required_field_fail() throws Exception {
107113
// given
108114
SignUpRequest request = new SignUpRequest("", TRAINER, "KAKAO", "12345", "[email protected]", true,
109-
true, true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
115+
true, true, "홍길동", LocalDate.of(1990, 1, 1), 175.0, 70.0, "테스트 주의사항", List.of("체중 감량", "근력 향상"));
110116

111117
// when
112118
var jsonRequest = new MockMultipartFile("request", "", APPLICATION_JSON_VALUE,

src/test/java/com/tnt/presentation/trainer/TrainerControllerTest.java

-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ void get_invitation_code_success() throws Exception {
8686
.serviceAgreement(true)
8787
.collectionAgreement(true)
8888
.advertisementAgreement(true)
89-
.pushAgreement(true)
9089
.socialType(SocialType.KAKAO)
9190
.build();
9291

@@ -120,7 +119,6 @@ void get_invitation_code_fail() throws Exception {
120119
.serviceAgreement(true)
121120
.collectionAgreement(true)
122121
.advertisementAgreement(true)
123-
.pushAgreement(true)
124122
.socialType(SocialType.KAKAO)
125123
.build();
126124

@@ -154,7 +152,6 @@ void reissue_invitation_code_success() throws Exception {
154152
.serviceAgreement(true)
155153
.collectionAgreement(true)
156154
.advertisementAgreement(true)
157-
.pushAgreement(true)
158155
.socialType(SocialType.KAKAO)
159156
.build();
160157

@@ -187,7 +184,6 @@ void verify_invitation_code_success() throws Exception {
187184
.serviceAgreement(true)
188185
.collectionAgreement(true)
189186
.advertisementAgreement(true)
190-
.pushAgreement(true)
191187
.socialType(SocialType.KAKAO)
192188
.build();
193189

@@ -224,7 +220,6 @@ void verify_invitation_code_fail() throws Exception {
224220
.serviceAgreement(true)
225221
.collectionAgreement(true)
226222
.advertisementAgreement(true)
227-
.pushAgreement(true)
228223
.socialType(SocialType.KAKAO)
229224
.build();
230225

0 commit comments

Comments
 (0)