|
- using System;
- using System.Linq;
- using Microsoft.EntityFrameworkCore;
- using Permission.Entity.System;
- using Permission.Infrastructure.Repositories;
- using Permission.Infrastructure.WebControls;
- using Permission.Service.IServices;
- using Permission.Utils.Validate;
-
- namespace Permission.Service.Services
- {
- public class SysLogService : ISysLogService
- {
- private readonly IUnitOfWork _unitOfWork;
- private readonly IBaseRepository<SysLog> _sysLogRepository;
-
- public SysLogService(IUnitOfWork unitOfWork, IBaseRepository<SysLog> sysLogRepository)
- {
- this._unitOfWork = unitOfWork;
- this._sysLogRepository = sysLogRepository;
- }
-
- public Page<SysLog> PageList(string keyword, DateTime limitDate, int pagesize, int pageindex)
- {
- try
- {
- if (keyword.IsEmpty())
- {
- var data = _sysLogRepository.PageList<DateTime>(pageindex, pagesize, u => u.CreateTime > limitDate, us => us.CreateTime.Value, false);
- return data;
- }
- else
- {
- var data = _sysLogRepository.PageList<DateTime>(pageindex, pagesize, u => (u.Account.Contains(keyword) || u.RealName.Contains(keyword)) && u.CreateTime > limitDate, us => us.CreateTime.Value, false);
- return data;
- }
- }
- catch (Exception e)
- {
- throw e;
- }
- }
-
- public SysLog GetLogByKey(int key)
- {
- throw new NotImplementedException();
- }
-
- public bool DeleteModels(string keys)
- {
- bool flag = false;
- try
- {
- if (!keys.IsEmpty())
- {
- var logkeys = keys.Split(',').ToList();
- foreach (var key in logkeys)
- {
- var log = _sysLogRepository.Get(int.Parse(key));
- _sysLogRepository.Delete(log);
- }
- return true;
- }
- else
- {
- return false;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|