Skip to content

Commit 207becf

Browse files
[FEAT] 회원탈퇴 기능 구현 완료
[FEAT] 회원탈퇴 기능 구현 완료
2 parents e61fc23 + ab8a8a8 commit 207becf

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

q-api/src/main/java/com/qcard/api/account/controller/AccountController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public ResponseEntity<LogOutRes> logOut(HttpServletRequest request) {
4747
return new ResponseEntity<>(response, HttpStatus.OK);
4848
}
4949

50+
@DeleteMapping("/")
51+
public ResponseEntity<AccountDeleteRes> accountDelete(@AuthAccount Account account) {
52+
AccountDeleteRes response = accountService.deleteAccount(account);
53+
return new ResponseEntity<>(response, HttpStatus.OK);
54+
}
55+
5056
@GetMapping("/profile")
5157
public ResponseEntity<AccountRes> myAccountInfo(@AuthAccount Account account) {
5258
AccountRes response = new AccountRes(account);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.qcard.api.account.dto;
2+
3+
import com.qcard.domains.account.entity.Account;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
7+
@Getter
8+
@NoArgsConstructor
9+
public class AccountDeleteRes {
10+
private String message;
11+
private Account account;
12+
public AccountDeleteRes(Account account) {
13+
this.account = account;
14+
this.message = "성공적으로 회원탈퇴를 완료했습니다.";
15+
}
16+
}

q-api/src/main/java/com/qcard/api/account/service/AccountService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,12 @@ public LogOutRes logout(String refreshToken) {
7171
public AccountRes modifyAccount(Account account, AccountModifyReq request) {
7272
return new AccountRes(accountDomainService.updateAccount(account, request.getName(), request.getEmail(), request.getProfile()));
7373
}
74+
75+
public AccountDeleteRes deleteAccount(Account account) {
76+
if(account.getIsDeleted()) throw new IllegalArgumentException("이미 탈퇴한 회원입니다.");
77+
else {
78+
accountDomainService.findAccountById(account.getId());
79+
return new AccountDeleteRes(accountDomainService.updateAccountIsDeleted(account));
80+
}
81+
}
7482
}

q-domain/src/main/generated/com/qcard/domains/account/entity/QAccount.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class QAccount extends EntityPathBase<Account> {
2323

2424
public final NumberPath<Long> id = createNumber("id", Long.class);
2525

26+
public final BooleanPath isDeleted = createBoolean("isDeleted");
27+
2628
public final StringPath name = createString("name");
2729

2830
public final StringPath password = createString("password");

q-domain/src/main/java/com/qcard/domains/account/entity/Account.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class Account {
2727
@Column
2828
private String profile;
2929

30+
@Column
31+
private Boolean isDeleted;
32+
3033
@Builder
3134
public Account(String name, String email, String password) {
3235
this.name = name;
@@ -40,4 +43,8 @@ public void update(String name, String email, String profile) {
4043
this.password = profile;
4144
}
4245

46+
public void updateIsDeleted() {
47+
this.isDeleted = true;
48+
}
49+
4350
}

q-domain/src/main/java/com/qcard/domains/account/service/AccountDomainService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ public Account updateAccount(Account account, String name, String email, String
5050
account.update(name, email, profile);
5151
return findAccountById(account.getId());
5252
}
53+
54+
public Account updateAccountIsDeleted(Account account) {
55+
account.updateIsDeleted();
56+
return findAccountById(account.getId());
57+
}
5358
}

0 commit comments

Comments
 (0)