Align desktop user contract with backend

- Replace firstName and lastName with fullName and email in UserRequest
- Add email and updatedAt to UserResponse
- Update StaffRegisterDialogController to build fullName from firstName + lastName
- Update StaffRegisterDialogController to include email validation and send email
- Update StaffAccountsController to use backend email from UserResponse instead of hardcoding blank
This commit is contained in:
2026-03-08 22:02:28 -06:00
parent d4e532a798
commit 000c1f8859
4 changed files with 36 additions and 13 deletions

View File

@@ -3,8 +3,8 @@ package org.example.petshopdesktop.api.dto.user;
public class UserRequest {
private String username;
private String password;
private String firstName;
private String lastName;
private String fullName;
private String email;
private String role;
private Boolean active;
@@ -27,20 +27,20 @@ public class UserRequest {
this.password = password;
}
public String getFirstName() {
return firstName;
public String getFullName() {
return fullName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getLastName() {
return lastName;
public String getEmail() {
return email;
}
public void setLastName(String lastName) {
this.lastName = lastName;
public void setEmail(String email) {
this.email = email;
}
public String getRole() {

View File

@@ -6,9 +6,11 @@ public class UserResponse {
private Long id;
private String username;
private String fullName;
private String email;
private String role;
private Boolean active;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
public UserResponse() {
}
@@ -37,6 +39,14 @@ public class UserResponse {
this.fullName = fullName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getRole() {
return role;
}
@@ -60,4 +70,12 @@ public class UserResponse {
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@@ -142,7 +142,7 @@ public class StaffAccountsController {
String[] names = splitFullName(fullName);
String firstName = names[0];
String lastName = names[1];
String email = "";
String email = user.getEmail() != null ? user.getEmail() : "";
String phone = "";
boolean active = user.getActive() != null ? user.getActive() : false;
Timestamp createdAt = user.getCreatedAt() != null

View File

@@ -48,6 +48,7 @@ public class StaffRegisterDialogController {
String firstName = value(txtFirstName);
String lastName = value(txtLastName);
String email = value(txtEmail);
String username = value(txtUsername);
String password = txtPassword.getText() == null ? "" : txtPassword.getText();
String confirm = txtPasswordConfirm.getText() == null ? "" : txtPasswordConfirm.getText();
@@ -56,6 +57,10 @@ public class StaffRegisterDialogController {
lblError.setText("First name and last name are required.");
return;
}
if (email.isBlank()) {
lblError.setText("Email is required.");
return;
}
if (username.isBlank()) {
lblError.setText("Username is required.");
return;
@@ -76,8 +81,8 @@ public class StaffRegisterDialogController {
UserRequest request = new UserRequest();
request.setUsername(username);
request.setPassword(password);
request.setFirstName(firstName);
request.setLastName(lastName);
request.setFullName(firstName + " " + lastName);
request.setEmail(email);
request.setRole("STAFF");
request.setActive(true);