Skip to content
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

fix : Account readOnly 적용 #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
public class BlogsessionApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,29 @@ public AccountResponseDto getAccount(@PathVariable Long accountId)
}


@PatchMapping("/profile")
@PatchMapping("/profile/{accountId}")
@ResponseStatus(value = HttpStatus.OK)
public AccountResponseDto update(@PathVariable final Long accountId, @RequestBody @Valid final AccountUpdateRequestDto requestDto) {
Long id = accountService.update(accountId,requestDto);
Account findAccount = accountService.findById(id);
return new AccountResponseDto(findAccount);
}

@PatchMapping("/{accountId}/withdraw/")
@PatchMapping("/{accountId}")
@ResponseStatus(value = HttpStatus.OK)
public void withdraw(@PathVariable long accountId)
public String withdraw(@PathVariable long accountId)
{
accountService.withdraw(accountId);

return "성공적으로 탈퇴가 완료되었습니다";

}

@DeleteMapping("/{accountId}/withdraw/")
@DeleteMapping("/{accountId}")
@ResponseStatus(value = HttpStatus.OK)
public void delete(@PathVariable long accountId)
public String delete(@PathVariable long accountId)
{
accountService.delete(accountId);
return "성공적으로 탈퇴가 완료되었습니다";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import javax.persistence.*;

import static com.jiyun.blogsession.domain.account.domain.AccountStatus.REGISTERED;
import static com.jiyun.blogsession.domain.account.domain.AccountStatus.UNREGISTERED;


@Entity//해당 클래스에 있는 내부변수에 모두 @Column을 내부적으로 포함 -> 옵셥없으면 생략 가능
@NoArgsConstructor(access = AccessLevel.PROTECTED) //기본 생성자의 접근 제어를 PROTECTED로 설정해놓게 되면 무분별한 객체 생성에 대해 한번 더 체크할 수 있는 수단
@DynamicInsert//status 기본값 유지를 위해
@Getter
public class Account extends BaseTimeEntity {
@Id
Expand All @@ -33,7 +33,6 @@ public class Account extends BaseTimeEntity {
private String bio;//length 따로 지정하지 않으면 기본적으로 255이다.

@Enumerated(EnumType.STRING)
@ColumnDefault("'REGISTERED'")
private AccountStatus status;

@Builder
Expand All @@ -43,6 +42,7 @@ public Account(Long accountId, String email, String password, String nickname, S
this.encodedPassword = password;
this.nickname = nickname;
this.bio = bio;
this.status = REGISTERED;
}

public void updateAccount(String bio, String nickname){
Expand All @@ -55,4 +55,4 @@ public void withdrawAccount(){
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AccountResponseDto {
private String nickname;
private String bio;

@Builder

public AccountResponseDto(Account account) {
this.accountId = account.getAccountId();
this.email = account.getEmail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.stereotype.Service;

import javax.persistence.EntityNotFoundException;
import javax.security.auth.login.AccountNotFoundException;
import javax.transaction.Transactional;

@Service//서비스 레이어, 내부에서 자바 로직을 처리함
Expand All @@ -19,7 +18,7 @@ public class AccountService {

public Long signUp(SignUpRequestDto requestDto){
if (isExistedEmail(requestDto.getEmail())){
throw new IllegalArgumentException();
throw new IllegalArgumentException("이미 존재하는 email입니다. " + requestDto.getEmail());
}
Account account = accountRepository.save(requestDto.toEntity());
return account.getAccountId();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading