Add new domain models and interfaces for project management features

This commit is contained in:
2025-12-08 14:47:03 +03:30
parent b7a7fb01d7
commit 27e8a26ed8
295 changed files with 24896 additions and 26 deletions

View File

@@ -0,0 +1,114 @@
using System.Security.Claims;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
/// <summary>
/// رابط کمکی برای کار با JWT و HttpContext
/// این interface فقط متدهای helper دارد و هیچ عملیات دیتابیسی ندارد
/// </summary>
public interface IAuthHelper
{
// ==================== Token Generation ====================
LoginSession SignIn(long userId, string userName, string fullName, long accountId, List<string> roles);
/// <summary>
/// تولید Access Token
/// </summary>
string GenerateAccessToken(long userId, string userName, string fullName, long? accountId, List<string> roles);
/// <summary>
/// تولید Refresh Token
/// </summary>
string GenerateRefreshToken();
/// <summary>
/// دریافت تاریخ انقضای Refresh Token
/// </summary>
DateTime GetRefreshTokenExpiration();
// ==================== Token Validation ====================
/// <summary>
/// اعتبارسنجی توکن و استخراج Claims
/// </summary>
ClaimsPrincipal? ValidateToken(string token);
/// <summary>
/// اعتبارسنجی توکن منقضی شده (بدون چک زمان انقضا)
/// </summary>
ClaimsPrincipal? ValidateExpiredToken(string token);
/// <summary>
/// استخراج UserId از توکن (حتی اگر منقضی شده باشد)
/// </summary>
long? GetUserIdFromToken(string token);
// ==================== HttpContext Helpers ====================
/// <summary>
/// دریافت IP Address کاربر جاری
/// </summary>
string? GetClientIpAddress();
/// <summary>
/// دریافت User Agent کاربر جاری
/// </summary>
string? GetUserAgent();
/// <summary>
/// دریافت Refresh Token از Cookie
/// </summary>
string? GetRefreshTokenFromCookie();
// ==================== Current User Claims ====================
/// <summary>
/// بررسی احراز هویت کاربر جاری
/// </summary>
bool IsAuthenticated();
/// <summary>
/// دریافت شناسه کاربر جاری از Claims
/// </summary>
long? GetCurrentUserId();
/// <summary>
/// دریافت نام کاربری جاری از Claims
/// </summary>
string? GetCurrentUserName();
/// <summary>
/// دریافت نام کامل کاربر جاری از Claims
/// </summary>
string? GetCurrentFullName();
/// <summary>
/// دریافت AccountId کاربر جاری از Claims
/// </summary>
long? GetCurrentAccountId();
/// <summary>
/// دریافت نقش‌های کاربر جاری از Claims
/// </summary>
List<string> GetCurrentUserRoles();
// ==================== Role Checking ====================
/// <summary>
/// بررسی دسترسی کاربر به نقش خاص
/// </summary>
bool HasRole(string roleName);
/// <summary>
/// بررسی دسترسی کاربر به یکی از نقش‌ها
/// </summary>
bool HasAnyRole(params string[] roleNames);
void SignOut();
}
public class LoginSession
{
public string AccessToken { get; set; }
public string RefreshToken { get; set; }
public DateTime RefreshTokenExpiration { get; set; }
public DateTime AccessTokenExpiration { get; set; }
}

View File

@@ -0,0 +1,14 @@
using GozareshgirProgramManager.Application._Common.Models;
using MediatR;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBaseCommand : IRequest<OperationResult>
{
}
public interface IBaseCommand<TResponse> : IRequest<OperationResult<TResponse>>
{
}

View File

@@ -0,0 +1,13 @@
using GozareshgirProgramManager.Application._Common.Models;
using MediatR;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBaseCommandHandler<in TCommand> : IRequestHandler<TCommand, OperationResult>
where TCommand : IBaseCommand
{
}
public interface IBaseCommandHandler<in TCommand, TResponseData> : IRequestHandler<TCommand, OperationResult<TResponseData>>
where TCommand : IBaseCommand<TResponseData>
{
}

View File

@@ -0,0 +1,10 @@
using MediatR;
using GozareshgirProgramManager.Application._Common.Models;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBasePaginationQuery<TResponse> : IRequest<OperationResult<PaginationResult<TResponse>>>
{
int PageIndex { get; set; }
int PageSize { get; set; }
}

View File

@@ -0,0 +1,12 @@
using GozareshgirProgramManager.Application._Common.Models;
using MediatR;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBasePaginationQueryHandler<in TQuery, TResponse>
: IRequestHandler<TQuery, OperationResult<PaginationResult<TResponse>>>
where TQuery : PaginationRequest, IBasePaginationQuery<TResponse>
where TResponse : class
{
}

View File

@@ -0,0 +1,9 @@
using MediatR;
using GozareshgirProgramManager.Application._Common.Models;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBaseQuery<TResponse> : IRequest<OperationResult<TResponse>>
{
}

View File

@@ -0,0 +1,10 @@
using MediatR;
using GozareshgirProgramManager.Application._Common.Models;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IBaseQueryHandler<in TQuery, TResponse> : IRequestHandler<TQuery, OperationResult<TResponse>>
where TQuery : IBaseQuery<TResponse>
{
}

View File

@@ -0,0 +1,12 @@
using GozareshgirProgramManager.Domain.HolidayAgg;
using GozareshgirProgramManager.Domain.HolidayItemAgg;
using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IGozareshgirDbContext
{
DbSet<HolidayItem> HolidayItems { get; set; }
DbSet<Holiday> Holidays { get; set; }
}

View File

@@ -0,0 +1,32 @@
using GozareshgirProgramManager.Domain.CheckoutAgg.Entities;
using GozareshgirProgramManager.Domain.CustomerAgg;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.RoleAgg.Entities;
using GozareshgirProgramManager.Domain.RoleUserAgg;
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities;
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
using GozareshgirProgramManager.Domain.UserAgg.Entities;
using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Application._Common.Interfaces;
public interface IProgramManagerDbContext
{
DbSet<Checkout> Checkouts { set; get; }
DbSet<SalaryPaymentSetting?> SalaryPaymentSettings { set; get; }
DbSet<Role> Roles { get; set; }
DbSet<User> Users { get; set; }
DbSet<UserRefreshToken> RefreshTokens { get; set; }
DbSet<Customer> Customers { get; }
DbSet<Project> Projects { get; set; }
DbSet<ProjectPhase> ProjectPhases { get; set; }
DbSet<TaskSection> TaskSections { get; set; }
DbSet<ProjectSection> ProjectSections { get; set; }
DbSet<PhaseSection> PhaseSections { get; set; }
DbSet<ProjectTask> ProjectTasks { get; set; }
DbSet<Skill> Skills { get; set; }
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}