飞星
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

75 行
2.3 KiB

  1. using System;
  2. using System.Linq;
  3. using Microsoft.EntityFrameworkCore;
  4. using Permission.Entity.System;
  5. using Permission.Infrastructure.Repositories;
  6. using Permission.Infrastructure.WebControls;
  7. using Permission.Service.IServices;
  8. using Permission.Utils.Validate;
  9. namespace Permission.Service.Services
  10. {
  11. public class SysLogService : ISysLogService
  12. {
  13. private readonly IUnitOfWork _unitOfWork;
  14. private readonly IBaseRepository<SysLog> _sysLogRepository;
  15. public SysLogService(IUnitOfWork unitOfWork, IBaseRepository<SysLog> sysLogRepository)
  16. {
  17. this._unitOfWork = unitOfWork;
  18. this._sysLogRepository = sysLogRepository;
  19. }
  20. public Page<SysLog> PageList(string keyword, DateTime limitDate, int pagesize, int pageindex)
  21. {
  22. try
  23. {
  24. if (keyword.IsEmpty())
  25. {
  26. var data = _sysLogRepository.PageList<DateTime>(pageindex, pagesize, u => u.CreateTime > limitDate, us => us.CreateTime.Value, false);
  27. return data;
  28. }
  29. else
  30. {
  31. var data = _sysLogRepository.PageList<DateTime>(pageindex, pagesize, u => (u.Account.Contains(keyword) || u.RealName.Contains(keyword)) && u.CreateTime > limitDate, us => us.CreateTime.Value, false);
  32. return data;
  33. }
  34. }
  35. catch (Exception e)
  36. {
  37. throw e;
  38. }
  39. }
  40. public SysLog GetLogByKey(int key)
  41. {
  42. throw new NotImplementedException();
  43. }
  44. public bool DeleteModels(string keys)
  45. {
  46. bool flag = false;
  47. try
  48. {
  49. if (!keys.IsEmpty())
  50. {
  51. var logkeys = keys.Split(',').ToList();
  52. foreach (var key in logkeys)
  53. {
  54. var log = _sysLogRepository.Get(int.Parse(key));
  55. _sysLogRepository.Delete(log);
  56. }
  57. return true;
  58. }
  59. else
  60. {
  61. return false;
  62. }
  63. }
  64. catch (Exception ex)
  65. {
  66. throw ex;
  67. }
  68. }
  69. }
  70. }