irc-netcore-api/IRaCIS.Core.Application/Service/Management/UserLogService.cs

71 lines
2.8 KiB
C#

//--------------------------------------------------------------------
// 此代码由T4模板自动生成 byzhouhang 20210918
// 生成时间 2023-07-04 16:10:37
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
namespace IRaCIS.Core.Application.Service
{
/// <summary>
/// UserLogService
/// </summary>
[ApiExplorerSettings(GroupName = "Test")]
public class UserLogService : BaseService, IUserLogService
{
private readonly IRepository<UserLog> _userLogRepository;
private readonly IRepository<TrialUser> _trialUserRepository;
public UserLogService(IRepository<UserLog> userLogRepository, IRepository<TrialUser> trialUserRepository)
{
_userLogRepository = userLogRepository;
_trialUserRepository = trialUserRepository;
}
public async Task<PageOutput<UserLogView>> GetUserLogList(UserLogQuery inQuery)
{
var userLogQueryable =
_userLogRepository
.WhereIf(inQuery.TrialId != null, t => t.LoginUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && c.UserId == t.CreateUserId))
.WhereIf(inQuery.OptType!=null ,t=>t.OptType==inQuery.OptType)
.WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
.WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginName) , t => t.LoginName.Contains(inQuery.LoginName) )
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP))
.ProjectTo<UserLogView>(_mapper.ConfigurationProvider);
var pageList = await userLogQueryable.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? "Id" : inQuery.SortField,inQuery.Asc);
return pageList;
}
//public async Task<IResponseOutput> AddOrUpdateUserLog(UserLogAddOrEdit addOrEditUserLog)
//{
// // 在此处拷贝automapper 映射
// var entity = await _userLogRepository.InsertOrUpdateAsync(addOrEditUserLog, true);
// return ResponseOutput.Ok(entity.Id.ToString());
//}
//[HttpDelete("{userLogId:guid}")]
//public async Task<IResponseOutput> DeleteUserLog(Guid userLogId)
//{
// var success = await _userLogRepository.DeleteFromQueryAsync(t => t.Id == userLogId, true);
// return ResponseOutput.Ok();
//}
}
}