ResourcesService.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Lottomat.Application.Entity.PublicInfoManage;
  2. using Lottomat.Application.IService.PublicInfoManage;
  3. using Lottomat.Data.Repository;
  4. using Lottomat.Util.WebControl;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using Lottomat.Util.Extension;
  8. using Newtonsoft.Json.Linq;
  9. namespace Lottomat.Application.Service.PublicInfoManage
  10. {
  11. /// <summary>
  12. /// 版 本 1.0
  13. /// Copyright (c) 2016-2017
  14. /// 创 建:超级管理员
  15. /// 日 期:2017-08-02 12:20
  16. /// 描 述:资源分享
  17. /// </summary>
  18. public class ResourcesService : RepositoryFactory<ResourcesEntity>, IResourcesService
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取列表
  23. /// </summary>
  24. /// <param name="pagination">分页</param>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns>返回分页列表</returns>
  27. public IEnumerable<ResourcesEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. var expression = LinqExtensions.True<ResourcesEntity>();
  30. JObject queryParam = queryJson.ToJObject();
  31. if (queryParam != null)
  32. {
  33. if (!queryParam["Name"].IsEmpty())
  34. {
  35. string Name = queryParam["Name"].ToString();
  36. expression = expression.And(t => t.Name.Contains(Name));
  37. }
  38. if (!queryParam["TypeNme"].IsEmpty())
  39. {
  40. string TypeName = queryParam["TypeName"].ToString();
  41. expression = expression.And(t => t.TypeName == TypeName);
  42. }
  43. if (!queryParam["TypeId"].IsEmpty())
  44. {
  45. string TypeId = queryParam["TypeId"].ToString();
  46. expression = expression.And(t => t.TypeId == TypeId);
  47. }
  48. }
  49. return this.BaseRepository().FindList(expression, pagination);
  50. }
  51. /// <summary>
  52. /// 获取列表
  53. /// </summary>
  54. /// <param name="queryJson">查询参数</param>
  55. /// <returns>返回列表</returns>
  56. public IEnumerable<ResourcesEntity> GetList(string queryJson)
  57. {
  58. return this.BaseRepository().IQueryable().ToList();
  59. }
  60. /// <summary>
  61. /// 获取实体
  62. /// </summary>
  63. /// <param name="keyValue">主键值</param>
  64. /// <returns></returns>
  65. public ResourcesEntity GetEntity(string keyValue)
  66. {
  67. return this.BaseRepository().FindEntity(keyValue);
  68. }
  69. #endregion
  70. #region 提交数据
  71. /// <summary>
  72. /// 删除数据
  73. /// </summary>
  74. /// <param name="keyValue">主键</param>
  75. public void RemoveForm(string keyValue)
  76. {
  77. this.BaseRepository().Delete(keyValue);
  78. }
  79. /// <summary>
  80. /// 保存表单(新增、修改)
  81. /// </summary>
  82. /// <param name="keyValue">主键值</param>
  83. /// <param name="entity">实体对象</param>
  84. /// <returns></returns>
  85. public void SaveForm(string keyValue, ResourcesEntity entity)
  86. {
  87. if (!string.IsNullOrEmpty(keyValue))
  88. {
  89. entity.Modify(keyValue);
  90. this.BaseRepository().Update(entity);
  91. }
  92. else
  93. {
  94. entity.Create();
  95. this.BaseRepository().Insert(entity);
  96. }
  97. }
  98. #endregion
  99. }
  100. }