Skip to content

Commit

Permalink
.11
Browse files Browse the repository at this point in the history
  • Loading branch information
akbaramd committed Nov 3, 2024
1 parent 294629e commit f36e9fa
Show file tree
Hide file tree
Showing 56 changed files with 3,512 additions and 48 deletions.
23 changes: 23 additions & 0 deletions .idea/.idea.Nezam.ESS/.idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.Nezam.ESS/.idea/easycode/codebase-v2.xml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .idea/.idea.Nezam.ESS/.idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Nezam.Modular.ESS.Identity.Application/Auth/AuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
using Bonyan.Layer.Application.Services;
using Bonyan.Security.Claims;
using Bonyan.UserManagement.Application.Dtos;
using Bonyan.UserManagement.Domain.Enumerations;
using Bonyan.UserManagement.Domain.Repositories;
using FastEndpoints.Security;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using Nezam.Modular.ESS.Identity.Application.Auth.Dto;
using Nezam.Modular.ESS.Identity.Application.Users.Dto;
using Nezam.Modular.ESS.Identity.Application.Users.Specs;
using Nezam.Modular.ESS.Identity.Domain.User;

namespace Nezam.Modular.ESS.Identity.Application.Auth
Expand Down Expand Up @@ -50,19 +53,21 @@ public async Task<AuthJwtResult> LoginAsync(AuthLoginDto authLoginDto,
o.User.Claims.Add((BonyanClaimTypes.Email, user.Email?.Address.ToString() ?? ""));
});



user.ChangeStatus(UserStatus.Active);
await UserRepository.UpdateAsync(user);
return new AuthJwtResult
{
AccessToken = jwtToken,
UserId = user.Id
};
}

public async Task<BonyanUserDto> CurrentUserProfileAsync(CancellationToken cancellationToken = default)
public async Task<UserDtoWithDetail> CurrentUserProfileAsync(CancellationToken cancellationToken = default)
{
var user = await UserRepository.FindOneAsync(x => x.UserName == CurrentUser.UserName);
var user = await UserRepository.FindOneAsync(new UserByUsernameSpec(CurrentUser.UserName));

return Mapper.Map<UserEntity, BonyanUserDto>(user ?? throw new InvalidOperationException());
return Mapper.Map<UserEntity, UserDtoWithDetail>(user ?? throw new InvalidOperationException());
}

public async Task<AuhForgetPasswordResult> ForgetPasswordAsync(AuhForgetPasswordDto forgetPasswordDto,
Expand Down
4 changes: 2 additions & 2 deletions Nezam.Modular.ESS.Identity.Application/Auth/IAuthService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Bonyan.Layer.Application.Services;
using Bonyan.UserManagement.Application.Dtos;
using Nezam.Modular.ESS.Identity.Application.Auth.Dto;
using Nezam.Modular.ESS.Identity.Application.Users.Dto;

namespace Nezam.Modular.ESS.Identity.Application.Auth;

Expand All @@ -10,8 +11,7 @@ public Task<AuthJwtResult>
LoginAsync(AuthLoginDto authLoginDto,CancellationToken cancellationToken = default);


public Task<BonyanUserDto>
CurrentUserProfileAsync(CancellationToken cancellationToken = default);
public Task<UserDtoWithDetail> CurrentUserProfileAsync(CancellationToken cancellationToken = default);

public Task<AuhForgetPasswordResult>
ForgetPasswordAsync(AuhForgetPasswordDto forgetPasswordDto,CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Bonyan.Layer.Application.Dto;
using FastEndpoints;
using Nezam.Modular.ESS.Identity.Domain.Employer;

namespace Nezam.Modular.ESS.Identity.Application.Employers.Dtos;

public class EmployerDto : EntityDto<EmployerId>
{
public string FirstName { get; set; }
public string LastName { get; set; }
}

public class EmployerFilterDto
{

[QueryParam]
public int Take { get; set; }
[QueryParam]
public int Skip { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AutoMapper;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Employers.Dtos;
using Nezam.Modular.ESS.Identity.Domain.Employer;

namespace Nezam.Modular.ESS.Identity.Application.Employers;

public class EmployerProfile : Profile
{
public EmployerProfile()
{
CreateMap<EmployerEntity,EmployerDto>();
CreateMap<PaginatedResult<EmployerEntity>,PaginatedResult<EmployerDto>>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Bonyan.Layer.Application.Services;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Employers.Dtos;
using Nezam.Modular.ESS.Identity.Application.Employers.Specs;
using Nezam.Modular.ESS.Identity.Domain.Employer;

namespace Nezam.Modular.ESS.Identity.Application.Employers;

public class EmployerService : ApplicationService, IEmployerService
{
public IEmployerRepository EmployerRepository => LazyServiceProvider.LazyGetRequiredService<IEmployerRepository>();

public async Task<PaginatedResult<EmployerDto>> GetPaginatedResult(EmployerFilterDto filterDto)
{
var res = await EmployerRepository.PaginatedAsync(new EmployerFilterSpec(filterDto));
return Mapper.Map<PaginatedResult<EmployerEntity>,PaginatedResult<EmployerDto>>(res);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Bonyan.Layer.Application.Services;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Employers.Dtos;

namespace Nezam.Modular.ESS.Identity.Application.Employers;

public interface IEmployerService : IApplicationService
{
Task<PaginatedResult<EmployerDto>> GetPaginatedResult(EmployerFilterDto filterDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Nezam.Modular.ESS.Identity.Application.Employers.Jobs
{
[CronJob("* 1 * * *")]
public class EmployerSynchronizerJob : IJob
{
private readonly IEmployerRepository _employerRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Bonyan.Layer.Domain.Specifications;
using Nezam.Modular.ESS.Identity.Application.Employers.Dtos;
using Nezam.Modular.ESS.Identity.Application.Users.Dto;
using Nezam.Modular.ESS.Identity.Domain.Employer;
using Nezam.Modular.ESS.Identity.Domain.Engineer;

namespace Nezam.Modular.ESS.Identity.Application.Employers.Specs;

public class EmployerFilterSpec : PaginatedSpecification<EmployerEntity>
{
public EmployerFilterSpec(EmployerFilterDto dto) : base(dto.Skip,dto.Take)
{
}

public override void Handle(ISpecificationContext<EmployerEntity> context)
{
context
.AddInclude(x => x.User);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Bonyan.Layer.Application.Dto;
using FastEndpoints;
using Nezam.Modular.ESS.Identity.Application.Users.Dto;
using Nezam.Modular.ESS.Identity.Domain.Engineer;

namespace Nezam.Modular.ESS.Identity.Application.Engineers.Dtos;

public class EngineerDto : EntityDto<EngineerId>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string RegistrationNumber { get; set; }
}

public class EngineerDtoWithDetails : EngineerDto
{
public UserDto User { get; set; }
}

public class EngineerFilterDto
{

[QueryParam]
public int Take { get; set; }
[QueryParam]
public int Skip { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using AutoMapper;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Engineers.Dtos;
using Nezam.Modular.ESS.Identity.Domain.Engineer;

namespace Nezam.Modular.ESS.Identity.Application.Engineers;

public class EngineerProfile : Profile
{
public EngineerProfile()
{
CreateMap<EngineerEntity,EngineerDto>();
CreateMap<EngineerEntity,EngineerDtoWithDetails>();
CreateMap<PaginatedResult<EngineerEntity>,PaginatedResult<EngineerDto>>();
CreateMap<PaginatedResult<EngineerEntity>,PaginatedResult<EngineerDtoWithDetails>>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Bonyan.Layer.Application.Services;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Engineers.Dtos;
using Nezam.Modular.ESS.Identity.Application.Engineers.Specs;
using Nezam.Modular.ESS.Identity.Domain.Engineer;

namespace Nezam.Modular.ESS.Identity.Application.Engineers;

public class EngineerService : ApplicationService, IEngineerService
{
public IEngineerRepository EngineerRepository => LazyServiceProvider.LazyGetRequiredService<IEngineerRepository>();

public async Task<PaginatedResult<EngineerDtoWithDetails>> GetPaginatedResult(EngineerFilterDto filterDto)
{
var res = await EngineerRepository.PaginatedAsync(new EngineerFilterSpec(filterDto));
return Mapper.Map<PaginatedResult<EngineerEntity>,PaginatedResult<EngineerDtoWithDetails>>(res);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Bonyan.Layer.Application.Services;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Engineers.Dtos;

namespace Nezam.Modular.ESS.Identity.Application.Engineers;

public interface IEngineerService : IApplicationService
{
Task<PaginatedResult<EngineerDtoWithDetails>> GetPaginatedResult(EngineerFilterDto filterDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Nezam.Modular.ESS.Identity.Application.Engineers.Jobs
{
[CronJob("* 1 * * *")]
public class EngineerSynchronizerJob : IJob
{
private readonly IEngineerRepository _engineerRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Bonyan.Layer.Domain.Specifications;
using Nezam.Modular.ESS.Identity.Application.Engineers.Dtos;
using Nezam.Modular.ESS.Identity.Application.Users.Dto;
using Nezam.Modular.ESS.Identity.Domain.Engineer;
using Nezam.Modular.ESS.Identity.Domain.User;

namespace Nezam.Modular.ESS.Identity.Application.Engineers.Specs;

public class EngineerFilterSpec : PaginatedSpecification<EngineerEntity>
{
public EngineerFilterSpec(EngineerFilterDto dto) : base(dto.Skip,dto.Take)
{
}

public override void Handle(ISpecificationContext<EngineerEntity> context)
{
context
.AddInclude(x => x.User);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
using Bonyan.UserManagement.Application;
using Microsoft.Extensions.DependencyInjection;
using Nezam.Modular.ESS.Identity.Application.Auth;
using Nezam.Modular.ESS.Identity.Application.Employers;
using Nezam.Modular.ESS.Identity.Application.Employers.Jobs;
using Nezam.Modular.ESS.Identity.Application.Engineers;
using Nezam.Modular.ESS.Identity.Application.Engineers.Jobs;
using Nezam.Modular.ESS.Identity.Application.Roles;
using Nezam.Modular.ESS.Identity.Application.Users;
using Nezam.Modular.ESS.Identity.Domain;
using Nezam.Modular.ESS.Identity.Domain.User;

Expand All @@ -22,12 +26,23 @@ public NezamEssIdentityApplicationModule()
public override Task OnConfigureAsync(ServiceConfigurationContext context)
{
context.Services.AddTransient<IAuthService, AuthService>();
context.Services.AddTransient<IRoleService, RoleService>();
context.Services.AddTransient<IUserService, UserService>();
context.Services.AddTransient<IEmployerService, EmployerService>();
context.Services.AddTransient<IEngineerService, EngineerService>();

context.Services.Configure<BonyanAutoMapperOptions>(c => { c.AddProfile<AuthProfile>(); });
context.Services.Configure<BonyanAutoMapperOptions>(c =>
{
c.AddProfile<AuthProfile>();
c.AddProfile<RoleProfile>();
c.AddProfile<UserProfile>();
c.AddProfile<EngineerProfile>();
c.AddProfile<EmployerProfile>();
});

// context.AddJob<EngineerSynchronizerJob>();
context.AddJob<EmployerSynchronizerJob>();
// context.AddJob<EmployerSynchronizerJob>();

return base.OnConfigureAsync(context);
}
}
20 changes: 20 additions & 0 deletions Nezam.Modular.ESS.Identity.Application/Roles/Dto/RoleDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using Bonyan.Layer.Application.Dto;
using FastEndpoints;
using Nezam.Modular.ESS.Identity.Domain.Roles;

namespace Nezam.Modular.ESS.Identity.Application.Roles.Dto;

public class RoleDto : EntityDto<RoleId>
{
public string Name { get; set; }
public string Title { get; set; }
}
public class RoleFilterDto
{

[QueryParam]
public int Take { get; set; }
[QueryParam]
public int Skip { get; set; }
}
11 changes: 11 additions & 0 deletions Nezam.Modular.ESS.Identity.Application/Roles/IRoleService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using Bonyan.Layer.Application.Services;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Roles.Dto;

namespace Nezam.Modular.ESS.Identity.Application.Roles;

public interface IRoleService : IApplicationService
{
Task<PaginatedResult<RoleDto>> GetPaginatedResult(RoleFilterDto filterDto);
}
16 changes: 16 additions & 0 deletions Nezam.Modular.ESS.Identity.Application/Roles/RoleProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using AutoMapper;
using Bonyan.Layer.Domain.Model;
using Nezam.Modular.ESS.Identity.Application.Roles.Dto;
using Nezam.Modular.ESS.Identity.Domain.Roles;

namespace Nezam.Modular.ESS.Identity.Application.Roles;

public class RoleProfile : Profile
{
public RoleProfile()
{
CreateMap<RoleEntity,RoleDto>();
CreateMap<PaginatedResult<RoleEntity>,PaginatedResult<RoleDto>>();
}
}
Loading

0 comments on commit f36e9fa

Please sign in to comment.