AreaService.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using LeaRun.Application.Entity.SystemManage;
  2. using LeaRun.Application.IService.SystemManage;
  3. using LeaRun.Data.Repository;
  4. using LeaRun.Util.Extension;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace LeaRun.Application.Service.SystemManage
  8. {
  9. /// <summary>
  10. /// 版 本 6.1
  11. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  12. /// 创建人:佘赐雄
  13. /// 日 期:2015.11.12 16:40
  14. /// 描 述:区域管理
  15. /// </summary>
  16. public class AreaService : RepositoryFactory<AreaEntity>, IAreaService
  17. {
  18. #region 获取数据
  19. /// <summary>
  20. /// 区域列表
  21. /// </summary>
  22. /// <returns></returns>
  23. public IEnumerable<AreaEntity> GetList()
  24. {
  25. return this.BaseRepository().IQueryable(t => t.Layer != 4).OrderBy(t => t.CreateDate).ToList();
  26. }
  27. /// <summary>
  28. /// 区域列表
  29. /// </summary>
  30. /// <param name="parentId">节点Id</param>
  31. /// <param name="keyword">关键字查询</param>
  32. /// <returns></returns>
  33. public IEnumerable<AreaEntity> GetList(string parentId, string keyword)
  34. {
  35. var expression = LinqExtensions.True<AreaEntity>();
  36. if (!string.IsNullOrEmpty(parentId))
  37. {
  38. expression = expression.And(t => t.ParentId == parentId);
  39. }
  40. if (!string.IsNullOrEmpty(keyword))
  41. {
  42. expression = expression.And(t => t.AreaCode.Contains(keyword));
  43. expression = expression.Or(t => t.AreaName.Contains(keyword));
  44. }
  45. return this.BaseRepository().IQueryable(expression).OrderBy(t => t.CreateDate).ToList();
  46. }
  47. /// <summary>
  48. /// 区域实体
  49. /// </summary>
  50. /// <param name="keyValue">主键值</param>
  51. /// <returns></returns>
  52. public AreaEntity GetEntity(string keyValue)
  53. {
  54. return this.BaseRepository().FindEntity(keyValue);
  55. }
  56. #endregion
  57. #region 提交数据
  58. /// <summary>
  59. /// 删除区域
  60. /// </summary>
  61. /// <param name="keyValue">主键</param>
  62. public void RemoveForm(string keyValue)
  63. {
  64. this.BaseRepository().Delete(keyValue);
  65. }
  66. /// <summary>
  67. /// 保存区域表单(新增、修改)
  68. /// </summary>
  69. /// <param name="keyValue">主键值</param>
  70. /// <param name="{">区域实体</param>
  71. /// <returns></returns>
  72. public void SaveForm(string keyValue, AreaEntity areaEntity)
  73. {
  74. if (!string.IsNullOrEmpty(keyValue))
  75. {
  76. areaEntity.Modify(keyValue);
  77. this.BaseRepository().Update(areaEntity);
  78. }
  79. else
  80. {
  81. areaEntity.Create();
  82. this.BaseRepository().Insert(areaEntity);
  83. }
  84. }
  85. #endregion
  86. }
  87. }