healthchecks

This commit is contained in:
2025-08-25 18:52:59 +02:00
parent 5777e351bf
commit 0560a40876
33 changed files with 317 additions and 127 deletions

View File

@@ -1,10 +1,12 @@
using back.DTO;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Transactional.Abstractions.Interfaces;
namespace back.DataModels;
[Table("Users")]
public class User : IEquatable<User>
public class User : IEntity<User>
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; } = null!;
@@ -31,6 +33,12 @@ public class User : IEquatable<User>
CreatedAt = createdAt.ToString("dd-MM-yyyy HH:mm:ss zz");
}
public UserDto ToDto() => new()
{
Id = Id,
Roles = Roles
};
public bool IsAdmin() => Roles.Any(r => r.IsAdmin());
public bool IsContentManager() => Roles.Any(r => r.IsContentManager());
public bool IsUser() => Roles.Any(r => r.IsUser());
@@ -46,12 +54,33 @@ public class User : IEquatable<User>
return Id == other.Id && Email == other.Email;
}
public bool IsNull => this is null;
public object Clone() => (User)MemberwiseClone();
public int CompareTo(object? obj)
{
if (obj is null) return 1;
if (obj is not User other) throw new ArgumentException("Object is not a Person");
return CompareTo(other);
}
public int CompareTo(User? other)
{
if (other is null) return 1;
if (ReferenceEquals(this, other)) return 0;
return string.Compare(Id, other.Id, StringComparison.OrdinalIgnoreCase);
}
public const string SystemUserId = "00000000-0000-0000-0000-000000000001";
public static readonly User SystemUser = new(
id: SystemUserId,
email: "@system",
email: "sys@t.em",
password: "",
createdAt: DateTime.UtcNow
);
)
{
Roles = [Role.AdminRole, Role.ContentManagerRole, Role.UserRole]
};
}