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

[3차 세미나 과제] 필수 과제 구현 #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

Ivoryeee
Copy link
Collaborator

@Ivoryeee Ivoryeee commented Nov 3, 2024

📍관련 이슈

closed #8

📍과제 구현

  • 로그인 기능
  • 회원가입 기능
  • 기존 다이어리 테이블과 유저 테이블 연결

📍구현 내용

회원가입

    @PostMapping("/signup")
    private ResponseEntity<?> signUp(@Valid @RequestBody SignUpRequest signUpRequest){
        UserEntity user = userService.createUser(signUpRequest);
        HttpHeaders headers = new HttpHeaders();
        headers.setLocation(ServletUriComponentsBuilder
                .fromCurrentRequest()
                .path("/{id}")
                .buildAndExpand(user.getId())
                .toUri());
        headers.add("UserId", String.valueOf(user.getId()));

        return new ResponseEntity<> (headers, HttpStatus.CREATED);
    }

로그인

    @PostMapping("/login")
    private ResponseEntity<?> login(@Valid @RequestBody LoginRequest loginRequest){
        return userService.findUser(loginRequest);

📍새로 배운 점

  • HttpHeaders 를 사용해 헤더 정보 내보내고, @RequestHeader 를 사용해 헤더 정보를 함께 받아올 수 있다
  • @ManyToOne, @JoinColumn 어노테이션을 사용해 테이블 간 PK-FK 연결을 생성할 수 있음
  • application.yml에서 hibernate: ddl-auto: none 속성을 통해 데이터 베이스가 꼬이는 것을 방지할 수 있으나, 최초 생성 시 create 로 입력해 entity에 맞게 테이블을 생성해도 됨

📍궁금한 점

  • 전역 처리 시 파일간 역할을 어느 정도까지 분리하는 게 좋을지 고민됨...

@Ivoryeee Ivoryeee added the 과제 label Nov 3, 2024
@Ivoryeee Ivoryeee self-assigned this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3차 세미나 과제] 한 줄 일기장 유저 정보 추가
1 participant