You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
4.3 KiB

  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace Learun.Application.CRM
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2017-07-11 09:58
  13. /// 描 述:客户联系人
  14. /// </summary>
  15. public class CrmCustomerContactService : RepositoryFactory
  16. {
  17. #region 获取数据
  18. /// <summary>
  19. /// 获取列表
  20. /// </summary>
  21. /// <param name="queryJson">查询参数</param>
  22. /// <returns>返回列表</returns>
  23. public IEnumerable<CrmCustomerContactEntity> GetList(string queryJson)
  24. {
  25. try
  26. {
  27. var expression = LinqExtensions.True<CrmCustomerContactEntity>();
  28. var queryParam = queryJson.ToJObject();
  29. //客户Id
  30. if (!queryParam["customerId"].IsEmpty())
  31. {
  32. string CustomerId = queryParam["customerId"].ToString();
  33. expression = expression.And(t => t.F_CustomerId == CustomerId);
  34. }
  35. //查询条件
  36. if (!queryParam["keyword"].IsEmpty())
  37. {
  38. string keyword = queryParam["keyword"].ToString();
  39. expression = expression.And(t => t.F_Contact.Contains(keyword) || t.F_Mobile.Contains(keyword) || t.F_Tel.Contains(keyword) || t.F_QQ.Contains(keyword));
  40. }
  41. return this.BaseRepository().IQueryable(expression).OrderByDescending(t => t.F_CreateDate).ToList();
  42. }
  43. catch (Exception ex)
  44. {
  45. if (ex is ExceptionEx)
  46. {
  47. throw;
  48. }
  49. else
  50. {
  51. throw ExceptionEx.ThrowServiceException(ex);
  52. }
  53. }
  54. }
  55. /// <summary>
  56. /// 获取实体
  57. /// </summary>
  58. /// <param name="keyValue">主键值</param>
  59. /// <returns></returns>
  60. public CrmCustomerContactEntity GetEntity(string keyValue)
  61. {
  62. try
  63. {
  64. return this.BaseRepository().FindEntity<CrmCustomerContactEntity>(keyValue);
  65. }
  66. catch (Exception ex)
  67. {
  68. if (ex is ExceptionEx)
  69. {
  70. throw;
  71. }
  72. else
  73. {
  74. throw ExceptionEx.ThrowServiceException(ex);
  75. }
  76. }
  77. }
  78. #endregion
  79. #region 提交数据
  80. /// <summary>
  81. /// 删除数据
  82. /// </summary>
  83. /// <param name="keyValue">主键</param>
  84. public void DeleteEntity(string keyValue)
  85. {
  86. try
  87. {
  88. this.BaseRepository().Delete<CrmCustomerContactEntity>(t => t.F_CustomerContactId == keyValue);
  89. }
  90. catch (Exception ex)
  91. {
  92. if (ex is ExceptionEx)
  93. {
  94. throw;
  95. }
  96. else
  97. {
  98. throw ExceptionEx.ThrowServiceException(ex);
  99. }
  100. }
  101. }
  102. /// <summary>
  103. /// 保存表单(新增、修改)
  104. /// </summary>
  105. /// <param name="keyValue">主键值</param>
  106. /// <param name="entity">实体对象</param>
  107. /// <returns></returns>
  108. public void SaveEntity(string keyValue, CrmCustomerContactEntity entity)
  109. {
  110. try
  111. {
  112. if (!string.IsNullOrEmpty(keyValue))
  113. {
  114. entity.Modify(keyValue);
  115. this.BaseRepository().Update(entity);
  116. }
  117. else
  118. {
  119. entity.Create();
  120. this.BaseRepository().Insert(entity);
  121. }
  122. }
  123. catch (Exception ex)
  124. {
  125. if (ex is ExceptionEx)
  126. {
  127. throw;
  128. }
  129. else
  130. {
  131. throw ExceptionEx.ThrowServiceException(ex);
  132. }
  133. }
  134. }
  135. #endregion
  136. }
  137. }