using Infrastructure.Attribute;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model;
using ARW.Repository;
using ARW.Repository.Business.CustomerServices;
using ARW.Service.Api.IBusinessService.CustomerServices;
using ARW.Model.Dto.Api.CustomerServices;
using ARW.Model.Models.Business.CustomerServices;
using ARW.Model.Vo.Api.CustomerServices;
namespace ARW.Service.Api.BusinessService.CustomerServices
{
///
/// 客服接口实现类Api
///
/// @author lwh
/// @date 2023-10-21
///
[AppService(ServiceType = typeof(ICustomerServiceServiceApi), ServiceLifetime = LifeTime.Transient)]
public class CustomerServiceServiceImplApi : BaseService, ICustomerServiceServiceApi
{
private readonly CustomerServiceRepository _CustomerServiceRepository;
public CustomerServiceServiceImplApi(CustomerServiceRepository CustomerServiceRepository)
{
this._CustomerServiceRepository = CustomerServiceRepository;
}
#region Api接口代码
///
/// 查询客服列表(Api)
///
///
///
public async Task> GetCustomerServiceListApi(CustomerServiceQueryDtoApi parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerServiceName), s => s.CustomerServiceName.Contains(parm.CustomerServiceName));
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerServicePhone), s => s.CustomerServicePhone.Contains(parm.CustomerServicePhone));
var query = _CustomerServiceRepository
.Queryable()
.Where(predicate.ToExpression())
.OrderBy(s => s.CustomerServiceSort, OrderByType.Desc)
.Select(s => new CustomerServiceVoApi
{
CustomerServiceId = s.CustomerServiceId,
CustomerServiceGuid = s.CustomerServiceGuid,
CustomerServiceName = s.CustomerServiceName,
CustomerServicePhone = s.CustomerServicePhone,
CustomerServiceImg = s.CustomerServiceImg,
WorkingHoursBeginTime = s.WorkingHoursBeginTime,
WorkingHoursEndTime = s.WorkingHoursEndTime,
CustomerServiceSort = s.CustomerServiceSort,
});
return await query.ToListAsync();
}
#endregion
}
}