Skip to content

[FEAT] 약관 동의 조회 API 구현 #297

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

Merged
merged 9 commits into from
Feb 11, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.websoso.WSSServer.dto.feed.UserFeedsGetResponse;
import org.websoso.WSSServer.dto.notification.PushSettingGetResponse;
import org.websoso.WSSServer.dto.notification.PushSettingRequest;
import org.websoso.WSSServer.dto.user.ConsentSettingGetResponse;
import org.websoso.WSSServer.dto.user.EditMyInfoRequest;
import org.websoso.WSSServer.dto.user.EditProfileStatusRequest;
import org.websoso.WSSServer.dto.user.FCMTokenRequest;
Expand Down Expand Up @@ -239,4 +240,12 @@ public ResponseEntity<Void> registerPushSetting(Principal principal,
.status(NO_CONTENT)
.build();
}

@GetMapping("/consent-settings")
public ResponseEntity<ConsentSettingGetResponse> getConsentSettingValue(Principal principal) {
User user = userService.getUserOrException(Long.valueOf(principal.getName()));
return ResponseEntity
.status(OK)
.body(userService.getConsentSettingValue(user));
}
}
12 changes: 12 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ public class User extends BaseEntity {
@Column(columnDefinition = "Boolean default true", nullable = false)
private Boolean isPushEnabled;

@Column(columnDefinition = "Boolean default false", nullable = false)
private Boolean isTermsAgreed;

@Column(columnDefinition = "Boolean default false", nullable = false)
private Boolean isPrivacyConsented;

@Column(columnDefinition = "Boolean default false", nullable = false)
private Boolean isMarketingConsented;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
@ColumnDefault("'USER'")
Expand Down Expand Up @@ -130,6 +139,9 @@ private User(String socialId, String nickname, String email) {
this.avatarId = 1;
this.isProfilePublic = true;
this.isPushEnabled = true;
this.isTermsAgreed = false;
this.isPrivacyConsented = false;
this.isMarketingConsented = false;
this.role = USER;
this.socialId = socialId;
this.nickname = nickname;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.websoso.WSSServer.dto.user;

public record ConsentSettingGetResponse(
Boolean isTermsAgreed,
Boolean isPrivacyConsented,
Boolean isMarketingConsented
) {
public static ConsentSettingGetResponse of(Boolean isTermsAgreed, Boolean isPrivacyConsented,
Boolean isMarketingConsented) {
return new ConsentSettingGetResponse(
isTermsAgreed,
isPrivacyConsented,
isMarketingConsented
);
}
}
7 changes: 7 additions & 0 deletions src/main/java/org/websoso/WSSServer/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.websoso.WSSServer.domain.common.DiscordWebhookMessage;
import org.websoso.WSSServer.domain.common.SocialLoginType;
import org.websoso.WSSServer.dto.notification.PushSettingGetResponse;
import org.websoso.WSSServer.dto.user.ConsentSettingGetResponse;
import org.websoso.WSSServer.dto.user.EditMyInfoRequest;
import org.websoso.WSSServer.dto.user.EditProfileStatusRequest;
import org.websoso.WSSServer.dto.user.FCMTokenRequest;
Expand Down Expand Up @@ -277,4 +278,10 @@ public void registerPushSetting(User user, Boolean isPushEnabled) {
public PushSettingGetResponse getPushSettingValue(User user) {
return PushSettingGetResponse.of(user.getIsPushEnabled());
}

@Transactional(readOnly = true)
public ConsentSettingGetResponse getConsentSettingValue(User user) {
return ConsentSettingGetResponse.of(user.getIsTermsAgreed(), user.getIsPrivacyConsented(),
user.getIsMarketingConsented());
}
}
Loading