...
This commit is contained in:
@@ -7,6 +7,5 @@ namespace Common.Dtos.Conversation
|
|||||||
public string Question { get; set; }
|
public string Question { get; set; }
|
||||||
public int? GroupID { get; set; }
|
public int? GroupID { get; set; }
|
||||||
public int CompanyID { get; set; }
|
public int CompanyID { get; set; }
|
||||||
public int? ExperID { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
Hushian.Application/Contracts/IconversationAssistant.cs
Normal file
12
Hushian.Application/Contracts/IconversationAssistant.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Hushian.Application.Contracts
|
||||||
|
{
|
||||||
|
interface IconversationAssistant
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@@ -27,7 +27,11 @@ namespace Hushian.Application.Services
|
|||||||
private readonly IGenericRepository<User> _UserRepository;
|
private readonly IGenericRepository<User> _UserRepository;
|
||||||
private readonly IGenericRepository<Exper> _ExperRepository;
|
private readonly IGenericRepository<Exper> _ExperRepository;
|
||||||
private readonly VerificationService _verificationService;
|
private readonly VerificationService _verificationService;
|
||||||
public AuthService(IOptions<JwtSettings> jwtSettings, IGenericRepository<Company> companyRepository, IGenericRepository<User> userRepository, IGenericRepository<Exper> experRepository, VerificationService verificationService)
|
public AuthService(IOptions<JwtSettings> jwtSettings
|
||||||
|
, IGenericRepository<Company> companyRepository
|
||||||
|
, IGenericRepository<User> userRepository
|
||||||
|
, IGenericRepository<Exper> experRepository
|
||||||
|
, VerificationService verificationService)
|
||||||
{
|
{
|
||||||
_jwtSettings = jwtSettings.Value;
|
_jwtSettings = jwtSettings.Value;
|
||||||
_CompanyRepository = companyRepository;
|
_CompanyRepository = companyRepository;
|
||||||
@@ -119,8 +123,6 @@ namespace Hushian.Application.Services
|
|||||||
|
|
||||||
public async Task<JwtSecurityToken> GenerateToken(string UserName, int userId)
|
public async Task<JwtSecurityToken> GenerateToken(string UserName, int userId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var claims = new[]
|
var claims = new[]
|
||||||
{
|
{
|
||||||
new Claim(JwtRegisteredClaimNames.Sub,UserName),
|
new Claim(JwtRegisteredClaimNames.Sub,UserName),
|
||||||
|
@@ -22,6 +22,13 @@ namespace Hushian.Application.Services
|
|||||||
private readonly VerificationService _VerificationService;
|
private readonly VerificationService _VerificationService;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public CompanyService(IGenericRepository<Company> companyRepository, VerificationService verificationService, IMapper mapper)
|
||||||
|
{
|
||||||
|
_CompanyRepository = companyRepository;
|
||||||
|
_VerificationService = verificationService;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ResponseBase<int>> RegisterCompany(RegisterCompanyDto dto)
|
public async Task<ResponseBase<int>> RegisterCompany(RegisterCompanyDto dto)
|
||||||
{
|
{
|
||||||
ResponseBase<int> Response = new();
|
ResponseBase<int> Response = new();
|
||||||
@@ -197,6 +204,8 @@ namespace Hushian.Application.Services
|
|||||||
}
|
}
|
||||||
public async Task<bool> AnyCompany(int CompanyID)
|
public async Task<bool> AnyCompany(int CompanyID)
|
||||||
=>await _CompanyRepository.Get().AnyAsync(a=>a.ID==CompanyID);
|
=>await _CompanyRepository.Get().AnyAsync(a=>a.ID==CompanyID);
|
||||||
|
public async Task<bool> AllowBot(int CompanyID)
|
||||||
|
=> await _CompanyRepository.Get().AnyAsync(a => a.ID == CompanyID && a.allowBot);
|
||||||
private async Task<int> Verifi(string Mobile) => await _VerificationService.GenerateCodeByPhoneNumberConfirmed(Mobile);
|
private async Task<int> Verifi(string Mobile) => await _VerificationService.GenerateCodeByPhoneNumberConfirmed(Mobile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,11 +18,25 @@ namespace Hushian.Application.Services
|
|||||||
{
|
{
|
||||||
private readonly IGenericRepository<Conversation> _ConversationRepository;
|
private readonly IGenericRepository<Conversation> _ConversationRepository;
|
||||||
private readonly IGenericRepository<ConversationResponse> _ConversationResponseRepository;
|
private readonly IGenericRepository<ConversationResponse> _ConversationResponseRepository;
|
||||||
private readonly IMapper _mapper;
|
|
||||||
private readonly CompanyService _companyService;
|
private readonly CompanyService _companyService;
|
||||||
private readonly UserService _userService;
|
private readonly UserService _userService;
|
||||||
private readonly GroupService _groupService;
|
private readonly GroupService _groupService;
|
||||||
private readonly ExperService _experService;
|
private readonly ExperService _experService;
|
||||||
|
|
||||||
|
public ConversationService(
|
||||||
|
IGenericRepository<Conversation> conversationRepository
|
||||||
|
, IGenericRepository<ConversationResponse> conversationResponseRepository
|
||||||
|
, CompanyService companyService, UserService userService, GroupService groupService
|
||||||
|
, ExperService experService)
|
||||||
|
{
|
||||||
|
_ConversationRepository = conversationRepository;
|
||||||
|
_ConversationResponseRepository = conversationResponseRepository;
|
||||||
|
_companyService = companyService;
|
||||||
|
_userService = userService;
|
||||||
|
_groupService = groupService;
|
||||||
|
_experService = experService;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ResponseBase<int>> NewConversation(ADD_ConversationDto dto, ConversationType type = ConversationType.UE)
|
public async Task<ResponseBase<int>> NewConversation(ADD_ConversationDto dto, ConversationType type = ConversationType.UE)
|
||||||
{
|
{
|
||||||
var Response = new ResponseBase<int>();
|
var Response = new ResponseBase<int>();
|
||||||
@@ -30,6 +44,15 @@ namespace Hushian.Application.Services
|
|||||||
{
|
{
|
||||||
if (await _userService.AnyUser(dto.UserID))
|
if (await _userService.AnyUser(dto.UserID))
|
||||||
{
|
{
|
||||||
|
if (type == ConversationType.Bot)
|
||||||
|
{
|
||||||
|
if (!await _companyService.AllowBot(dto.CompanyID))
|
||||||
|
{
|
||||||
|
Response.Errors.Add("دستیار گفتگو هوشمند برای این شرکت در دسترس نمی باشد");
|
||||||
|
return Response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!dto.GroupID.HasValue || (dto.GroupID.HasValue
|
if (!dto.GroupID.HasValue || (dto.GroupID.HasValue
|
||||||
&& await _groupService.AnyGroup(dto.GroupID.Value)
|
&& await _groupService.AnyGroup(dto.GroupID.Value)
|
||||||
&& await _groupService.CHeckGroupMemberCompany(dto.GroupID.Value, dto.CompanyID)))
|
&& await _groupService.CHeckGroupMemberCompany(dto.GroupID.Value, dto.CompanyID)))
|
||||||
@@ -46,6 +69,8 @@ namespace Hushian.Application.Services
|
|||||||
}
|
}
|
||||||
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else Response.Errors.Add("شناسه کاربر یافت نشد");
|
else Response.Errors.Add("شناسه کاربر یافت نشد");
|
||||||
|
|
||||||
@@ -177,5 +202,19 @@ namespace Hushian.Application.Services
|
|||||||
UserFullName = s.User.FullName
|
UserFullName = s.User.FullName
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
public async Task<bool> FinishConversation(int ConversationID)
|
||||||
|
{
|
||||||
|
var convModel = await _ConversationRepository.Get()
|
||||||
|
.Include(inc => inc.ConversationResponses)
|
||||||
|
.FirstOrDefaultAsync(w => w.ID == ConversationID);
|
||||||
|
|
||||||
|
if (convModel != null && convModel.Status != ConversationStatus.Finished)
|
||||||
|
{
|
||||||
|
convModel.Status = ConversationStatus.Finished;
|
||||||
|
return await _ConversationRepository.UPDATEBool(convModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,17 @@ namespace Hushian.Application.Services
|
|||||||
{
|
{
|
||||||
public class ExperService
|
public class ExperService
|
||||||
{
|
{
|
||||||
private readonly IGenericRepository<Company> _CompanyRepository;
|
|
||||||
private readonly IGenericRepository<Exper> _ExperRepository;
|
private readonly IGenericRepository<Exper> _ExperRepository;
|
||||||
private readonly VerificationService _VerificationService;
|
private readonly VerificationService _VerificationService;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public ExperService(IGenericRepository<Exper> experRepository, VerificationService verificationService, IMapper mapper)
|
||||||
|
{
|
||||||
|
_ExperRepository = experRepository;
|
||||||
|
_VerificationService = verificationService;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto, int CompanyID)
|
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto, int CompanyID)
|
||||||
{
|
{
|
||||||
var Response = new ResponseBase<bool>();
|
var Response = new ResponseBase<bool>();
|
||||||
|
@@ -20,6 +20,17 @@ namespace Hushian.Application.Services
|
|||||||
private readonly IGenericRepository<ExperGroup> _EGRepository;
|
private readonly IGenericRepository<ExperGroup> _EGRepository;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly ExperService _experService;
|
private readonly ExperService _experService;
|
||||||
|
|
||||||
|
public GroupService(IGenericRepository<Group> groupRepository
|
||||||
|
, IGenericRepository<ExperGroup> eGRepository
|
||||||
|
, IMapper mapper, ExperService experService)
|
||||||
|
{
|
||||||
|
_GroupRepository = groupRepository;
|
||||||
|
_EGRepository = eGRepository;
|
||||||
|
_mapper = mapper;
|
||||||
|
_experService = experService;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ResponseBase<bool>> NewGroup(ADD_GroupDto model, int CompanyID)
|
public async Task<ResponseBase<bool>> NewGroup(ADD_GroupDto model, int CompanyID)
|
||||||
{
|
{
|
||||||
ResponseBase<bool> Response = new();
|
ResponseBase<bool> Response = new();
|
||||||
|
@@ -27,7 +27,12 @@ namespace Hushian.Application.Services
|
|||||||
private readonly IGenericRepository<User> _UserRepository;
|
private readonly IGenericRepository<User> _UserRepository;
|
||||||
private readonly AuthService _authService;
|
private readonly AuthService _authService;
|
||||||
|
|
||||||
public VerificationService(IGenericRepository<VerificationCode> verificationCodeRepository, IMessageSender messageSender, IGenericRepository<User> userRepository, AuthService authService, IGenericRepository<Company> companyRepository, IGenericRepository<Exper> experRepository)
|
public VerificationService(IGenericRepository<VerificationCode> verificationCodeRepository
|
||||||
|
, IMessageSender messageSender
|
||||||
|
, IGenericRepository<User> userRepository
|
||||||
|
, AuthService authService
|
||||||
|
, IGenericRepository<Company> companyRepository
|
||||||
|
, IGenericRepository<Exper> experRepository)
|
||||||
{
|
{
|
||||||
_VerificationCodeRepository = verificationCodeRepository;
|
_VerificationCodeRepository = verificationCodeRepository;
|
||||||
_messageSender = messageSender;
|
_messageSender = messageSender;
|
||||||
|
Reference in New Issue
Block a user