Skip to content

Commit 239de14

Browse files
committed
logout
1 parent ce57df4 commit 239de14

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/main/java/com/codingwasabi/bigtong/main/controller/AccountController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ public CurrentReturnDto returnCurrent(){
3535
return accountService.returnCurrent();
3636
}
3737

38+
@DeleteMapping("/logout")
39+
public boolean logout(@RequestParam String name){
40+
return accountService.deleteNickname(name);
41+
}
42+
3843
}

src/main/java/com/codingwasabi/bigtong/main/service/AccountService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.codingwasabi.bigtong.main.Account;
66
import com.codingwasabi.bigtong.main.dto.CurrentReturnDto;
77
import com.codingwasabi.bigtong.main.repository.AccountRepository;
8+
import com.codingwasabi.bigtong.websocket.exception.AccountNotExistException;
89
import com.codingwasabi.bigtong.websocket.message.ChatMessage;
910
import com.codingwasabi.bigtong.websocket.message.MessageType;
1011
import com.codingwasabi.bigtong.websocket.service.ChatService;
@@ -110,4 +111,17 @@ public CurrentReturnDto returnCurrent(){
110111

111112
return currentReturnDto;
112113
}
114+
115+
@Transactional
116+
public boolean deleteNickname(String name){
117+
118+
try {
119+
Account account = accountRepository.findByNickname(name).orElseThrow(AccountNotExistException::new);
120+
}catch (AccountNotExistException a){
121+
return false;
122+
}
123+
124+
accountRepository.deleteAccountByNickname(name);
125+
return true;
126+
}
113127
}

0 commit comments

Comments
 (0)