From a3b7302d9020b7f313ee1f846a21944a972e048a Mon Sep 17 00:00:00 2001 From: MeysamMoghaddam <65253484+MeysamMoghaddam@users.noreply.github.com> Date: Sun, 28 Sep 2025 06:30:13 +0330 Subject: [PATCH] Generator Changes at 9/28/2025 6:19:21 AM --- .../Interfaces/IApplicationDbContext.cs | 2 +- .../CreateNewOtpTokenCommandHandler.cs | 8 +- .../CreateNewOtpTokenResponseDto.cs | 4 + .../VerifyOtpTokenCommandHandler.cs | 8 +- .../VerifyOtpTokenResponseDto.cs | 4 + .../Commands/UpdateUser/UpdateUserCommand.cs | 4 + .../UpdateUser/UpdateUserCommandValidator.cs | 2 + src/CMSMicroservice.Domain/Entities/User.cs | 4 + .../Persistence/ApplicationDbContext.cs | 2 +- .../Configurations/UserConfiguration.cs | 2 + .../Migrations/20250928025307_u03.Designer.cs | 442 ++++++++++++++++++ .../Migrations/20250928025307_u03.cs | 44 ++ .../ApplicationDbContextModelSnapshot.cs | 6 + .../Protos/otptoken.proto | 4 + .../Protos/user.proto | 2 + .../User/UpdateUserRequestValidator.cs | 2 + 16 files changed, 534 insertions(+), 6 deletions(-) create mode 100644 src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.Designer.cs create mode 100644 src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.cs diff --git a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs index f173703..8e7d8b5 100644 --- a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs @@ -7,7 +7,7 @@ public interface IApplicationDbContext DbSet UserOrders { get; } DbSet Roles { get; } DbSet UserRoles { get; } - DbSet Users { get; } DbSet OtpTokens { get; } + DbSet Users { get; } Task SaveChangesAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/src/CMSMicroservice.Application/OtpTokenCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs b/src/CMSMicroservice.Application/OtpTokenCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs index 79dd318..c7b3501 100644 --- a/src/CMSMicroservice.Application/OtpTokenCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs +++ b/src/CMSMicroservice.Application/OtpTokenCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs @@ -14,7 +14,9 @@ public class CreateNewOtpTokenCommandHandler : IRequestHandler Handle(CreateNewOtpTokenCommand request, @@ -57,7 +59,9 @@ public class CreateNewOtpTokenCommandHandler : IRequestHandler public string? NationalCode { get; init; } //آدرس آواتار public string? AvatarPath { get; init; } + //قوانین پذیرفته شده؟ + public bool IsRulesAccepted { get; init; } + //تاریخ پذیرش قوانین + public DateTime? RulesAcceptedAt { get; init; } } \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserCQ/Commands/UpdateUser/UpdateUserCommandValidator.cs b/src/CMSMicroservice.Application/UserCQ/Commands/UpdateUser/UpdateUserCommandValidator.cs index 44a4fbe..23773ae 100644 --- a/src/CMSMicroservice.Application/UserCQ/Commands/UpdateUser/UpdateUserCommandValidator.cs +++ b/src/CMSMicroservice.Application/UserCQ/Commands/UpdateUser/UpdateUserCommandValidator.cs @@ -5,6 +5,8 @@ public class UpdateUserCommandValidator : AbstractValidator { RuleFor(model => model.Id) .NotNull(); + RuleFor(model => model.IsRulesAccepted) + .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { diff --git a/src/CMSMicroservice.Domain/Entities/User.cs b/src/CMSMicroservice.Domain/Entities/User.cs index 1bcd92d..1e98e03 100644 --- a/src/CMSMicroservice.Domain/Entities/User.cs +++ b/src/CMSMicroservice.Domain/Entities/User.cs @@ -22,6 +22,10 @@ public class User : BaseAuditableEntity public bool IsMobileVerified { get; set; } //تاریخ فعال سازی موبایل public DateTime? MobileVerifiedAt { get; set; } + //قوانین پذیرفته شده؟ + public bool IsRulesAccepted { get; set; } + //تاریخ پذیرش قوانین + public DateTime? RulesAcceptedAt { get; set; } //UserAddress Collection Navigation Reference public virtual ICollection UserAddresss { get; set; } //UserOrder Collection Navigation Reference diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index 1487938..07d0c2f 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -44,7 +44,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public DbSet UserOrders => Set(); public DbSet Roles => Set(); public DbSet UserRoles => Set(); - public DbSet Users => Set(); public DbSet OtpTokens => Set(); + public DbSet Users => Set(); } \ No newline at end of file diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs index 0493b73..19b4c52 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs @@ -25,5 +25,7 @@ public class UserConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.ReferralCode).IsRequired(true); builder.Property(entity => entity.IsMobileVerified ).IsRequired(true); builder.Property(entity => entity.MobileVerifiedAt).IsRequired(false); + builder.Property(entity => entity.IsRulesAccepted).IsRequired(true); + builder.Property(entity => entity.RulesAcceptedAt).IsRequired(false); } } \ No newline at end of file diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.Designer.cs new file mode 100644 index 0000000..82a9484 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.Designer.cs @@ -0,0 +1,442 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250928025307_u03")] + partial class u03 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("bit"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent") + .WithMany("Users") + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("UserAddresss"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.cs new file mode 100644 index 0000000..3936cbd --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20250928025307_u03.cs @@ -0,0 +1,44 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class u03 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsRulesAccepted", + schema: "CMS", + table: "Users", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RulesAcceptedAt", + schema: "CMS", + table: "Users", + type: "datetime2", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsRulesAccepted", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropColumn( + name: "RulesAcceptedAt", + schema: "CMS", + table: "Users"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index cf4360b..a1428f6 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -177,6 +177,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("IsMobileVerified") .HasColumnType("bit"); + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + b.Property("LastModified") .HasColumnType("datetime2"); @@ -203,6 +206,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + b.HasKey("Id"); b.HasIndex("ParentId"); diff --git a/src/CMSMicroservice.Protobuf/Protos/otptoken.proto b/src/CMSMicroservice.Protobuf/Protos/otptoken.proto index 7dcb4bf..d02b1c9 100644 --- a/src/CMSMicroservice.Protobuf/Protos/otptoken.proto +++ b/src/CMSMicroservice.Protobuf/Protos/otptoken.proto @@ -42,6 +42,8 @@ message CreateNewOtpTokenResponse bool success = 1; string message = 2; google.protobuf.StringValue code = 3; + int32 remaining_attempts = 4; + int32 remaining_seconds = 5; } message VerifyOtpTokenRequest { @@ -54,6 +56,8 @@ message VerifyOtpTokenResponse bool success = 1; string message = 2; google.protobuf.Int64Value user_id = 3; + int32 remaining_attempts = 4; + int32 remaining_seconds = 5; } message GetAllOtpTokenByFilterRequest { diff --git a/src/CMSMicroservice.Protobuf/Protos/user.proto b/src/CMSMicroservice.Protobuf/Protos/user.proto index e528a9a..046ed99 100644 --- a/src/CMSMicroservice.Protobuf/Protos/user.proto +++ b/src/CMSMicroservice.Protobuf/Protos/user.proto @@ -70,6 +70,8 @@ message UpdateUserRequest google.protobuf.StringValue last_name = 3; google.protobuf.StringValue national_code = 4; google.protobuf.StringValue avatar_path = 5; + bool is_rules_accepted = 6; + google.protobuf.Timestamp rules_accepted_at = 7; } message DeleteUserRequest { diff --git a/src/CMSMicroservice.Protobuf/Validator/User/UpdateUserRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/User/UpdateUserRequestValidator.cs index 335859e..fa0647f 100644 --- a/src/CMSMicroservice.Protobuf/Validator/User/UpdateUserRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/User/UpdateUserRequestValidator.cs @@ -8,6 +8,8 @@ public class UpdateUserRequestValidator : AbstractValidator { RuleFor(model => model.Id) .NotNull(); + RuleFor(model => model.IsRulesAccepted) + .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => {