UserBelongService.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using YiSha.Data.Repository;
  8. using YiSha.Entity.OrganizationManage;
  9. using YiSha.Enum;
  10. using YiSha.Model.Param.OrganizationManage;
  11. using YiSha.Util.Extension;
  12. using YiSha.Util.Model;
  13. namespace YiSha.Service.OrganizationManage
  14. {
  15. public partial class UserBelongService
  16. {
  17. private IRepositoryFactory _baseRepository;
  18. public UserBelongService(IRepositoryFactory baseRepository)
  19. {
  20. _baseRepository = baseRepository;
  21. }
  22. #region 获取数据
  23. public async Task<List<UserBelongEntity>> GetListPartial(UserBelongEntity entity)
  24. {
  25. var expression = LinqExtensions.True<UserBelongEntity>();
  26. expression = expression.And(t => t.BaseIsDelete == (int)IsDeleteEnum.No);
  27. if (entity != null)
  28. {
  29. if (entity.BelongType != null)
  30. {
  31. expression = expression.And(t => t.BelongType == entity.BelongType);
  32. }
  33. if (entity.UserId != null)
  34. {
  35. expression = expression.And(t => t.UserId == entity.UserId);
  36. }
  37. }
  38. var list = await _baseRepository.BaseRepository(dbConnectType).FindList(expression);
  39. return list.ToList();
  40. }
  41. #endregion
  42. #region 提交数据
  43. #endregion
  44. #region 私有方法
  45. /// <summary>
  46. /// 列表条件过滤
  47. /// 建议该方法放在Partial部分类中,因为代码生成时当前类会被覆盖(该方法在生成时将会被注释)
  48. /// </summary>
  49. /// <param name="param"></param>
  50. /// <returns></returns>
  51. private Expression<Func<UserBelongEntity, bool>> ListFilterPartial(UserBelongListParam param)
  52. {
  53. var expression = LinqExtensions.True<UserBelongEntity>();
  54. expression = expression.And(t => t.BaseIsDelete == (int)IsDeleteEnum.No);
  55. if (param != null)
  56. {
  57. }
  58. return expression;
  59. }
  60. #endregion
  61. }
  62. }