Add user deleting

This commit is contained in:
Dmitrii Cravcenco
2023-12-10 15:14:30 +02:00
parent ca1c1473a4
commit 8420f15732
5 changed files with 70 additions and 39 deletions

View File

@@ -1,48 +1,48 @@
package com.faf223.expensetrackerfaf.model;
package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.util.List;
import java.util.List;
@Entity(name = "users")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class User {
@Id
@Column(name = "user_uuid")
@GeneratedValue(strategy = GenerationType.UUID)
private String userUuid;
@Entity(name = "users")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class User {
@Id
@Column(name = "user_uuid")
@GeneratedValue(strategy = GenerationType.UUID)
private String userUuid;
@Column(name = "name")
@NotNull(message = "First name must not be null")
@NotEmpty(message = "First name must not be empty")
private String firstName;
@Column(name = "name")
@NotNull(message = "First name must not be null")
@NotEmpty(message = "First name must not be empty")
private String firstName;
@Column(name = "surname")
@NotNull(message = "Last name must not be null")
@NotEmpty(message = "Last name must not be empty")
private String lastName;
@Column(name = "surname")
@NotNull(message = "Last name must not be null")
@NotEmpty(message = "Last name must not be empty")
private String lastName;
@Column(name = "username")
@NotNull(message = "Username must not be null")
@NotEmpty(message = "Username must not be empty")
private String username;
@Column(name = "username")
@NotNull(message = "Username must not be null")
@NotEmpty(message = "Username must not be empty")
private String username;
@Transient
// @NotNull(message = "Password must not be null")
// @NotEmpty(message = "Password must not be empty")
private String password;
@Transient
// @NotNull(message = "Password must not be null")
// @NotEmpty(message = "Password must not be empty")
private String password;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
@ToString.Exclude
private List<Expense> expenses;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@ToString.Exclude
private List<Expense> expenses;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
@ToString.Exclude
private List<Income> incomes;
}
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@ToString.Exclude
private List<Income> incomes;
}