...
This commit is contained in:
21
Common/Dtos/aiNewResponseDto.cs
Normal file
21
Common/Dtos/aiNewResponseDto.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos
|
||||
{
|
||||
public class aiNewResponseDto
|
||||
{
|
||||
public int companyId { get; set; }
|
||||
public int userId { get; set; }
|
||||
public string requestText { get; set; }
|
||||
}
|
||||
public class aiResponseDto
|
||||
{
|
||||
public DateTime dateTime { get; set; }
|
||||
public string requestText { get; set; }
|
||||
public string responseText { get; set; }
|
||||
}
|
||||
}
|
@@ -69,6 +69,7 @@ namespace Hushian.Application
|
||||
services.AddScoped(typeof(PromptService));
|
||||
services.AddScoped(typeof(UserService));
|
||||
services.AddScoped(typeof(VerificationService));
|
||||
services.AddScoped(typeof(AIService));
|
||||
services.Configure<JwtSettings>(configuration.GetSection("JwtSettings"));
|
||||
}
|
||||
}
|
||||
|
72
Hushian.Application/Services/AIService.cs
Normal file
72
Hushian.Application/Services/AIService.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using AutoMapper;
|
||||
using Common.Dtos;
|
||||
using Hushian.Application.Contracts.Persistence;
|
||||
using Hushian.Application.Models;
|
||||
using Hushian.Domain.Entites;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace Hushian.Application.Services
|
||||
{
|
||||
public class AIService
|
||||
{
|
||||
private readonly IGenericRepository<AIA> _aiaRepository;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public AIService(IGenericRepository<AIA> aiaRepository, IMapper mapper)
|
||||
{
|
||||
_aiaRepository = aiaRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<ResponseBase<aiResponseDto>> NewRequest
|
||||
(aiNewResponseDto dto)
|
||||
{
|
||||
ResponseBase<aiResponseDto> response = new();
|
||||
try
|
||||
{
|
||||
string responeai="همین جوری";
|
||||
bool sucessresponseai = false;
|
||||
|
||||
|
||||
var entity = new AIA
|
||||
{
|
||||
CompanyID = dto.companyId,
|
||||
UserID = dto.userId,
|
||||
Request = dto.requestText,
|
||||
Response = responeai,
|
||||
Cdatetime = DateTime.Now
|
||||
};
|
||||
var added = await _aiaRepository.ADD(entity);
|
||||
|
||||
if(sucessresponseai)
|
||||
response.Value = new() { dateTime=added.Cdatetime,responseText=added.Response,requestText=added.Request};
|
||||
response.Success = sucessresponseai;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
response.Errors.Add("خطا در ذخیره سازی");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<List<aiResponseDto>> GetCurrent(int companyId, int userId)
|
||||
{
|
||||
return await _aiaRepository
|
||||
.Get()
|
||||
.Where(w => w.CompanyID == companyId && w.UserID == userId && w.Cdatetime.AddHours(3) >= DateTime.Now)
|
||||
.OrderBy(o => o.ID)
|
||||
.Select(s=>new aiResponseDto() { responseText = s.Response, requestText = s.Request,dateTime=s.Cdatetime})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
//public async Task<bool> DeleteEntry(int id, int companyId)
|
||||
//{
|
||||
// var entity = await _aiaRepository.Get().FirstOrDefaultAsync(f => f.ID == id && f.CompanyID == companyId);
|
||||
// if (entity == null) return false;
|
||||
// return await _aiaRepository.DELETE(entity);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,10 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
class AIA : BaseEntity
|
||||
public class AIA : BaseEntity
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public DateTime Cdatetime { get; set; }
|
||||
public DateTime Cdatetime { get; set; } = DateTime.Now;
|
||||
|
||||
public int CompanyID { get; set; }
|
||||
public int UserID { get; set; }
|
||||
|
@@ -23,6 +23,7 @@ namespace Hushian.Persistence
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<VerificationCode > verificationCodes { get; set; }
|
||||
public DbSet<Prompt> prompts { get; set; }
|
||||
public DbSet<AIA> AIAs { get; set; }
|
||||
#endregion
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
520
Infrastructure/Persistence/Migrations/20250817205731_newtable.Designer.cs
generated
Normal file
520
Infrastructure/Persistence/Migrations/20250817205731_newtable.Designer.cs
generated
Normal file
@@ -0,0 +1,520 @@
|
||||
// <auto-generated />
|
||||
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("20250817205731_newtable")]
|
||||
partial class newtable
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Request")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Response")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("AIAs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<bool>("Available")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullNameManager")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Mobile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("Verified")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("WebSite")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("allowBot")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<byte[]>("logo")
|
||||
.HasColumnType("varbinary(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Companies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Content")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("CompanyID");
|
||||
|
||||
b.ToTable("CompanyContentInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("FinishedDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("GroupID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("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<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ConversationID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ExperID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<byte[]>("FileContent")
|
||||
.HasColumnType("varbinary(max)");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FileType")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("IsRead")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("ReadDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ConversationID");
|
||||
|
||||
b.HasIndex("ExperID");
|
||||
|
||||
b.ToTable("ConversationItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<bool>("Available")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("CompanyID");
|
||||
|
||||
b.ToTable("Expers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
|
||||
{
|
||||
b.Property<int>("ExperID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GroupID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("ExperID", "GroupID");
|
||||
|
||||
b.HasIndex("GroupID");
|
||||
|
||||
b.ToTable("EG");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<bool>("Available")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Info")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<byte[]>("img")
|
||||
.HasColumnType("varbinary(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("CompanyID");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Test")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("CompanyID");
|
||||
|
||||
b.ToTable("prompts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Mobile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Identity.Models.VerificationCode", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Mobile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("verificationCodes");
|
||||
});
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Hushian.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class newtable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AIAs",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
CompanyID = table.Column<int>(type: "int", nullable: false),
|
||||
UserID = table.Column<int>(type: "int", nullable: false),
|
||||
Request = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Response = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AIAs", x => x.ID);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AIAs");
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,6 +22,36 @@ namespace Hushian.Persistence.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.AIA", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<DateTime>("Cdatetime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CompanyID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Request")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Response")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("AIAs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Common.Dtos.Conversation;
|
||||
using Common.Dtos;
|
||||
using Common.Dtos.Conversation;
|
||||
using Common.Enums;
|
||||
using Hushian.Application.Constants;
|
||||
using Hushian.Application.Services;
|
||||
@@ -16,11 +17,13 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
private readonly ConversationService _conversationService;
|
||||
private readonly CompanyService _companyService;
|
||||
private readonly ExperService _experService;
|
||||
public ConversationController(ConversationService conversationService, CompanyService companyService, ExperService experService)
|
||||
private readonly AIService _aIService;
|
||||
public ConversationController(ConversationService conversationService, CompanyService companyService, ExperService experService, AIService aIService)
|
||||
{
|
||||
_conversationService = conversationService;
|
||||
_companyService = companyService;
|
||||
_experService = experService;
|
||||
_aIService = aIService;
|
||||
}
|
||||
|
||||
//*
|
||||
@@ -164,5 +167,23 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
var response = await _conversationService.GEtConversation(UserID,CompanyID );
|
||||
return Ok(response) ;
|
||||
}
|
||||
[HttpPost("ai/NewResponse")]
|
||||
[Authorize(Roles = "User")]
|
||||
public async Task<ActionResult> ainewresponse(aiNewResponseDto dto)
|
||||
{
|
||||
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):BadRequest(response.Errors);
|
||||
}
|
||||
[HttpGet("ai/CurrentResponse/{companyID}")]
|
||||
[Authorize(Roles = "User")]
|
||||
public async Task<ActionResult> aiCurrentResponse(int companyID)
|
||||
{
|
||||
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);
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -95,3 +95,4 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -54,3 +54,4 @@ namespace HushianWebApp.Service
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user