|
@@ -1,8 +1,13 @@
|
|
|
using Hotline.Api.Filter;
|
|
|
+using Hotline.Application.Enterprise;
|
|
|
using Hotline.Enterprise;
|
|
|
+using Hotline.Repository.SqlSugar.Extensions;
|
|
|
+using Hotline.Share.Dtos;
|
|
|
using Hotline.Share.Dtos.Enterprise;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Dtos.Users;
|
|
|
using Hotline.Share.Requests;
|
|
|
+using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
@@ -12,15 +17,21 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
private readonly IEnterpriseService _enterpriseService;
|
|
|
private readonly IRepository<EnterpriseSpecialist> _enterpriseSpecialistRepository;
|
|
|
+ private readonly IEnterpriseApplication _enterpriseApplication;
|
|
|
+ private readonly IMapper _mapper;
|
|
|
|
|
|
public EnterprisesController(
|
|
|
IEnterpriseService enterpriseService,
|
|
|
- IRepository<EnterpriseSpecialist> enterpriseSpecialistRepository)
|
|
|
+ IRepository<EnterpriseSpecialist> enterpriseSpecialistRepository,
|
|
|
+ IEnterpriseApplication enterpriseApplication,
|
|
|
+ IMapper mapper)
|
|
|
{
|
|
|
_enterpriseService = enterpriseService;
|
|
|
_enterpriseSpecialistRepository = enterpriseSpecialistRepository;
|
|
|
+ _enterpriseApplication = enterpriseApplication;
|
|
|
+ _mapper = mapper;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#region (宜宾)获取企业信息
|
|
|
|
|
|
/// <summary>
|
|
@@ -39,25 +50,35 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#region 泸州
|
|
|
|
|
|
+ public async Task<PagedDto<UserDto>> QueryUsers([FromQuery] UserPagedDto request)
|
|
|
+ {
|
|
|
+ var query = _enterpriseApplication.QueryUsersForSpecialist(request);
|
|
|
+ var (total, users) = await query.ToPagedListAsync(request);
|
|
|
+ var userDtos = _mapper.Map<List<UserDto>>(users);
|
|
|
+ return new PagedDto<UserDto>(total, userDtos);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 批量新增企业专员
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("specialist-batch")]
|
|
|
- public Task<EnterpriseSpecialist> AddSpecialists()
|
|
|
+ public async Task AddSpecialists([FromBody] List<AddEnterpriseSpecialistDto> dto)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ var specialists = _mapper.Map<List<EnterpriseSpecialist>>(dto);
|
|
|
+ await _enterpriseSpecialistRepository.AddRangeAsync(specialists, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 批量删除企业专员
|
|
|
/// </summary>
|
|
|
- [HttpDelete("specialist-batch/{id}")]
|
|
|
- public Task RemoveSpecialists(string id)
|
|
|
+ [HttpDelete("specialist-batch")]
|
|
|
+ public async Task RemoveSpecialists([FromBody] List<string> ids)
|
|
|
{
|
|
|
- //清除子元素
|
|
|
- //then delete
|
|
|
- throw new NotImplementedException();
|
|
|
+ var specialists = await _enterpriseSpecialistRepository.Queryable()
|
|
|
+ .Where(d => ids.Contains(d.Id) || ids.Contains(d.ParentId))
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+ await _enterpriseSpecialistRepository.RemoveRangeAsync(specialists, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -68,30 +89,33 @@ namespace Hotline.Api.Controllers
|
|
|
public Task<List<EnterpriseSpecialist>> QuerySpecialists()
|
|
|
{
|
|
|
return _enterpriseSpecialistRepository.Queryable()
|
|
|
- .OrderBy(d=>d.Id)
|
|
|
- .ToTreeAsync(d=>d.Children, it => it.ParentId, null);
|
|
|
+ .OrderBy(d => d.Id)
|
|
|
+ .ToTreeAsync(d => d.Children, it => it.ParentId, null);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询企业专员工单
|
|
|
/// </summary>
|
|
|
[HttpGet("specialist/orders")]
|
|
|
- public Task<IReadOnlyList<OrderDto>> QueryEnterpriseSpecialistOrders([FromQuery] QueryOrderDto dto)
|
|
|
+ public async Task<IReadOnlyList<OrderDto>> QueryEnterpriseSpecialistOrders([FromQuery] QueryOrderDto dto)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ var query = await _enterpriseApplication.QueryEnterpriseSpecialistOrdersAsync(dto, HttpContext.RequestAborted);
|
|
|
+ var orders = query.ToPageListWithoutTotalAsync(dto, HttpContext.RequestAborted);
|
|
|
+ return _mapper.Map<IReadOnlyList<OrderDto>>(orders);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询总数
|
|
|
/// </summary>
|
|
|
[HttpGet("specialist/orders/count")]
|
|
|
- public Task<int> CountEnterpriseSpecialistOrders([FromQuery] QueryOrderDto dto)
|
|
|
+ public async Task<int> CountEnterpriseSpecialistOrders([FromQuery] QueryOrderDto dto)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ var query = await _enterpriseApplication.QueryEnterpriseSpecialistOrdersAsync(dto, HttpContext.RequestAborted);
|
|
|
+ return await query.CountAsync(HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
//todo export
|
|
|
-
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
-}
|
|
|
+}
|