terminado sign up

This commit is contained in:
2025-10-04 13:09:35 +02:00
parent d9c4f16cf0
commit b66ceee85c
15 changed files with 491 additions and 200 deletions

View File

@ -57,7 +57,8 @@ public class User {
@Column(name = "deleted_by")
private Long deletedBy;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, orphanRemoval = true)
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REMOVE }, orphanRemoval = true)
@SQLRestriction("deleted = false")
@JsonIgnore
private Set<UserRole> rolesLink = new HashSet<>();

View File

@ -29,6 +29,15 @@ public interface UserDao extends JpaRepository<User, Long>, JpaSpecificationExec
boolean existsByUserNameIgnoreCase(String userName);
// Para comprobar si existe al hacer signup
@Query(value = """
SELECT id, deleted, enabled
FROM users
WHERE LOWER(username) = LOWER(:userName)
LIMIT 1
""", nativeQuery = true)
Optional<UserLite> findLiteByUserNameIgnoreCase(@Param("userName") String userName);
boolean existsByUserNameIgnoreCaseAndIdNot(String userName, Long id);
// Nuevo: para login/negocio "activo"

View File

@ -0,0 +1,9 @@
package com.imprimelibros.erp.users;
// Proyección para consultas ligeras de usuarios (id, enabled, deleted)
public interface UserLite {
Long getId();
Boolean getDeleted();
Boolean getEnabled();
}