Change
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmPermissionAgg;
|
||||
|
||||
public class Permission
|
||||
{
|
||||
public long Id { get; private set; }
|
||||
public int Code { get; private set; }
|
||||
public Role Role { get; private set; }
|
||||
|
||||
public Permission(int code)
|
||||
{
|
||||
Code = code;
|
||||
}
|
||||
}
|
||||
46
AccountManagement.Domain/PmDomains/PmRoleAgg/Role.cs
Normal file
46
AccountManagement.Domain/PmDomains/PmRoleAgg/Role.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Domain.PmDomains.PmPermissionAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
|
||||
public class Role : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// نام نقش
|
||||
/// </summary>
|
||||
public string RoleName { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست پرمیشن کد ها
|
||||
/// </summary>
|
||||
public List<Permission> Permissions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی نقش در گزارشگیر
|
||||
/// </summary>
|
||||
public long? GozareshgirRoleId { get; private set; }
|
||||
|
||||
|
||||
protected Role()
|
||||
{
|
||||
}
|
||||
|
||||
public Role(string roleName,long? gozareshgirRolId, List<Permission> permissions)
|
||||
{
|
||||
RoleName = roleName;
|
||||
Permissions = permissions;
|
||||
GozareshgirRoleId = gozareshgirRolId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Edit(string roleName, List<Permission> permissions)
|
||||
{
|
||||
RoleName = roleName;
|
||||
Permissions = permissions;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
AccountManagement.Domain/PmDomains/PmRoleUserAgg/RoleUser.cs
Normal file
19
AccountManagement.Domain/PmDomains/PmRoleUserAgg/RoleUser.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmRoleUserAgg;
|
||||
|
||||
public class RoleUser
|
||||
{
|
||||
public RoleUser(long roleId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
}
|
||||
|
||||
public long Id { get; private set; }
|
||||
public long RoleId { get; private set; }
|
||||
|
||||
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
}
|
||||
127
AccountManagement.Domain/PmDomains/PmUserAgg/User.cs
Normal file
127
AccountManagement.Domain/PmDomains/PmUserAgg/User.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleUserAgg;
|
||||
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
/// <summary>
|
||||
/// کاربر
|
||||
/// </summary>
|
||||
public class User : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ایجاد
|
||||
/// </summary>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="roles"></param>
|
||||
public User(string fullName, string userName, string password, string mobile, string email, long? accountId, List<RoleUser> roles)
|
||||
{
|
||||
FullName = fullName;
|
||||
UserName = userName;
|
||||
Password = password;
|
||||
Mobile = mobile;
|
||||
Email = email;
|
||||
IsActive = true;
|
||||
AccountId = accountId;
|
||||
RoleUser = roles;
|
||||
}
|
||||
|
||||
protected User()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// نام و نام خانوادگی
|
||||
/// </summary>
|
||||
public string FullName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربری
|
||||
/// </summary>
|
||||
public string UserName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// گذرواژه
|
||||
/// </summary>
|
||||
public string Password { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// مسیر عکس پروفایل
|
||||
/// </summary>
|
||||
public string ProfilePhotoPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره موبایل
|
||||
/// </summary>
|
||||
public string Mobile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ایمیل
|
||||
/// </summary>
|
||||
public string Email { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیر فعال بودن یوزر
|
||||
/// </summary>
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// کد یکبارمصرف ورود
|
||||
/// </summary>
|
||||
public string VerifyCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی کاربر در گزارشگیر
|
||||
/// </summary>
|
||||
public long? AccountId { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست پرمیشن کد ها
|
||||
/// </summary>
|
||||
public List<RoleUser> RoleUser { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آپدیت کاربر
|
||||
/// </summary>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="roles"></param>
|
||||
/// <param name="isActive"></param>
|
||||
public void Edit(string fullName, string userName, string mobile, List<RoleUser> roles, bool isActive)
|
||||
{
|
||||
FullName = fullName;
|
||||
UserName = userName;
|
||||
Mobile = mobile;
|
||||
RoleUser = roles;
|
||||
IsActive = isActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// غیرفعال سازی
|
||||
/// </summary>
|
||||
public void DeActive()
|
||||
{
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// فعال سازی
|
||||
/// </summary>
|
||||
public void ReActive()
|
||||
{
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
CompanyManagment.EFCore/Mapping/PmMappings/RoleMapping.cs
Normal file
23
CompanyManagment.EFCore/Mapping/PmMappings/RoleMapping.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping.PmMappings;
|
||||
|
||||
public class RoleMapping : IEntityTypeConfiguration<Role>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Role> builder)
|
||||
{
|
||||
builder.ToTable("Roles");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.RoleName).HasMaxLength(100).IsRequired();
|
||||
|
||||
builder.OwnsMany(x => x.Permissions, navigationBuilder =>
|
||||
{
|
||||
navigationBuilder.HasKey(x => x.Id);
|
||||
navigationBuilder.ToTable("RolePermissions");
|
||||
navigationBuilder.WithOwner(x => x.Role);
|
||||
});
|
||||
}
|
||||
}
|
||||
34
CompanyManagment.EFCore/Mapping/PmMappings/UserMapping.cs
Normal file
34
CompanyManagment.EFCore/Mapping/PmMappings/UserMapping.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings;
|
||||
|
||||
public class UserMapping :IEntityTypeConfiguration<User>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<User> builder)
|
||||
{
|
||||
builder.ToTable("Users");
|
||||
builder.HasKey(x => x.Id);
|
||||
|
||||
builder.Property(x => x.FullName).HasMaxLength(100).IsRequired();
|
||||
builder.Property(x => x.UserName).HasMaxLength(100).IsRequired();
|
||||
builder.Property(x => x.Password).HasMaxLength(1000).IsRequired();
|
||||
builder.Property(x => x.ProfilePhotoPath).HasMaxLength(500).IsRequired(false);
|
||||
builder.Property(x => x.Mobile).HasMaxLength(20).IsRequired();
|
||||
builder.Property(x => x.Email).HasMaxLength(150).IsRequired(false); ;
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(10).IsRequired(false);
|
||||
builder.OwnsMany(x => x.RoleUser, navigationBuilder =>
|
||||
{
|
||||
navigationBuilder.HasKey(x => x.Id);
|
||||
navigationBuilder.ToTable("RoleUsers");
|
||||
navigationBuilder.WithOwner(x => x.User);
|
||||
});
|
||||
|
||||
builder.HasMany(x=>x.RefreshTokens)
|
||||
.WithOne(x=>x.User)
|
||||
.HasForeignKey(x=>x.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
}
|
||||
}
|
||||
30
CompanyManagment.EFCore/PmDbContext.cs
Normal file
30
CompanyManagment.EFCore/PmDbContext.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
namespace CompanyManagment.EFCore;
|
||||
|
||||
public class PmDbContext : DbContext
|
||||
{
|
||||
public PmDbContext(DbContextOptions<PmDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
public DbSet<User> Users { get; set; } = null!;
|
||||
public DbSet<Role> Roles { get; set; } = null!;
|
||||
|
||||
|
||||
public PmDbContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(PmDbContext).Assembly);
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
18
PersonalContractingParty.Config/PmDbBootstrapper.cs
Normal file
18
PersonalContractingParty.Config/PmDbBootstrapper.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using Company.Domain.InsurancJobAgg;
|
||||
using CompanyManagment.App.Contracts.InsuranceJob;
|
||||
using CompanyManagment.Application;
|
||||
using CompanyManagment.EFCore;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace PersonalContractingParty.Config;
|
||||
|
||||
public class PmDbBootstrapper
|
||||
{
|
||||
public static void Configure(IServiceCollection services, string connectionString)
|
||||
{
|
||||
|
||||
services.AddDbContext<TestDbContext>(x => x.UseSqlServer(connectionString));
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddHttpClient("holidayApi", c => c.BaseAddress = new System.Uri("https://api.github.com"));
|
||||
var connectionString = builder.Configuration.GetConnectionString("MesbahDb");
|
||||
var connectionStringTestDb = builder.Configuration.GetConnectionString("TestDb");
|
||||
var connectionStringProgramManager = builder.Configuration.GetConnectionString("ProgramManagerDb");
|
||||
|
||||
#region MongoDb
|
||||
|
||||
@@ -68,6 +69,7 @@ builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
|
||||
builder.Services.AddSingleton<IActionResultExecutor<JsonResult>, CustomJsonResultExecutor>();
|
||||
PersonalBootstrapper.Configure(builder.Services, connectionString);
|
||||
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
|
||||
PmDbBootstrapper.Configure(builder.Services, connectionStringProgramManager);
|
||||
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
|
||||
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
|
||||
QueryBootstrapper.Configure(builder.Services);
|
||||
|
||||
@@ -16,15 +16,17 @@
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=185.208.175.186;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;",
|
||||
|
||||
//dad-mehr
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;"
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
"ProgramManagerDb": "Server=.;Database=program_manager_db;Integrated Security=True;TrustServerCertificate=True;"
|
||||
//mahan Docker
|
||||
//"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user