using Infrastructure.Attribute;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ARW.Model;
using ARW.Repository;
using ARW.Service.Api.IBusinessService.Custom.Customers;
using ARW.Model.Dto.Api.Custom.Customers;
using ARW.Model.Vo.Api.Custom.Customers;
using ARW.Model.Models.Business.Custom.Customers;
using ARW.Repository.Business.Custom.Customers;
namespace ARW.Service.Api.BusinessService.Custom.Customers
{
///
/// 小程序客户接口实现类Api
///
/// @author 黎文豪
/// @date 2023-06-07
///
[AppService(ServiceType = typeof(ICustomerServiceApi), ServiceLifetime = LifeTime.Transient)]
public class CustomerServiceImplApi : BaseService, ICustomerServiceApi
{
private readonly CustomerRepository _CustomerRepository;
public CustomerServiceImplApi(CustomerRepository CustomerRepository)
{
this._CustomerRepository = CustomerRepository;
}
#region Api接口代码
///
/// 查询小程序客户详情(Api)
///
///
///
public Task GetCustomerDetails(CustomerQueryDtoApi parm)
{
var query = _CustomerRepository
.Queryable()
.Where(s => s.CustomerGuid == parm.CustomerGuid)
.Select(s => new CustomerApiDetailsVo
{
CustomerId = s.CustomerId,
CustomerGuid = s.CustomerGuid,
CustomerXcxOpenid = s.CustomerXcxOpenid,
CustomerNickname = s.CustomerNickname,
CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber,
CustomerAvatar = s.CustomerAvatar,
CustomerGender = s.CustomerGender,
CustomerType = s.CustomerType
}).Take(1);
return query.ToJsonAsync();
}
///
/// 编辑客户信息
///
public async Task UpdateCustomer(Customer model)
{
var response = await _CustomerRepository.UpdateAsync(f => new Customer
{
CustomerAvatar = model.CustomerAvatar,
CustomerNickname = model.CustomerNickname,
CustomerGender = model.CustomerGender,
}, s => s.CustomerGuid == model.CustomerGuid);
return "修改成功!";
}
#endregion
}
}