forked from ddrilling/AsbCloudServer
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
|
||
namespace AsbCloudDb.Model
|
||
{
|
||
[Table("t_user"), Comment("Пользователи облака")]
|
||
public partial class User : IId
|
||
{
|
||
public const int ActiveStateId = 1;
|
||
|
||
[Key]
|
||
[Column("id")]
|
||
public int Id { get; set; }
|
||
|
||
[Column("id_company")]
|
||
public int IdCompany { get; set; }
|
||
|
||
[Column("login")]
|
||
[StringLength(255)]
|
||
public string Login { get; set; } = null!;
|
||
|
||
[Column("password_hash"), Comment("соленый хэш пароля.\nпервые 5 символов - соль")]
|
||
[StringLength(255)]
|
||
public string PasswordHash { get; set; } = null!;
|
||
|
||
[Column("state"), Comment("состояние:\n0 - не активен, \n1 - активен, \n2 - заблокирован")]
|
||
public short IdState { get; set; }
|
||
|
||
[Column("name"), Comment("имя")]
|
||
[StringLength(255)]
|
||
public string? Name { get; set; }
|
||
|
||
[Column("surname"), Comment("фамилия")]
|
||
[StringLength(255)]
|
||
public string? Surname { get; set; }
|
||
|
||
[Column("patronymic"), Comment("отчество")]
|
||
[StringLength(255)]
|
||
public string? Patronymic { get; set; }
|
||
|
||
[Column("email"), Comment("должность")]
|
||
[StringLength(255)]
|
||
public string Email { get; set; } = string.Empty;
|
||
|
||
[Column("phone"), Comment("номер телефона")]
|
||
[StringLength(50)]
|
||
public string? Phone { get; set; }
|
||
|
||
[Column("position"), Comment("email")]
|
||
[StringLength(255)]
|
||
public string? Position { get; set; }
|
||
|
||
[ForeignKey(nameof(IdCompany))]
|
||
[InverseProperty(nameof(Model.Company.Users))]
|
||
public virtual Company Company { get; set; } = null!;
|
||
|
||
[InverseProperty(nameof(RelationUserUserRole.User))]
|
||
public virtual ICollection<RelationUserUserRole> RelationUsersUserRoles { get; set; } = null!;
|
||
|
||
public virtual ICollection<RelationContactWell> RelationContactsWells { get; set; } = null!;
|
||
|
||
[InverseProperty(nameof(FileInfo.Author))]
|
||
public virtual ICollection<FileInfo> Files { get; set; } = null!;
|
||
|
||
[InverseProperty(nameof(FileMark.User))]
|
||
public virtual ICollection<FileMark> FileMarks { get; set; } = null!;
|
||
|
||
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;
|
||
}
|
||
}
|
||
}
|