add version 0.4.6.6
parent
d72bf848b5
commit
cce4acaa00
|
@ -6,8 +6,8 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
<AssemblyVersion>0.3.6.5</AssemblyVersion>
|
||||
<FileVersion>0.3.6.5</FileVersion>
|
||||
<AssemblyVersion>0.4.6.6</AssemblyVersion>
|
||||
<FileVersion>0.4.6.6</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -15,17 +15,17 @@ public class RoleController : ICarterModule
|
|||
|
||||
group.MapGet("/permission", GetPermissions)
|
||||
.WithDisplayName("Permissions")
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles))
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles, ApplicationPermission.ViewRoles))
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("", GetAllAsync)
|
||||
.WithDisplayName("GetAllRoles")
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles))
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles , ApplicationPermission.ViewRoles))
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("{id}", GetAsync)
|
||||
.WithDisplayName("GetOneRole")
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles))
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles, ApplicationPermission.ViewRoles))
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
//group.MapPost("", Post)
|
||||
|
|
|
@ -27,7 +27,6 @@ public class UserController : ICarterModule
|
|||
|
||||
group.MapPost("/role/change/{roleId}", ChangeUserRoleAsync)
|
||||
.WithDisplayName("GetUserProfile")
|
||||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageUsers))
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", Post)
|
||||
|
|
|
@ -176,6 +176,13 @@ public static class ApplicationClaims
|
|||
Title = "مشاهده گزارشات",
|
||||
Detail = "دسترسی به مشاهده گزارشات"
|
||||
};
|
||||
public static ClaimDto ViewRoles { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ViewRoles,
|
||||
Title = "مشاهده نقش ها",
|
||||
Detail = "دسترسی به مشاهده نقش ها"
|
||||
};
|
||||
public static ClaimDto ManageUsers { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
|
@ -201,9 +208,10 @@ public static class ApplicationClaims
|
|||
ManageShiftPlans,
|
||||
ViewShifts,
|
||||
ManageShifts,
|
||||
ViewRoles,
|
||||
|
||||
ManageUsers,
|
||||
ViewUsers
|
||||
ViewUsers,
|
||||
|
||||
ViewComplexes,
|
||||
ManageComplexes,
|
||||
|
@ -233,6 +241,9 @@ public static class ApplicationClaims
|
|||
ViewUsers.GetClaim,
|
||||
ManageUsers.GetClaim,
|
||||
|
||||
|
||||
ViewRoles.GetClaim,
|
||||
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
|
||||
|
@ -245,6 +256,7 @@ public static class ApplicationClaims
|
|||
|
||||
ManageActivities.GetClaim,
|
||||
ViewActivities.GetClaim,
|
||||
ChangeActivityStatus.GetClaim,
|
||||
|
||||
ManageRoutines.GetClaim,
|
||||
ViewRoutines.GetClaim,
|
||||
|
@ -267,10 +279,13 @@ public static class ApplicationClaims
|
|||
|
||||
ManageActivities.GetClaim,
|
||||
ViewActivities.GetClaim,
|
||||
ChangeActivityStatus.GetClaim,
|
||||
|
||||
ViewUsers.GetClaim,
|
||||
ManageUsers.GetClaim,
|
||||
|
||||
ViewRoles.GetClaim,
|
||||
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
|
||||
|
@ -295,6 +310,8 @@ public static class ApplicationClaims
|
|||
|
||||
public static List<Claim> ViewerOwnerClaims = new List<Claim>
|
||||
{
|
||||
ManageReports.GetClaim,
|
||||
|
||||
ViewStaffs.GetClaim,
|
||||
|
||||
ViewActivities.GetClaim,
|
||||
|
|
|
@ -3,6 +3,7 @@ public static class ApplicationPermission
|
|||
{
|
||||
public const string ManageReports = nameof(ManageReports);
|
||||
public const string ManageRoles = nameof(ManageRoles);
|
||||
public const string ViewRoles = nameof(ViewRoles);
|
||||
|
||||
public const string ManageUsers = nameof(ManageUsers);
|
||||
public const string ViewUsers = nameof(ViewUsers);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<Using Include="Brizco.Core.CoreServices.ReportServices.Commands" />
|
||||
<Using Include="Brizco.Core.EntityServices.Abstracts" />
|
||||
<Using Include="Brizco.Domain.CommandQueries.Commands" />
|
||||
<Using Include="Brizco.Domain.CommandQueries.Queries" />
|
||||
<Using Include="Brizco.Domain.Dtos.LargDtos" />
|
||||
<Using Include="Brizco.Domain.Dtos.PageDto" />
|
||||
<Using Include="Brizco.Domain.Dtos.RequestDtos" />
|
||||
|
@ -47,6 +48,7 @@
|
|||
<Using Include="Brizco.Domain.Mappers" />
|
||||
<Using Include="Brizco.Repository.Abstracts" />
|
||||
<Using Include="Brizco.Repository.Repositories.Base.Contracts" />
|
||||
<Using Include="Mapster" />
|
||||
<Using Include="MediatR" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore" />
|
||||
|
@ -54,6 +56,7 @@
|
|||
<Using Include="NPOI.SS.UserModel" />
|
||||
<Using Include="NPOI.SS.Util" />
|
||||
<Using Include="NPOI.XSSF.UserModel" />
|
||||
<Using Include="System.Security.Claims" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ComplexService : IComplexService
|
|||
if (!createViewerResult.Succeeded)
|
||||
throw new AppException(string.Join('|', createViewerResult.Errors));
|
||||
|
||||
foreach (var claim in ApplicationClaims.ManagerClaims)
|
||||
foreach (var claim in ApplicationClaims.ViewerOwnerClaims)
|
||||
await _roleManager.AddClaimAsync(viewOwnerRole, claim);
|
||||
|
||||
var superVisorRole = new ApplicationRole
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using System.Security.Claims;
|
||||
using Brizco.Domain.CommandQueries.Queries;
|
||||
using Brizco.Domain.Mappers;
|
||||
using Mapster;
|
||||
|
||||
namespace Brizco.Core.EntityServices;
|
||||
namespace Brizco.Core.EntityServices;
|
||||
|
||||
public class UserService : IUserService
|
||||
{
|
||||
|
@ -37,6 +32,8 @@ public class UserService : IUserService
|
|||
var user = await _userManager.FindByIdAsync(userId.ToString());
|
||||
if (user == null)
|
||||
throw new AppException("User NotFound", ApiResultStatusCode.NotFound);
|
||||
if (user.SignUpStatus < SignUpStatus.ComplexCreated)
|
||||
throw new UnauthorizedAccessException("SignUp is not completed");
|
||||
|
||||
var response = new ProfileResponseDto();
|
||||
|
||||
|
@ -87,7 +84,21 @@ public class UserService : IUserService
|
|||
|
||||
if (!Guid.TryParse(_currentUserService.UserId, out var userId))
|
||||
throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized);
|
||||
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out var complexId))
|
||||
throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized);
|
||||
|
||||
AccessToken<ApplicationUserSDto, ComplexUserRoleSDto> jwt;
|
||||
|
||||
|
||||
var complexUser = await _repositoryWrapper.SetRepository<ComplexUser>()
|
||||
.TableNoTracking
|
||||
.Where(mcu => mcu.UserId == userId && mcu.ComplexId == complexId)
|
||||
.Select(ComplexUserMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (complexUser == null)
|
||||
throw new AppException("User role is wrong", ApiResultStatusCode.BadRequest);
|
||||
|
||||
var complexUserRole = await _repositoryWrapper.SetRepository<ComplexUserRole>()
|
||||
.TableNoTracking
|
||||
.Where(c => c.Id == roleId)
|
||||
|
@ -97,17 +108,9 @@ public class UserService : IUserService
|
|||
if (complexUserRole == null)
|
||||
throw new AppException("Role not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var complexUser = await _repositoryWrapper.SetRepository<ComplexUser>()
|
||||
.TableNoTracking
|
||||
.Where(mcu => mcu.Id == complexUserRole.ComplexUserId)
|
||||
.Select(ComplexUserMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
var user = await _userManager.FindByIdAsync(userId.ToString());
|
||||
if (user == null)
|
||||
throw new AppException("User not found", ApiResultStatusCode.NotFound);
|
||||
if (complexUser?.UserId != user.Id)
|
||||
throw new AppException("User role is wrong", ApiResultStatusCode.BadRequest);
|
||||
|
||||
user.SelectedComplexUserRoleId = complexUserRole.Id;
|
||||
await _userManager.UpdateAsync(user);
|
||||
|
|
|
@ -9,6 +9,7 @@ public class ShiftPlanSDto : BaseDto<ShiftPlanSDto,ShiftPlan>
|
|||
public int UndoneActivitiesCount { get; set; }
|
||||
public int DoneActivitiesCount { get; set; }
|
||||
public int TotalActivitiesCount { get; set; }
|
||||
public int StaffCount { get; set; }
|
||||
public int CompletePercent { get; internal set; }
|
||||
public string CompleteDescription { get; internal set; } = string.Empty;
|
||||
public Guid ShiftId { get; set; }
|
||||
|
|
|
@ -61,9 +61,22 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
|
|||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(ShiftMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
}
|
||||
|
||||
foreach (var shift in shifts)
|
||||
{
|
||||
var shiftDays = new List<DayOfWeek>();
|
||||
shift.Days.OrderBy(d=>d).ToList().ForEach(d =>
|
||||
{
|
||||
if(d==DayOfWeek.Saturday)
|
||||
shiftDays.Insert(0,d);
|
||||
else{
|
||||
shiftDays.Add(d);}
|
||||
|
||||
});
|
||||
shift.Days = shiftDays;
|
||||
}
|
||||
|
||||
return shifts;
|
||||
}
|
||||
|
|
|
@ -112,6 +112,13 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftPlansQuery, Lis
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var shiftPlan in shiftPlans)
|
||||
{
|
||||
shiftPlan.StaffCount = await _repositoryWrapper.SetRepository<ShiftPlanUser>()
|
||||
.TableNoTracking
|
||||
.CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken);
|
||||
}
|
||||
|
||||
return shiftPlans;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue