Skip to content

Commit

Permalink
[feat] 회원탈퇴 이유 입력 기능 추가 #169
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns committed Nov 12, 2023
1 parent 8b92bca commit 03ccbeb
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import allchive.server.api.auth.service.TokenRefreshUseCase;
import allchive.server.api.auth.service.WithdrawUserUseCase;
import allchive.server.api.config.security.SecurityUtil;
import allchive.server.domain.domains.quitReason.domain.enums.Reason;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
Expand All @@ -26,9 +27,10 @@ public class AuthController {
@DeleteMapping("/withdrawal")
public void withDrawUser(
@RequestParam(required = false, name = "appleCode", value = "") String appleCode,
@RequestHeader(value = "referer", required = false) String referer) {
@RequestHeader(value = "referer", required = false) String referer,
@RequestParam("quitReason") Reason reason) {
Long userId = SecurityUtil.getCurrentUserId();
withdrawUserUseCase.execute(appleCode, referer, userId);
withdrawUserUseCase.execute(appleCode, referer, userId, reason);
}

@Operation(summary = "회원탈퇴를 합니다. (개발용)", deprecated = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import allchive.server.domain.domains.content.service.ContentDomainService;
import allchive.server.domain.domains.content.service.ContentTagGroupDomainService;
import allchive.server.domain.domains.content.service.TagDomainService;
import allchive.server.domain.domains.quitReason.domain.QuitReason;
import allchive.server.domain.domains.quitReason.domain.enums.Reason;
import allchive.server.domain.domains.quitReason.service.QuitReasonDomainService;
import allchive.server.domain.domains.recycle.service.RecycleDomainService;
import allchive.server.domain.domains.report.service.ReportDomainService;
import allchive.server.domain.domains.search.service.LatestSearchDomainService;
Expand Down Expand Up @@ -47,13 +50,15 @@ public class WithdrawUserUseCase {
private final ReportDomainService reportDomainService;
private final UserDomainService userDomainService;
private final ArchivingDomainService archivingDomainService;
private final QuitReasonDomainService quitReasonDomainService;

@Transactional
@DistributedLock(
lockType = DistributedLockType.USER,
identifier = {"userId"})
public void execute(String appleAccessToken, String referer, Long userId) {
public void execute(String appleAccessToken, String referer, Long userId, Reason reason) {
User user = userAdaptor.findById(userId);
quitReasonDomainService.save(QuitReason.of(userId, reason));
// oauth쪽 탈퇴
withdrawOauth(user.getOauthInfo().getProvider(), appleAccessToken, user, referer);
// 우리쪽 탈퇴
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package allchive.server.domain.domains.quitReason.adaptor;

import allchive.server.core.annotation.Adaptor;
import allchive.server.domain.domains.quitReason.domain.QuitReason;
import allchive.server.domain.domains.quitReason.repository.QuitReasonRepository;
import lombok.RequiredArgsConstructor;

@Adaptor
@RequiredArgsConstructor
public class QuitReasonAdaptor {
private final QuitReasonRepository quitReasonRepository;

public void save(QuitReason quitReason) {
quitReasonRepository.save(quitReason);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package allchive.server.domain.domains.quitReason.domain;

import allchive.server.domain.common.model.BaseTimeEntity;
import allchive.server.domain.domains.quitReason.domain.enums.Reason;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Getter
@Table(name = "tbl_quit_reason")
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class QuitReason extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull
private Long userId;

private Reason reason;

@Builder
private QuitReason(Long userId, Reason reason) {
this.userId = userId;
this.reason = reason;
}

public static QuitReason of(Long userId, Reason reason) {
return QuitReason.builder()
.userId(userId)
.reason(reason)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package allchive.server.domain.domains.quitReason.domain.enums;

import allchive.server.domain.domains.user.domain.enums.OauthProvider;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum Reason {
NOT_USED("NOT_USED"), // 자주 사용하지 않아서
UNCONFORTABLE("UNCONFORTABLE"), // 이용이 불편하고 장애가 많아서
USE_OTHER_SERVICE("USE_OTHER_SERVICE"), //다른 대체 서비스를 이용해서
EXPENSIVE("EXPENSIVE"), // 서비스 이용료가 비싸서
NEW_ACCOUNT("NEW_ACCOUNT"), //새 계정을 만들고싶어서
ETC("ETC");

@JsonValue
private String value;

@JsonCreator
public static Reason parsing(String inputValue) {
return Stream.of(Reason.values())
.filter(type -> type.getValue().equals(inputValue))
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package allchive.server.domain.domains.quitReason.repository;

import allchive.server.domain.domains.quitReason.domain.QuitReason;
import org.springframework.data.jpa.repository.JpaRepository;

public interface QuitReasonRepository extends JpaRepository<QuitReason, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package allchive.server.domain.domains.quitReason.service;

import allchive.server.core.annotation.DomainService;
import allchive.server.domain.domains.quitReason.adaptor.QuitReasonAdaptor;
import allchive.server.domain.domains.quitReason.domain.QuitReason;
import lombok.RequiredArgsConstructor;

@DomainService
@RequiredArgsConstructor
public class QuitReasonDomainService {
private final QuitReasonAdaptor quitReasonAdaptor;

public void save(QuitReason quitReason) {
quitReasonAdaptor.save(quitReason);
}
}
2 changes: 1 addition & 1 deletion Domain/src/main/resources/application-domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spring:
format_sql: true
default_batch_fetch_size: 100
hibernate:
ddl-auto: none
ddl-auto: update
defer-datasource-initialization: true
open-in-view: false
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
Expand Down

0 comments on commit 03ccbeb

Please sign in to comment.