add version 0.1.0.0

release/production
Amir Hossein Khademi 2023-10-18 17:19:56 +03:30
parent 49bb2d2b09
commit d5834894d0
28 changed files with 2530 additions and 33 deletions

1
.version 100644
View File

@ -0,0 +1 @@
0.1.0.0

View File

@ -13,7 +13,7 @@
}
},
"SiteSettings": {
"BaseUrl": "http://localhost:32769",
"BaseUrl": "http://192.168.88.12:32769",
"UserSetting": {
"Username": "root",
"Email": "info@brizco.io",

View File

@ -6,6 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -1,4 +1,6 @@
namespace Brizco.Api.Controllers;
using Brizco.Core.EntityServices;
namespace Brizco.Api.Controllers;
public class RoleController : ICarterModule
{
@ -11,6 +13,10 @@ public class RoleController : ICarterModule
.MapGroup($"api/role")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
group.MapGet("/permission", GetPermissions)
.WithDisplayName("Permissions")
.HasApiVersion(1.0);
group.MapGet("", GetAllAsync)
.WithDisplayName("GetAllRoles")
.HasApiVersion(1.0);
@ -48,4 +54,7 @@ public class RoleController : ICarterModule
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IUserService userService, CancellationToken cancellationToken)
=> TypedResults.Ok(await userService.RemoveRoleAsync(id));
public IResult GetPermissions(IUserService userService)
=> TypedResults.Ok(userService.GetPermissions());
}

View File

@ -26,7 +26,7 @@ public class CreateComplexUserCommandHandler : IRequestHandler<CreateComplexUser
{
try
{
await _repositoryWrapper.BeginTransaction(cancellationToken);
//await _repositoryWrapper.BeginTransaction(cancellationToken);
var complex = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Complex>().TableNoTracking
.FirstOrDefaultAsync(c => c.Id == request.ComplexId, cancellationToken);
if (complex == null)
@ -53,7 +53,7 @@ public class CreateComplexUserCommandHandler : IRequestHandler<CreateComplexUser
_repositoryWrapper.SetRepository<ComplexUser>().Add(complexUser);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _repositoryWrapper.CommitAsync(cancellationToken);
//await _repositoryWrapper.CommitAsync(cancellationToken);
return complexUser.AdaptToSDto();
}
catch (Exception)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class editTask : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TaskDays",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DayOfWeek = table.Column<int>(type: "integer", nullable: false),
TaskId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskDays", x => x.Id);
table.ForeignKey(
name: "FK_TaskDays_Tasks_TaskId",
column: x => x.TaskId,
principalSchema: "public",
principalTable: "Tasks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_TaskDays_TaskId",
schema: "public",
table: "TaskDays",
column: "TaskId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TaskDays",
schema: "public");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class editUserNationalId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "InternationalId",
schema: "public",
table: "Users",
newName: "NationalId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "NationalId",
schema: "public",
table: "Users",
newName: "InternationalId");
}
}
}

View File

@ -431,6 +431,49 @@ namespace Brizco.Repository.Migrations
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DayOfWeek")
.HasColumnType("integer");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("TaskId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TaskId");
b.ToTable("TaskDays", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b =>
{
b.Property<Guid>("Id")
@ -640,10 +683,6 @@ namespace Brizco.Repository.Migrations
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("InternationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
@ -654,6 +693,10 @@ namespace Brizco.Repository.Migrations
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
@ -920,6 +963,17 @@ namespace Brizco.Repository.Migrations
b.Navigation("Complex");
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b =>
{
b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Days")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Task");
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b =>
{
b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role")
@ -1067,6 +1121,8 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b =>
{
b.Navigation("Days");
b.Navigation("Roles");
b.Navigation("Shifts");

View File

@ -62,6 +62,19 @@ public static class ApplicationClaims
Detail = "دسترسی به افزودن و مدیریت فعالیت ها فروشگاه شما"
};
public static List<ClaimDto> AllClaimDtos = new List<ClaimDto>
{
ManageActivities,
ViewTasks,
ManageTasks,
ManageShiftPlans,
ViewShifts,
ManageShifts,
ViewComplexes,
ManageComplexes,
};
public static List<Claim> AllClaims = new List<Claim>
{

View File

@ -129,6 +129,7 @@ public class JwtService : IJwtService
var claims = new List<Claim>();
claims.Add(new Claim("JwtID", jwtId));
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
claims.Add(new Claim("SignUpStatus", ((int)baseUser.SignUpStatus).ToString()));
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
if (baseUser.Email != null)
claims.Add(new Claim(ClaimTypes.Email, baseUser.Email));
@ -142,6 +143,7 @@ public class JwtService : IJwtService
var applicationRole = await _roleManager.FindByIdAsync(roleId);
var roleClaims = await _roleManager.GetClaimsAsync(applicationRole);
var claims = new List<Claim>();
claims.Add(new Claim("SignUpStatus",((int)baseUser.SignUpStatus).ToString()));
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
claims.Add(new Claim(ClaimTypes.Role,applicationRole.EnglishName));

View File

@ -35,6 +35,7 @@
<Using Include="Brizco.Core.EntityServices.Abstracts" />
<Using Include="Brizco.Domain.CommandQueries.Commands" />
<Using Include="Brizco.Domain.Dtos.RequestDtos" />
<Using Include="Brizco.Domain.Dtos.ResponseDto" />
<Using Include="Brizco.Domain.Dtos.SmallDtos" />
<Using Include="Brizco.Domain.Entities.Complex" />
<Using Include="Brizco.Domain.Entities.User" />

View File

@ -4,7 +4,7 @@ public interface IAccountService : IScopedDependency
{
public Task<AccessToken<ApplicationUserSDto>> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken);
public Task<AccessToken<ApplicationUserSDto>> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken);
public Task<SignUpStatus> GetVerifyCodeAsync(string phoneNumber);
public Task<VerifyCodeResponseDto> GetVerifyCodeAsync(string phoneNumber);
public Task<bool> ForgetPasswordAsync(string phoneNumber);
public Task<bool> CheckMemberShipAsync(string phoneNumber);
public Task<AccessToken<ApplicationUserSDto>> CompleteComplexSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken);

View File

@ -64,7 +64,7 @@ public class AccountService : IAccountService
return true;
}
public async Task<SignUpStatus> GetVerifyCodeAsync(string phoneNumber)
public async Task<VerifyCodeResponseDto> GetVerifyCodeAsync(string phoneNumber)
{
var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber);
if (!PhoneNumberExtensions.CheckPhoneNumber(newPhoneNumber))
@ -74,8 +74,8 @@ public class AccountService : IAccountService
user = await _userService.CreateUserAsync(phoneNumber);
var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone");
await _smsService.SendVerifyCodeAsync(newPhoneNumber, token);
return user.SignUpStatus;
//await _smsService.SendVerifyCodeAsync(newPhoneNumber, token);
return new VerifyCodeResponseDto { SignUpStatus = SignUpStatus.StartSignOn };
}
public async Task<AccessToken<ApplicationUserSDto>> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken)
@ -133,12 +133,14 @@ public class AccountService : IAccountService
throw new AppException("آدرس مجموعه را وارد کنید");
user.FirstName = requestDto.FirstName;
user.LastName = requestDto.LastName;
user.SignUpStatus = SignUpStatus.ComplexCreated;
var result = await _userManager.UpdateAsync(user);
if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors));
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
var complex = await _complexService.CreateComplexAsync(requestDto.ComplexName,
requestDto.ComplexAddress,

View File

@ -16,4 +16,5 @@ public interface IUserService : IScopedDependency
Task<ApplicationRole> CreateRoleAsync(RoleActionRequestDto request);
Task<bool> EditRoleAsync(RoleActionRequestDto request);
Task<bool> RemoveRoleAsync(Guid roleId);
List<ClaimDto> GetPermissions();
}

View File

@ -44,7 +44,7 @@ public class UserService : IUserService
{
UserName = phoneNumber,
PhoneNumber = phoneNumber,
SignUpStatus = SignUpStatus.StartSignUp
SignUpStatus = SignUpStatus.StartSignOn
};
var result = await _userManager.CreateAsync(user);
if (!result.Succeeded)
@ -65,7 +65,7 @@ public class UserService : IUserService
PhoneNumber = request.PhoneNumber,
FirstName = request.FirstName,
LastName = request.LastName,
InternationalId = request.InternationalId,
NationalId = request.NationalId,
BirthDate = request.BirthDate,
Gender = request.Gender,
SignUpStatus = SignUpStatus.SignUpCompleted
@ -105,7 +105,7 @@ public class UserService : IUserService
user.PhoneNumber = request.PhoneNumber;
user.FirstName = request.FirstName;
user.LastName = request.LastName;
user.InternationalId = request.InternationalId;
user.NationalId = request.NationalId;
user.BirthDate = request.BirthDate;
user.Gender = request.Gender;
@ -140,7 +140,7 @@ public class UserService : IUserService
user.PhoneNumber = request.PhoneNumber;
user.FirstName = request.FirstName;
user.LastName = request.LastName;
user.InternationalId = request.InternationalId;
user.NationalId = request.NationalId;
user.BirthDate = request.BirthDate;
user.Gender = request.Gender;
@ -284,4 +284,8 @@ public class UserService : IUserService
return true;
}
public List<ClaimDto> GetPermissions()
{
return ApplicationClaims.AllClaimDtos;
}
}

View File

@ -7,7 +7,7 @@ public class UserActionRequestDto
public string LastName { get; set; } = string.Empty;
public DateTime BirthDate { get; set; }
public Gender Gender { get; set; }
public string InternationalId { get; set; } = string.Empty;
public string NationalId { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public List<Guid> RoleIds { get; set; } = new();

View File

@ -0,0 +1,6 @@
namespace Brizco.Domain.Dtos.ResponseDto;
public class VerifyCodeResponseDto
{
public SignUpStatus SignUpStatus { get; set; }
}

View File

@ -12,5 +12,5 @@ public class ApplicationUserSDto : BaseDto<ApplicationUserSDto,ApplicationUser>
public SignUpStatus SignUpStatus { get; set; }
public string SelectedRoleName { get; set; } = string.Empty;
public string SelectedComplexName { get; set; } = string.Empty;
public string InternationalId { get; set; } = string.Empty;
public string NationalId { get; set; } = string.Empty;
}

View File

@ -1,6 +1,6 @@
namespace Brizco.Domain.Entities.Task;
public class TaskDay
public class TaskDay : ApiEntity
{
public TaskDay()
{

View File

@ -6,7 +6,7 @@ public class ApplicationUser : IdentityUser<Guid>
{
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string InternationalId { get; set; } = string.Empty;
public string NationalId { get; set; } = string.Empty;
public DateTime BirthDate { get; set; }
public Gender Gender { get; set; }
public SignUpStatus SignUpStatus { get; set; }

View File

@ -2,7 +2,7 @@
public enum SignUpStatus
{
StartSignUp = 0,
StartSignOn = 0,
PhoneNumberVerified = 1,
ComplexCreated = 2,
SignUpCompleted = 3,

View File

@ -13,7 +13,7 @@ namespace Brizco.Domain.Mappers
{
FirstName = p1.FirstName,
LastName = p1.LastName,
InternationalId = p1.InternationalId,
NationalId = p1.NationalId,
BirthDate = p1.BirthDate,
Gender = p1.Gender,
SignUpStatus = p1.SignUpStatus,
@ -31,7 +31,7 @@ namespace Brizco.Domain.Mappers
result.FirstName = p2.FirstName;
result.LastName = p2.LastName;
result.InternationalId = p2.InternationalId;
result.NationalId = p2.NationalId;
result.BirthDate = p2.BirthDate;
result.Gender = p2.Gender;
result.SignUpStatus = p2.SignUpStatus;
@ -44,7 +44,7 @@ namespace Brizco.Domain.Mappers
{
FirstName = p4.FirstName,
LastName = p4.LastName,
InternationalId = p4.InternationalId,
NationalId = p4.NationalId,
BirthDate = p4.BirthDate,
Gender = p4.Gender,
SignUpStatus = p4.SignUpStatus,
@ -61,7 +61,7 @@ namespace Brizco.Domain.Mappers
BirthDate = p5.BirthDate,
Gender = p5.Gender,
SignUpStatus = p5.SignUpStatus,
InternationalId = p5.InternationalId,
NationalId = p5.NationalId,
Id = p5.Id
};
}
@ -79,7 +79,7 @@ namespace Brizco.Domain.Mappers
result.BirthDate = p6.BirthDate;
result.Gender = p6.Gender;
result.SignUpStatus = p6.SignUpStatus;
result.InternationalId = p6.InternationalId;
result.NationalId = p6.NationalId;
result.Id = p6.Id;
return result;
@ -92,7 +92,7 @@ namespace Brizco.Domain.Mappers
BirthDate = p8.BirthDate,
Gender = p8.Gender,
SignUpStatus = p8.SignUpStatus,
InternationalId = p8.InternationalId,
NationalId = p8.NationalId,
Id = p8.Id
};
}

View File

@ -16,7 +16,7 @@ public class MapsterRegister : IRegister
.Map(s=>s.ComplexName,o=>o.Complex!=null ? o.Complex.Name : string.Empty)
.Map(s=>s.FirstName,o=>o.User!=null ? o.User.FirstName : string.Empty)
.Map(s=>s.LastName,o=>o.User!=null ? o.User.LastName : string.Empty)
.Map(s=>s.InternationalId,o=>o.User!=null ? o.User.InternationalId : string.Empty)
.Map(s=>s.InternationalId,o=>o.User!=null ? o.User.NationalId : string.Empty)
.TwoWays();
}
}

20
Dockerfile 100644
View File

@ -0,0 +1,20 @@
FROM registry.vnfco.ir/library/dotnet/aspnet:7.0 AS base
ENV ASPNETCORE_URLS=http://0.0.0.0:8010
WORKDIR /app
EXPOSE 8010
FROM registry.vnfco.ir/library/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Berizco.Api/Brizco.Api.csproj", "Brizco.Api/"]
RUN dotnet restore "Brizco.Api/Brizco.Api.csproj"
COPY . .
WORKDIR "/src/Brizco.Api"
RUN dotnet build "Brizco.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Brizco.Api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Brizco.Api.dll"]

View File

@ -1,14 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="maxHttpRequestsPerSource" value="10" />
<add key='maxHttpRequestsPerSource' value='10' />
</config>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="VnfRepos" value="https://packages.vnfco.ir/repository/nuget-group/index.json" />
<!-- <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> -->
</packageSources>
</configuration>
<packageSourceCredentials>
<VnfRepos>
<add key="Username" value="runner" />
<add key="ClearTextPassword" value="22102210aA" />
</VnfRepos>
</packageSourceCredentials>
</configuration>
<!-- <configuration>
<config>

View File

@ -0,0 +1,9 @@
#/!bin/sh
defaultVersionValue=$(head -1 .version);
read -p "Enter Version : " version
version=${version:-$defaultVersionValue}
echo "version : $version"
docker build -t registry.vnfco.ir/brizco/api:latest -t registry.vnfco.ir/brizco/api:$version . || exit 1;
docker push registry.vnfco.ir/brizco/api:latest || exit 1;
docker push registry.vnfco.ir/brizco/api:$version || exit 1;