Skip to content

add feature/lesson2-quoc#7

Open
conalpham wants to merge 2 commits intofeature/lesson2from
feature/lesson2-quoc
Open

add feature/lesson2-quoc#7
conalpham wants to merge 2 commits intofeature/lesson2from
feature/lesson2-quoc

Conversation

@conalpham
Copy link
Copy Markdown

Please check my code !!!!

// make this as rest controller

@RestController
@RequestMapping(path="/api/v1/employee") // This means URL's start with /user (after Application path)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url neen laf: path="/api/v1/employees"

return "Welcome to Java Inspires";
}

@GetMapping(path = "/addemployee")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Khi server ghi dữ liệu vào CSDL thì là method Post, e đang để GetMapping
path chỉ cần path = "/" là được


@GetMapping(path = "/addemployee")
// @ResponseBody
public ResponseEntity<?> addemployee(@RequestParam int id, @RequestParam String firstName, @RequestParam String lastName, @RequestParam String address) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method nên đặt theo camelCase
và để CRUD cho dễ tìm sau này. addemployee => createEmployeee

* this method return list of usernames
* @return usernameList
*/
@GetMapping(path = "/getallemployee")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path = "/getallemployee" => path = "/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants