From 067607d98a1c2ce1f853748f32f1fd8bf1454c9a Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Mon, 18 Aug 2025 14:18:08 +0330 Subject: [PATCH] ... --- Common/Dtos/aiNewResponseDto.cs | 2 +- Hushian.Application/Services/AIService.cs | 6 +- Hushian.Domain/Entites/AIA.cs | 5 +- .../20250818094257_chngrtbai.Designer.cs | 534 ++++++++++++++++++ .../Migrations/20250818094257_chngrtbai.cs | 61 ++ .../HushianDbContextModelSnapshot.cs | 18 +- .../Controllers/v1/ConversationController.cs | 21 +- .../HushianWebApp/Layout/BeforeLayout.razor | 2 +- .../HushianWebApp/Layout/MainLayout.razor | 2 +- .../Pages/Auth/ForgetPassword.razor | 2 +- .../HushianWebApp/Pages/Auth/Login.razor | 6 +- .../HushianWebApp/Pages/Auth/Register.razor | 2 +- .../Pages/FromUserSide/AIChat.razor | 94 ++- .../Pages/FromUserSide/UserCP.razor | 2 +- .../Service/ConversationService.cs | 4 +- .../Before/assets/images/logofilehushian.png | Bin 0 -> 130711 bytes .../assets/images/logofilehushianخمی==.png | Bin 0 -> 568666 bytes .../HushianWebApp/wwwroot/favicon.svg | 5 + Presentation/HushianWebApp/wwwroot/index.html | 4 +- 19 files changed, 715 insertions(+), 55 deletions(-) create mode 100644 Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.Designer.cs create mode 100644 Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.cs create mode 100644 Presentation/HushianWebApp/wwwroot/Before/assets/images/logofilehushian.png create mode 100644 Presentation/HushianWebApp/wwwroot/Before/assets/images/logofilehushianخمی==.png create mode 100644 Presentation/HushianWebApp/wwwroot/favicon.svg diff --git a/Common/Dtos/aiNewResponseDto.cs b/Common/Dtos/aiNewResponseDto.cs index 9868020..274433a 100644 --- a/Common/Dtos/aiNewResponseDto.cs +++ b/Common/Dtos/aiNewResponseDto.cs @@ -9,7 +9,7 @@ namespace Common.Dtos public class aiNewResponseDto { public int companyId { get; set; } - public int userId { get; set; } + public string aiKeyUser { get; set; } public string requestText { get; set; } } public class aiResponseDto diff --git a/Hushian.Application/Services/AIService.cs b/Hushian.Application/Services/AIService.cs index 46980d5..010d819 100644 --- a/Hushian.Application/Services/AIService.cs +++ b/Hushian.Application/Services/AIService.cs @@ -32,7 +32,7 @@ namespace Hushian.Application.Services var entity = new AIA { CompanyID = dto.companyId, - UserID = dto.userId, + aiKeyUser = dto.aiKeyUser, Request = dto.requestText, Response = responeai, Cdatetime = DateTime.Now @@ -50,11 +50,11 @@ namespace Hushian.Application.Services return response; } - public async Task> GetCurrent(int companyId, int userId) + public async Task> GetCurrent(int companyId, string aiKeyUser) { return await _aiaRepository .Get() - .Where(w => w.CompanyID == companyId && w.UserID == userId && w.Cdatetime.AddHours(3) >= DateTime.Now) + .Where(w => w.CompanyID == companyId && w.aiKeyUser == aiKeyUser && w.Cdatetime.AddHours(3) >= DateTime.Now) .OrderBy(o => o.ID) .Select(s=>new aiResponseDto() { responseText = s.Response, requestText = s.Request,dateTime=s.Cdatetime}) .ToListAsync(); diff --git a/Hushian.Domain/Entites/AIA.cs b/Hushian.Domain/Entites/AIA.cs index ee1c2e1..81353a4 100644 --- a/Hushian.Domain/Entites/AIA.cs +++ b/Hushian.Domain/Entites/AIA.cs @@ -1,6 +1,7 @@ using Hushian.Domain.Abstracts; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,9 +14,11 @@ namespace Hushian.Domain.Entites public DateTime Cdatetime { get; set; } = DateTime.Now; public int CompanyID { get; set; } - public int UserID { get; set; } + public string aiKeyUser { get; set; } public string Request { get; set; } public string Response { get; set; } + [ForeignKey("CompanyID")] + public Company company { get; set; } } } diff --git a/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.Designer.cs b/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.Designer.cs new file mode 100644 index 0000000..8c2f4fb --- /dev/null +++ b/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.Designer.cs @@ -0,0 +1,534 @@ +// +using System; +using Hushian.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hushian.Persistence.Migrations +{ + [DbContext(typeof(HushianDbContext))] + [Migration("20250818094257_chngrtbai")] + partial class chngrtbai + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Hushian.Domain.Entites.AIA", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("Request") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Response") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("aiKeyUser") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.ToTable("AIAs"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Company", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullNameManager") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Verified") + .HasColumnType("bit"); + + b.Property("WebSite") + .HasColumnType("nvarchar(max)"); + + b.Property("allowBot") + .HasColumnType("bit"); + + b.Property("logo") + .HasColumnType("varbinary(max)"); + + b.HasKey("ID"); + + b.ToTable("Companies"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("Content") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.ToTable("CompanyContentInfo"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("FinishedDateTime") + .HasColumnType("datetime2"); + + b.Property("GroupID") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserID") + .HasColumnType("int"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.HasIndex("GroupID"); + + b.HasIndex("UserID"); + + b.ToTable("Conversations"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("ConversationID") + .HasColumnType("int"); + + b.Property("ExperID") + .HasColumnType("int"); + + b.Property("FileContent") + .HasColumnType("varbinary(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("FileType") + .HasColumnType("nvarchar(max)"); + + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("ReadDateTime") + .HasColumnType("datetime2"); + + b.Property("Text") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("ID"); + + b.HasIndex("ConversationID"); + + b.HasIndex("ExperID"); + + b.ToTable("ConversationItems"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Exper", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.ToTable("Expers"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b => + { + b.Property("ExperID") + .HasColumnType("int"); + + b.Property("GroupID") + .HasColumnType("int"); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.HasKey("ExperID", "GroupID"); + + b.HasIndex("GroupID"); + + b.ToTable("EG"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Group", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("Info") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("img") + .HasColumnType("varbinary(max)"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("CompanyID") + .HasColumnType("int"); + + b.Property("Test") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("CompanyID"); + + b.ToTable("prompts"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.User", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("FullName") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Identity.Models.VerificationCode", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("Cdatetime") + .HasColumnType("datetime2"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("ID"); + + b.ToTable("verificationCodes"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.AIA", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "company") + .WithMany() + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("company"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "company") + .WithMany("CompanyContentInfos") + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("company"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "Company") + .WithMany("Conversations") + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hushian.Domain.Entites.Group", "Group") + .WithMany() + .HasForeignKey("GroupID"); + + b.HasOne("Hushian.Domain.Entites.User", "User") + .WithMany("Conversations") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b => + { + b.HasOne("Hushian.Domain.Entites.Conversation", "conversation") + .WithMany("ConversationResponses") + .HasForeignKey("ConversationID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hushian.Domain.Entites.Exper", "Exper") + .WithMany() + .HasForeignKey("ExperID"); + + b.Navigation("Exper"); + + b.Navigation("conversation"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Exper", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "Company") + .WithMany("Expers") + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b => + { + b.HasOne("Hushian.Domain.Entites.Exper", "Exper") + .WithMany("EG") + .HasForeignKey("ExperID") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.HasOne("Hushian.Domain.Entites.Group", "Group") + .WithMany("EG") + .HasForeignKey("GroupID") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("Exper"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Group", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "Company") + .WithMany("Groups") + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "Company") + .WithMany("prompts") + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Company", b => + { + b.Navigation("CompanyContentInfos"); + + b.Navigation("Conversations"); + + b.Navigation("Expers"); + + b.Navigation("Groups"); + + b.Navigation("prompts"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b => + { + b.Navigation("ConversationResponses"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Exper", b => + { + b.Navigation("EG"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.Group", b => + { + b.Navigation("EG"); + }); + + modelBuilder.Entity("Hushian.Domain.Entites.User", b => + { + b.Navigation("Conversations"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.cs b/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.cs new file mode 100644 index 0000000..0160684 --- /dev/null +++ b/Infrastructure/Persistence/Migrations/20250818094257_chngrtbai.cs @@ -0,0 +1,61 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hushian.Persistence.Migrations +{ + /// + public partial class chngrtbai : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UserID", + table: "AIAs"); + + migrationBuilder.AddColumn( + name: "aiKeyUser", + table: "AIAs", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "IX_AIAs_CompanyID", + table: "AIAs", + column: "CompanyID"); + + migrationBuilder.AddForeignKey( + name: "FK_AIAs_Companies_CompanyID", + table: "AIAs", + column: "CompanyID", + principalTable: "Companies", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AIAs_Companies_CompanyID", + table: "AIAs"); + + migrationBuilder.DropIndex( + name: "IX_AIAs_CompanyID", + table: "AIAs"); + + migrationBuilder.DropColumn( + name: "aiKeyUser", + table: "AIAs"); + + migrationBuilder.AddColumn( + name: "UserID", + table: "AIAs", + type: "int", + nullable: false, + defaultValue: 0); + } + } +} diff --git a/Infrastructure/Persistence/Migrations/HushianDbContextModelSnapshot.cs b/Infrastructure/Persistence/Migrations/HushianDbContextModelSnapshot.cs index d1b8d3c..5022598 100644 --- a/Infrastructure/Persistence/Migrations/HushianDbContextModelSnapshot.cs +++ b/Infrastructure/Persistence/Migrations/HushianDbContextModelSnapshot.cs @@ -44,11 +44,14 @@ namespace Hushian.Persistence.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("UserID") - .HasColumnType("int"); + b.Property("aiKeyUser") + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("ID"); + b.HasIndex("CompanyID"); + b.ToTable("AIAs"); }); @@ -374,6 +377,17 @@ namespace Hushian.Persistence.Migrations b.ToTable("verificationCodes"); }); + modelBuilder.Entity("Hushian.Domain.Entites.AIA", b => + { + b.HasOne("Hushian.Domain.Entites.Company", "company") + .WithMany() + .HasForeignKey("CompanyID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("company"); + }); + modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b => { b.HasOne("Hushian.Domain.Entites.Company", "company") diff --git a/Presentation/Hushian.WebApi/Controllers/v1/ConversationController.cs b/Presentation/Hushian.WebApi/Controllers/v1/ConversationController.cs index 704f3ed..f789b5c 100644 --- a/Presentation/Hushian.WebApi/Controllers/v1/ConversationController.cs +++ b/Presentation/Hushian.WebApi/Controllers/v1/ConversationController.cs @@ -11,7 +11,7 @@ namespace Hushian.WebApi.Controllers.v1 { [Route("api/v1/[controller]")] [ApiController] - [Authorize] + // [Authorize] public class ConversationController : ControllerBase { private readonly ConversationService _conversationService; @@ -80,6 +80,7 @@ namespace Hushian.WebApi.Controllers.v1 } //* [HttpPost("NewConversationFromCurrentUser")] + [Authorize(Roles = "User")] public async Task NewConversationFromCurrentUser(ADD_ConversationDto conversation) { conversation.UserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => Convert.ToInt32( s.Value)).First(); @@ -168,21 +169,21 @@ namespace Hushian.WebApi.Controllers.v1 return Ok(response) ; } [HttpPost("ai/NewResponse")] - [Authorize(Roles = "User")] + //[Authorize(Roles = "User")] public async Task ainewresponse(aiNewResponseDto dto) { - string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); - dto.userId = Convert.ToInt32(strUserID); + //string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); + //dto.userId = Convert.ToInt32(strUserID); var response = await _aIService.NewRequest(dto); return response.Success ? Ok(response.Value):BadRequest(response.Errors); } - [HttpGet("ai/CurrentResponse/{companyID}")] - [Authorize(Roles = "User")] - public async Task aiCurrentResponse(int companyID) + [HttpGet("ai/CurrentResponse/{companyID}/{aiKeyUser}")] + //[Authorize(Roles = "User")] + public async Task aiCurrentResponse(int companyID,string aiKeyUser) { - string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); - var UserId = Convert.ToInt32(strUserID); - var response = await _aIService.GetCurrent(companyID,UserId); + //string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); + //var UserId = Convert.ToInt32(strUserID); + var response = await _aIService.GetCurrent(companyID, aiKeyUser); return Ok(response); } } diff --git a/Presentation/HushianWebApp/Layout/BeforeLayout.razor b/Presentation/HushianWebApp/Layout/BeforeLayout.razor index e5051c5..3898484 100644 --- a/Presentation/HushianWebApp/Layout/BeforeLayout.razor +++ b/Presentation/HushianWebApp/Layout/BeforeLayout.razor @@ -8,7 +8,7 @@
- +
diff --git a/Presentation/HushianWebApp/Layout/MainLayout.razor b/Presentation/HushianWebApp/Layout/MainLayout.razor index 41f8bd7..f1c2fd1 100644 --- a/Presentation/HushianWebApp/Layout/MainLayout.razor +++ b/Presentation/HushianWebApp/Layout/MainLayout.razor @@ -18,7 +18,7 @@ IconName="IconName.BootstrapFill" Title="هوشــیان" BadgeText="v1.3.1" - ImageSrc="/before/assets/images/hushian-logo.svg" + ImageSrc="/before/assets/images/logofilehushian.png" DataProvider="SidebarDataProvider" Width="200" WidthUnit="Unit.Px" /> diff --git a/Presentation/HushianWebApp/Pages/Auth/ForgetPassword.razor b/Presentation/HushianWebApp/Pages/Auth/ForgetPassword.razor index cb7931c..649a662 100644 --- a/Presentation/HushianWebApp/Pages/Auth/ForgetPassword.razor +++ b/Presentation/HushianWebApp/Pages/Auth/ForgetPassword.razor @@ -11,7 +11,7 @@
- Hushian + Hushian بازیابی کلمه عبور diff --git a/Presentation/HushianWebApp/Pages/Auth/Login.razor b/Presentation/HushianWebApp/Pages/Auth/Login.razor index 11a590e..6e6c591 100644 --- a/Presentation/HushianWebApp/Pages/Auth/Login.razor +++ b/Presentation/HushianWebApp/Pages/Auth/Login.razor @@ -7,14 +7,14 @@ @inject AuthService auth; @inject NavigationManager navigationManager; -هوشیان / ورود بخش شرکت ها +هوشیان / ورود بخش مدیریت
- Hushian + Hushian ورود - به هوشیان + بخش مدیریت
diff --git a/Presentation/HushianWebApp/Pages/Auth/Register.razor b/Presentation/HushianWebApp/Pages/Auth/Register.razor index df28708..ea808d8 100644 --- a/Presentation/HushianWebApp/Pages/Auth/Register.razor +++ b/Presentation/HushianWebApp/Pages/Auth/Register.razor @@ -10,7 +10,7 @@ هوشیان / ثبت نام
- Hushian + Hushian حساب کاربری خود را در هوشیان بسازید
diff --git a/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor b/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor index ec637f9..dacc822 100644 --- a/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor +++ b/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor @@ -7,21 +7,27 @@ @inject ToastService toastService @inject IJSRuntime JS @layout UserPanelLayout +@using Common.Dtos.Company @using HushianWebApp.Service @using HushianWebApp.Services @using Microsoft.AspNetCore.Components.Web - +@inject CompanyService companyService +@inject ToastService toastService
@if (isReady) { @if (isLogin) { -
-
-

گفتگو هوش مصنوعی

+
+
+

دستیار هوشمند @CompanyInfo.FullName

+
- + +
@@ -32,7 +38,7 @@ {
- @msg.requestText + @msg.requestText
@@ -79,39 +85,44 @@
@code { + ReadANDUpdate_CompanyDto? CompanyInfo = new(); [Parameter] public int CompanyID { get; set; } List messages = new(); string inputText = string.Empty; bool isLogin = false; bool isReady = false; - + public string aikeyUser { get; set; } protected override async Task OnInitializedAsync() { await EnsureAuth(); if (isLogin) { - await LoadMessages(); + CompanyInfo = await companyService.GetCompany(CompanyID); + if (CompanyInfo != null) + await LoadMessages(); + else + { + toastService.Notify(new ToastMessage(ToastType.Danger, "شناسه شرکت صحیح نمی باشد")); + + } } } private async Task EnsureAuth() { - var token = await localStorageService.GetItem("U/key"); - if (string.IsNullOrEmpty(token)) + aikeyUser = await localStorageService.GetItem("aikeyUser"); + if (string.IsNullOrEmpty(aikeyUser)) { - isLogin = false; - isReady = true; - return; + aikeyUser = Guid.NewGuid().ToString(); + await localStorageService.SetItem("aikeyUser", aikeyUser); } - await baseController.RemoveToken(); - await baseController.SetToken(token); - isLogin = await authService.IsOnline(); + isLogin = true; isReady = true; } private async Task LoadMessages() { - messages = await conversationService.GetAiCurrentResponses(CompanyID); + messages = await conversationService.GetAiCurrentResponses(CompanyID,aikeyUser); StateHasChanged(); await JS.InvokeVoidAsync("scrollToBottom", "ai-chat"); } @@ -119,13 +130,8 @@ private async Task Send() { if (string.IsNullOrWhiteSpace(inputText)) return; - var token = await localStorageService.GetItem("U/key"); - if (!isLogin || string.IsNullOrEmpty(token)) - { - toastService.Notify(new ToastMessage(ToastType.Warning, "ابتدا وارد شوید")); - return; - } - var dto = new aiNewResponseDto { companyId = CompanyID, userId = 0, requestText = inputText }; + + var dto = new aiNewResponseDto { companyId = CompanyID, aiKeyUser = aikeyUser, requestText = inputText }; var okmodel = await conversationService.AiNewResponse(dto); if (okmodel!=null) { @@ -147,8 +153,7 @@ private async Task Logout() { - await baseController.RemoveToken(); - await localStorageService.RemoveItem("U/key"); + await localStorageService.RemoveItem("aiKeyUser"); isLogin = false; } } @@ -196,6 +201,43 @@ .input-wrapper { display:flex; align-items:center; gap:.75rem; } .message-input { flex:1; border:none; background:transparent; padding:.5rem .75rem; font-size:.95rem; color:#495057; outline:none; border-radius:20px; } .send-btn { border-radius:50%; width:38px; height:38px; padding:0; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#0d6efd 0%,#0b5ed7 100%); border:none; box-shadow:0 4px 12px rgba(13,110,253,.3); color:white; } + + .logout-btn { + border-radius: 20px; + font-weight: 600; + font-size: 0.875rem; + padding: 0.375rem 0.75rem; + transition: all 0.3s ease; + border-width: 2px; + box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2); + background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); + } + + .logout-btn:hover { + transform: translateY(-1px); + box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3); + border-color: #6c757d; + background: linear-gradient(135deg, #6c757d 0%, #495057 100%); + color: white; + } + + /* Improved input group styling */ + .input-group { + margin-bottom: 1rem; + border-radius: 0.5rem; + overflow: hidden; + } + + .input-group p { + margin: 0; + font-size: 1.1rem; + font-weight: 700; + background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; + } +