jpablog : read test
This commit is contained in:
@@ -4,9 +4,9 @@ import com.example.jpablog.model.RoleType;
|
||||
import com.example.jpablog.model.User;
|
||||
import com.example.jpablog.repository.UserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -14,10 +14,16 @@ public class DummyControllerTest {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@GetMapping("/dummy/user/{id}")
|
||||
public User detail(@PathVariable Long id) {
|
||||
return userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("유저 없음. id : " + id));
|
||||
}
|
||||
|
||||
@PostMapping("/dummy/join")
|
||||
public String join(@RequestBody User user) {
|
||||
user.setRole(RoleType.USER);
|
||||
userRepository.save(user);
|
||||
return "회원가입 완료";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ spring:
|
||||
jpa:
|
||||
open-in-view: true
|
||||
hibernate:
|
||||
ddl-auto: create
|
||||
ddl-auto: update
|
||||
# naming:
|
||||
# physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
use-new-id-generator-mappings: false
|
||||
|
||||
Reference in New Issue
Block a user