@PostMapping("/sign")
public ResponseEntity<Member> sign(@RequestBody Member member) {
memberService.sign(member);
return ResponseEntity.ok(member);
}
{
"id": 1,
"username": "hello",
"password": "1234"
}
@PostMapping("/sign")
public ResponseEntity<Void> sign(@RequestBody Member member) {
memberService.sign(member);
return ResponseEntity.ok().build();
}
@PostMapping("/sign")
public ResponseEntity<Void> sign(@RequestBody Member member) {
memberService.sign(member);
return new ResponseEntity<>(HttpStatus.OK);
}
{
"id": 1,
"name": "John Doe",
"email": "johndoe@example.com"
}
@PostMapping("/sign")
public ResponseEntity<Member> sign(@RequestBody Member member) {
// ...
}
@GetMapping("/members/{id}")
public ResponseEntity<Member> findById(@PathVariable Long id) {
Member currentMember = memberService.findById(id);
if (currentMember == null){
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(currentMember);
}
@GetMapping("/allMembers")
public ResponseEntity<Map<String, Object>> allMembers(){
List<Member> allMembers = memberService.findAll();
Map<String, Object> result = new HashMap<>();
result.put("members", allMembers);
return ResponseEntity.ok(allMembers);
}
{
"members": [
{
"id": 1,
"name": "John Doe",
"email": "johndoe@example.com"
},
{
"id": 2,
"name": "John Doe",
"email": "johndoe@example.com"
},
{
"id": 3,
"name": "John Doe",
"email": "johndoe@example.com"
}
]
}
@GetMapping("/allMembers")
public ResponseEntity<List<Member>> allMembers(){
List<Member> allMembers = memberService.findAll();
return ResponseEntity.ok(allMembers);
}
[
{
"id": 1,
"name": "John Doe",
"email": "johndoe@example.com"
},
{
"id": 2,
"name": "John Doe",
"email": "johndoe@example.com"
},
{
"id": 3,
"name": "John Doe",
"email": "johndoe@example.com"
}
]