Revert "feat: introduce Shared.Contracts for account management and refactor related services"
This reverts commit 9469a5f76e.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using GozareshgirProgramManager.Domain.RoleAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
||||
|
||||
public class RoleRepository : RepositoryBase<long, Role>, IRoleRepository
|
||||
{
|
||||
private readonly ProgramManagerDbContext _context;
|
||||
public RoleRepository(ProgramManagerDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Role?> GetByGozareshgirRoleIdAsync(long? gozareshgirRolId)
|
||||
{
|
||||
return await _context.Roles.FirstOrDefaultAsync(x => x.GozareshgirRoleId == gozareshgirRolId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.DTOs;
|
||||
using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetSalarySettingToEdit;
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.DTOs;
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.Contracts.Account;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
||||
|
||||
public class SalaryPaymentSettingRepository : RepositoryBase<long, SalaryPaymentSetting>, ISalaryPaymentSettingRepository
|
||||
{
|
||||
private readonly ProgramManagerDbContext _context;
|
||||
private readonly IAccountQueryService _accountQueryService;
|
||||
|
||||
public SalaryPaymentSettingRepository(ProgramManagerDbContext context, IAccountQueryService accountQueryService) : base(context)
|
||||
public SalaryPaymentSettingRepository(ProgramManagerDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_accountQueryService = accountQueryService;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,36 +25,31 @@ public class SalaryPaymentSettingRepository : RepositoryBase<long, SalaryPayment
|
||||
|
||||
public async Task<List<UserSalarySettingDto>> GetAllSettings(List<long> userIdList)
|
||||
{
|
||||
// دریافت تنظیمات حقوق
|
||||
var settings = await _context.SalaryPaymentSettings
|
||||
.AsNoTracking()
|
||||
.Where(s => userIdList.Contains(s.AccountId))
|
||||
_context.SalaryPaymentSettings.AsNoTracking();
|
||||
var query = await _context.SalaryPaymentSettings.Where(s=> userIdList.Contains(s.AccountId))
|
||||
.Join(_context.Users.AsNoTracking(),
|
||||
setting => setting.AccountId,
|
||||
user => user.Id,
|
||||
(setting, user) => new { setting, user }
|
||||
)
|
||||
.Select(x => new UserSalarySettingDto
|
||||
{
|
||||
UserId = x.user.Id,
|
||||
HolidayWorking = x.setting!.HolidayWorking,
|
||||
FullName = x.user.FullName,
|
||||
MonthlySalary = x.setting.MonthlySalary,
|
||||
WorkingHoursListDto = x.setting.WorkingHoursList
|
||||
.Where(wh => wh.IsActiveDay)
|
||||
.Select(wh => new WorkingHoursListDto()
|
||||
{
|
||||
ShiftDuration = wh.ShiftDuration,
|
||||
PersianDayOfWeek = wh.PersianDayOfWeek
|
||||
}).ToList()
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// دریافت اطلاعات پایه کاربران از ACL
|
||||
var accountIds = settings.Select(s => s.AccountId).Distinct().ToList();
|
||||
var accounts = await _accountQueryService.GetProgramManagerAccountListAsync(accountIds);
|
||||
var accountDictionary = accounts.ToDictionary(a => a.Id, a => a);
|
||||
return query;
|
||||
|
||||
// ترکیب دادهها
|
||||
var result = settings.Select(setting => new UserSalarySettingDto
|
||||
{
|
||||
UserId = setting.AccountId,
|
||||
HolidayWorking = setting.HolidayWorking,
|
||||
FullName = accountDictionary.ContainsKey(setting.AccountId)
|
||||
? accountDictionary[setting.AccountId].Username
|
||||
: "Unknown",
|
||||
MonthlySalary = setting.MonthlySalary,
|
||||
WorkingHoursListDto = setting.WorkingHoursList
|
||||
.Where(wh => wh.IsActiveDay)
|
||||
.Select(wh => new WorkingHoursListDto
|
||||
{
|
||||
ShiftDuration = wh.ShiftDuration,
|
||||
PersianDayOfWeek = wh.PersianDayOfWeek
|
||||
}).ToList()
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void RemoveRangeSalarySettings(List<SalaryPaymentSetting> removedItems)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Linq.Expressions;
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
||||
|
||||
public class UserRefreshTokenRepository : RepositoryBase<Guid, UserRefreshToken>, IUserRefreshTokenRepository
|
||||
{
|
||||
private readonly ProgramManagerDbContext _context;
|
||||
public UserRefreshTokenRepository(ProgramManagerDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
||||
|
||||
public class UserRepository : RepositoryBase<long, User>, IUserRepository
|
||||
{
|
||||
private readonly ProgramManagerDbContext _context;
|
||||
public UserRepository(ProgramManagerDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Task<User?> GetByIdAsync(long id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<User?> GetByGozareshgirAccountId(long accountId)
|
||||
{
|
||||
return await _context.Users.FirstOrDefaultAsync(x => x.AccountId == accountId);
|
||||
}
|
||||
|
||||
public Task<User?> GetByEmailAsync(string email)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<User?> GetByMobileAsync(string mobile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<User>> GetAllAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<User>> GetActiveUsersAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<User> AddAsync(User user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Update(User user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Delete(User user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> ExistsAsync(long id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> UsernameExistsAsync(string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> EmailExistsAsync(string email)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> MobileExistsAsync(string mobile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserWithRolesByIdAsync(long userId, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Users.Include(x => x.RoleUser)
|
||||
.FirstOrDefaultAsync(x=>x.Id == userId, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user