2021-08-09 15:41:42 +05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.Collections.Generic;
|
2021-04-02 17:28:07 +05:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudDb.Model
|
|
|
|
|
{
|
|
|
|
|
[Table("t_user"), Comment("Пользователи облака")]
|
2021-04-23 10:21:25 +05:00
|
|
|
|
public partial class User : IId
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
2023-07-12 12:07:56 +05:00
|
|
|
|
public const int ActiveStateId = 1;
|
|
|
|
|
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[Key]
|
|
|
|
|
[Column("id")]
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
2021-07-21 12:30:51 +05:00
|
|
|
|
[Column("id_company")]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public int IdCompany { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
[Column("login")]
|
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string Login { get; set; } = null!;
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
[Column("password_hash"), Comment("соленый хэш пароля.\nпервые 5 символов - соль")]
|
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string PasswordHash { get; set; } = null!;
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2023-07-12 12:07:56 +05:00
|
|
|
|
[Column("state"), Comment("состояние:\n0 - не активен, \n1 - активен, \n2 - заблокирован")]
|
|
|
|
|
public short IdState { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("name"), Comment("имя")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string? Name { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("surname"), Comment("фамилия")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string? Surname { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
[Column("patronymic"), Comment("отчество")]
|
2021-04-02 17:28:07 +05:00
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string? Patronymic { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-09-07 14:42:56 +05:00
|
|
|
|
[Column("email"), Comment("должность")]
|
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string Email { get; set; } = string.Empty;
|
2021-09-07 14:42:56 +05:00
|
|
|
|
|
|
|
|
|
[Column("phone"), Comment("номер телефона")]
|
|
|
|
|
[StringLength(50)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string? Phone { get; set; }
|
2021-09-07 14:42:56 +05:00
|
|
|
|
|
|
|
|
|
[Column("position"), Comment("email")]
|
|
|
|
|
[StringLength(255)]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public string? Position { get; set; }
|
2021-09-07 14:42:56 +05:00
|
|
|
|
|
2021-07-21 12:30:51 +05:00
|
|
|
|
[ForeignKey(nameof(IdCompany))]
|
|
|
|
|
[InverseProperty(nameof(Model.Company.Users))]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public virtual Company Company { get; set; } = null!;
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2021-11-24 11:30:29 +05:00
|
|
|
|
[InverseProperty(nameof(RelationUserUserRole.User))]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public virtual ICollection<RelationUserUserRole> RelationUsersUserRoles { get; set; } = null!;
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2023-06-21 11:44:04 +05:00
|
|
|
|
public virtual ICollection<RelationContactWell> RelationContactsWells { get; set; } = null!;
|
|
|
|
|
|
2023-02-20 12:18:45 +05:00
|
|
|
|
[InverseProperty(nameof(FileInfo.Author))]
|
|
|
|
|
public virtual ICollection<FileInfo> Files { get; set; } = null!;
|
2022-04-11 18:00:34 +05:00
|
|
|
|
|
2021-11-09 17:24:30 +05:00
|
|
|
|
[InverseProperty(nameof(FileMark.User))]
|
2023-02-20 12:18:45 +05:00
|
|
|
|
public virtual ICollection<FileMark> FileMarks { get; set; } = null!;
|
2021-07-27 16:55:32 +05:00
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
public string MakeDisplayName()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Surname))
|
|
|
|
|
return Login;
|
|
|
|
|
|
|
|
|
|
var s = Surname;
|
|
|
|
|
if (!string.IsNullOrEmpty(Name))
|
|
|
|
|
{
|
|
|
|
|
s += $"{Name[0]}.";
|
|
|
|
|
if (!string.IsNullOrEmpty(Patronymic))
|
|
|
|
|
s += $" {Patronymic[0]}.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|