44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Crm.Core.Domain
|
|
{
|
|
internal class UserDomain : IUserDomain
|
|
{
|
|
private readonly ICacheDomain _cacheDomain;
|
|
private readonly IHttpClient _httpClient;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
public UserDomain(ICacheDomain cacheDomain,
|
|
IHttpClient httpClient,
|
|
IConfiguration configuration,
|
|
IServiceProvider serviceProvider)
|
|
{
|
|
_cacheDomain = cacheDomain;
|
|
_httpClient = httpClient;
|
|
_configuration = configuration;
|
|
_serviceProvider = serviceProvider;
|
|
}
|
|
|
|
public async Task<CrmUserDto> GetCrmUser(int eid)
|
|
{
|
|
var appid = _cacheDomain.GetApp();
|
|
using var scope = _serviceProvider.CreateAsyncScope();
|
|
var repository = scope.ServiceProvider.GetRequiredService<IOracleRepository<CrmDbContext>>();
|
|
await _cacheDomain.SetApp(repository, appid);
|
|
var user = await repository.GetRepository<BAS_INNERUSER>().Query()
|
|
.Where(x => x.EID == eid)
|
|
.Select(x=>new CrmUserDto
|
|
{
|
|
Eid = x.EID,
|
|
Username = x.UNAME
|
|
}).FirstOrDefaultAsync() ?? throw new ApiException("用户不存或已删除!");
|
|
return user;
|
|
}
|
|
}
|
|
}
|