@PostMapping(path = "/register")
public String register (@RequestBody HackerUser user) {
HackerUser newUser = new HackerUser(user.getFirstName(), user.getLastName(), user.getUsername(), user.getUmuziEmail(), user.getPassword(), user.getRole());
return service.registerUser(newUser);
}
我可以澄清有关上述代码段的一些细节:
@PostMapping(path = "/Register")
public ResponseEntity<HackerUser> Register (@RequestBody HackerUser user) {
return ResponseEntity.ok(service.RegisterUser(newUser));
}
和您的
“ RegisterUser”方法可能类似于:
public HackerUser RegisterUser(HackerUser user) { HackerUser newUser = new HackerUser( user.getFirstName(), user.getLastName(), user.getUsername(), user.getUmuziEmail(), user.getPassword(), user.getRole()); return repo.save(newUser); }