UsersRepository.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.AesEncryption;
  4. using OASystem.Domain.Entities.System;
  5. using OASystem.Domain.ViewModels.System;
  6. using SqlSugar;
  7. using StackExchange.Redis;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace OASystem.Infrastructure.Repositories.System
  14. {
  15. public class UsersRepository : BaseRepository<UserInfo, UserInfoWebView>
  16. {
  17. public UsersRepository(SqlSugarClient sqlSugar) : base(sqlSugar){}
  18. /// <summary>
  19. /// 用户查询列表
  20. /// </summary>
  21. /// <param name="_userRep"></param>
  22. /// <returns></returns>
  23. public async Task<Result> GetUserList(int portType,string sqlWhere)
  24. {
  25. Result result = new Result() { Code = -2, Msg = "暂无数据!" };
  26. string userSqlWhere = string.Format(@"Select su.CompanyId, sc.CompanyName,su.DepId,sd.DepName,su.JobPostId,sjp.JobName,
  27. su.Id UserId,su.CnName,su.Number,su.Ext,su.Phone,su.UrgentPhone,su.Email
  28. From Sys_Users su
  29. Inner Join Sys_Company sc On su.CompanyId = sc.Id
  30. Inner Join Sys_Department sd On su.DepId = sd.Id
  31. Inner Join Sys_JobPost sjp On su.JobPostId = sjp.Id Where su.IsDel = 0");
  32. var _userList = await _sqlSugar.SqlQueryable<UserInfoWebView>(userSqlWhere).ToListAsync();
  33. if (portType == 1 || portType == 2 || portType == 3) //web、Android、ios
  34. {
  35. //解密
  36. foreach (var user in _userList) EncryptionProcessor.DecryptProperties(user);
  37. if (_userList.Count != 0)
  38. {
  39. result.Code = 0;
  40. result.Msg = "成功!";
  41. result.Data = _userList;
  42. }
  43. }
  44. return result;
  45. }
  46. /// <summary>
  47. /// 用户查询列表
  48. /// </summary>
  49. /// <param name="_userRep"></param>
  50. /// <returns></returns>
  51. public async Task<Result> GetUserNameList(int portType)
  52. {
  53. Result result = new Result() { Code = -2 };
  54. if (portType == 1 || portType == 2) //web
  55. {
  56. string sql = string.Format(@"Select Id,CnName From Sys_Users Where Isdel=0 And HrAudit = 1");
  57. var _userList = await _sqlSugar.SqlQueryable<UserNameView>(sql).ToListAsync();
  58. if (_userList.Count != 0)
  59. {
  60. result.Code = 0;
  61. result.Msg = "成功!";
  62. result.Data = _userList;
  63. }
  64. else
  65. {
  66. result.Msg = "暂无数据!";
  67. }
  68. }
  69. else if (portType == 2) //Android
  70. {
  71. }
  72. else if (portType == 3) //IOS
  73. {
  74. }
  75. else
  76. {
  77. result.Msg = "暂无数据!";
  78. }
  79. return result;
  80. }
  81. public async Task<List<UserInfo>> QueryUser(string sqlWhere)
  82. {
  83. string sql = string.Format(@"Select sc.CompanyName,sd.DepName,sjp.JobName,su.* From Sys_Users su
  84. left Join Sys_Company sc On su.CompanyId = sc.Id
  85. left Join Sys_Department sd On su.DepId = sd.Id
  86. left Join Sys_JobPost sjp On su.JobPostId = sjp.Id {0}", sqlWhere);
  87. return await _sqlSugar.SqlQueryable<UserInfo>(sql).ToListAsync();
  88. }
  89. }
  90. }