-
Notifications
You must be signed in to change notification settings - Fork 3
1회차 #8
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
base: main
Are you sure you want to change the base?
1회차 #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,3 +35,7 @@ out/ | |
|
|
||
| ### VS Code ### | ||
| .vscode/ | ||
|
|
||
| # Ignore all YAML files | ||
| *.yaml | ||
| *.yml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,41 @@ | ||
| package com.example.springhw1.controller; | ||
|
|
||
|
|
||
| import com.example.springhw1.entity.User; | ||
| import com.example.springhw1.service.UserService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController //HTTP 요청, JSON 반환 | ||
| @RequestMapping("/users")//이 클래스의 모든 메서드 /users 경로 사용 | ||
| public class UserController { | ||
| } | ||
|
|
||
| private final UserService userService; | ||
|
|
||
| @Autowired//의존성 주입 | ||
| public UserController(UserService userService) { | ||
| this.userService = userService; | ||
| } | ||
|
|
||
| @PostMapping("/join")//데이터 전송하거나 생성할 때 | ||
| public User 회원가입( | ||
| @RequestParam String username, | ||
| @RequestParam String password, | ||
| @RequestParam String nickname) { | ||
|
Comment on lines
+23
to
+25
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good! 생략된 부분이 있다는 거 꼭 알고 쓰면 됩니다~ |
||
|
|
||
| User savedUser = userService.saveUser(username, password, nickname); | ||
| return savedUser; | ||
|
Comment on lines
+27
to
+28
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거는 수정할 부분은 아니고 참고하면 좋은 부분이라 comment 남겨요 물론 이거는 본인 코딩 스타일이라 굳이 어떤 방법이 좋다 이건 없어 |
||
| } | ||
|
|
||
| @GetMapping("/id/{id}")//데이터 조회할 때 | ||
| public User getUserById(@PathVariable Long id){//변수 값 추출 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 마찬가지 |
||
| return userService.findUserById(id); | ||
| } | ||
|
|
||
| @GetMapping("/username/{username}") | ||
| public User getUserByUsername(@PathVariable String username){ | ||
| return userService.findUserByUsername(username); | ||
| } | ||
| //dfsdfdf | ||
| } | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
악 이거 넣는거 까먹었다 감사합니다~