UserCache.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using LeaRun.Application.Busines.BaseManage;
  2. using LeaRun.Application.Entity.BaseManage;
  3. using LeaRun.Application.Code;
  4. using LeaRun.Cache.Factory;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using LeaRun.Application.Entity.WebApp;
  9. namespace LeaRun.Application.Cache
  10. {
  11. /// <summary>
  12. /// 版 本 6.1
  13. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  14. /// 创建人:佘赐雄
  15. /// 日 期:2016.3.4 9:56
  16. /// 描 述:用户信息缓存
  17. /// </summary>
  18. public class UserCache
  19. {
  20. private UserBLL busines = new UserBLL();
  21. /// <summary>
  22. /// 用户列表
  23. /// </summary>
  24. /// <returns></returns>
  25. public IEnumerable<UserEntity> GetList()
  26. {
  27. IEnumerable<UserEntity> data = new List<UserEntity>();
  28. var cacheList = CacheFactory.Cache().GetCache<IEnumerable<UserEntity>>(busines.cacheKey);
  29. if (cacheList == null)
  30. {
  31. data = busines.GetList();
  32. CacheFactory.Cache().WriteCache(data, busines.cacheKey);
  33. }
  34. else
  35. {
  36. data = cacheList;
  37. }
  38. return data;
  39. }
  40. /// <summary>
  41. /// 用户列表
  42. /// </summary>
  43. /// <param name="departmentId">部门Id</param>
  44. /// <returns></returns>
  45. public IEnumerable<UserEntity> GetList(string departmentId)
  46. {
  47. var data = this.GetList();
  48. if (!string.IsNullOrEmpty(departmentId))
  49. {
  50. data = data.Where(t => t.DepartmentId == departmentId);
  51. }
  52. return data;
  53. }
  54. public Dictionary<string,appUserInfoModel> GetListToApp()
  55. {
  56. Dictionary<string, appUserInfoModel> data = new Dictionary<string,appUserInfoModel>();
  57. var datalist = this.GetList();
  58. foreach (var item in datalist)
  59. {
  60. appUserInfoModel one = new appUserInfoModel {
  61. UserId = item.UserId,
  62. Account = item.Account,
  63. RealName = item.RealName,
  64. OrganizeId = item.OrganizeId,
  65. DepartmentId = item.DepartmentId
  66. };
  67. data.Add(item.UserId, one);
  68. }
  69. return data;
  70. }
  71. }
  72. }