key1_beacon_api/ARW.Service/Business/BusinessService/Custom/CustomerLoginLogs/CustomerLoginLogService.cs
2023-11-22 12:17:14 +08:00

96 lines
3.1 KiB
C#

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 Infrastructure;
using ARW.Model;
using ARW.Repository;
using ARW.Repository.Business.Custom.CustomerLoginLogs;
using ARW.Service.Business.IBusinessService.Custom.CustomerLoginLogs;
using ARW.Model.Dto.Business.Custom.CustomerLoginLogs;
using ARW.Model.Models.Business.Custom.CustomerLoginLogs;
using ARW.Model.Vo.Business.Custom.CustomerLoginLogs;
using ARW.Model.Models.Business.Custom.Customers;
namespace ARW.Service.Business.BusinessService.Custom.CustomerLoginLogs
{
/// <summary>
/// 客户登录日志接口实现类
///
/// @author lwh
/// @date 2023-11-21
/// </summary>
[AppService(ServiceType = typeof(ICustomerLoginLogService), ServiceLifetime = LifeTime.Transient)]
public class CustomerLoginLogServiceImpl : BaseService<CustomerLoginLog>, ICustomerLoginLogService
{
private readonly CustomerLoginLogRepository _CustomerLoginLogRepository;
public CustomerLoginLogServiceImpl(CustomerLoginLogRepository CustomerLoginLogRepository)
{
this._CustomerLoginLogRepository = CustomerLoginLogRepository;
}
#region
/// <summary>
/// 查询客户登录日志分页列表
/// </summary>
public async Task<PagedInfo<CustomerLoginLogVo>> GetCustomerLoginLogList(CustomerLoginLogQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<CustomerLoginLog>();
predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
var query = _CustomerLoginLogRepository
.Queryable()
.LeftJoin<Customer>((s, c) => s.CustomerGuid == c.CustomerGuid)
.Where(predicate.ToExpression())
.OrderBy(s => s.Create_time, OrderByType.Desc)
.Select((s, c) => new CustomerLoginLogVo
{
CustomerLoginLogId = s.CustomerLoginLogId,
CustomerLoginLogGuid = s.CustomerLoginLogGuid,
CustomerGuid = s.CustomerGuid,
CreateTime = s.Create_time,
CustomerNickName = c.CustomerNickname
});
return await query.ToPageAsync(parm);
}
/// <summary>
/// 添加或修改客户登录日志
/// </summary>
public async Task<string> AddOrUpdateCustomerLoginLog(CustomerLoginLog model)
{
if (model.CustomerLoginLogId != 0)
{
var response = await _CustomerLoginLogRepository.UpdateAsync(model);
return "修改成功!";
}
else
{
var response = await _CustomerLoginLogRepository.InsertReturnSnowflakeIdAsync(model);
return "添加成功!";
}
}
#region Excel处理
#endregion
#endregion
}
}