ADD::added more comments

This commit is contained in:
Sem van der Hoeven
2019-03-18 20:47:34 +01:00
parent 2c54b8d68c
commit 920c7c798d
4 changed files with 22 additions and 6 deletions

View File

@@ -59,6 +59,7 @@ public class RegisterWindowController {
return; return;
} }
//register the user with the provided username and password
userService.registerUser(userNameText.getText(), passwordField.getText()); userService.registerUser(userNameText.getText(), passwordField.getText());
//close the register window after the user has entered all the credentials //close the register window after the user has entered all the credentials

View File

@@ -58,7 +58,7 @@ public class UserController {
if (passwordField.getText().isEmpty()) { if (passwordField.getText().isEmpty()) {
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!", AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
"Please enter a password"); "Please enter a password");
//checks if the password field id filled, //checks if the password field is filled,
// and gives an alert if it is not. // and gives an alert if it is not.
return; return;
} else { } else {
@@ -117,9 +117,11 @@ public class UserController {
} }
/** /**
* The method handles register button. * The method handles the clicking of the register button.
* @param event User clicks to the button * it then opens the register window where the user can register
* @throws Exception when the file couldn't be found * (handled by RegisterWindowController)
* @param event User clicks on the button
* @throws Exception when the fxml file couldn't be found
*/ */
public void handleRegisterButtonAction(ActionEvent event) throws Exception { public void handleRegisterButtonAction(ActionEvent event) throws Exception {
Parent registerWindow = Application.load(this.getClass().getClassLoader() Parent registerWindow = Application.load(this.getClass().getClassLoader()

View File

@@ -51,6 +51,7 @@ public class UserService {
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
//the result to be sent is a userDto //the result to be sent is a userDto
//encodes the userDTO object to a Uri so the database can work with it
UserDto result = this.restTemplate.getForObject(builder.build() UserDto result = this.restTemplate.getForObject(builder.build()
.encode().toUri(), UserDto.class); .encode().toUri(), UserDto.class);
this.currentUser = result; this.currentUser = result;

View File

@@ -16,8 +16,12 @@ public class UserController {
//registers a user in the userService //registers a user in the userService
@RequestMapping("/registerUser") @RequestMapping("/registerUser")
//requestMapping is for the communication (GET, POST, PUT requests)
//as with Web and Database Technology
public UserDto registerUser(@RequestParam(value = "name") String name, public UserDto registerUser(@RequestParam(value = "name") String name,
@RequestParam(value = "password") String password) { @RequestParam(value = "password") String password) {
//the requestParams are the parameters that are sent with the request
//so in this case that it wants to register with the name and password
return userService.registerUser(name, password); return userService.registerUser(name, password);
} }
@@ -28,10 +32,18 @@ public class UserController {
return userService.loginUser(name, password); return userService.loginUser(name, password);
} }
//adds a vegan meal to the user
/**
* adds a vegetarian meal to the user.
* @param id the id of the user
* @param name thr username of the user
*/
@RequestMapping("/addVeganMeal") @RequestMapping("/addVeganMeal")
public void addVeganMeal(@RequestParam(value = "id") Long id, public void addVeganMeal(@RequestParam(value = "id") Long id,
@RequestParam(value = "name") String name) { @RequestParam(value = "name") String name) {
//here the requestParams are the id and name, because that is needed for the
//addVeganMeal method of the userService
userService.addVeganMeal(id, name); userService.addVeganMeal(id, name);
} }
} }