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.

MyFunctionService.cs 3.1 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace Learun.Application.AppMagager
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2018-06-26 10:32
  13. /// 描 述:我的常用移动应用
  14. /// </summary>
  15. public class MyFunctionService: RepositoryFactory
  16. {
  17. #region 构造函数和属性
  18. private string fieldSql;
  19. public MyFunctionService()
  20. {
  21. fieldSql = @"
  22. t.F_Id,
  23. t.F_UserId,
  24. t.F_FunctionId,
  25. t.F_Sort
  26. ";
  27. }
  28. #endregion
  29. #region 获取数据
  30. /// <summary>
  31. /// 获取列表数据
  32. /// </summary>
  33. /// <param name="userId">用户主键ID</param>
  34. /// <returns></returns>
  35. public IEnumerable<MyFunctionEntity> GetList(string userId)
  36. {
  37. try
  38. {
  39. var strSql = new StringBuilder();
  40. strSql.Append("SELECT ");
  41. strSql.Append(fieldSql);
  42. strSql.Append(" FROM LR_App_MyFunction t where t.F_UserId = @userId Order by t.F_Sort ");
  43. return this.BaseRepository().FindList<MyFunctionEntity>(strSql.ToString(),new { userId });
  44. }
  45. catch (Exception ex)
  46. {
  47. if (ex is ExceptionEx)
  48. {
  49. throw;
  50. }
  51. else
  52. {
  53. throw ExceptionEx.ThrowServiceException(ex);
  54. }
  55. }
  56. }
  57. #endregion
  58. #region 提交数据
  59. /// <summary>
  60. /// 保存实体数据(新增、修改)
  61. /// <param name="keyValue">主键</param>
  62. /// <summary>
  63. /// <returns></returns>
  64. public void SaveEntity(string userId,string strFunctionId)
  65. {
  66. var db = this.BaseRepository().BeginTrans();
  67. try
  68. {
  69. string[] functionIds = strFunctionId.Split(',');
  70. db.Delete<MyFunctionEntity>(t=>t.F_UserId.Equals(userId));
  71. int num = 0;
  72. foreach (var functionId in functionIds) {
  73. MyFunctionEntity entity = new MyFunctionEntity();
  74. entity.Create();
  75. entity.F_UserId = userId;
  76. entity.F_FunctionId = functionId;
  77. entity.F_Sort = num;
  78. db.Insert(entity);
  79. num++;
  80. }
  81. db.Commit();
  82. }
  83. catch (Exception ex)
  84. {
  85. db.Rollback();
  86. if (ex is ExceptionEx)
  87. {
  88. throw;
  89. }
  90. else
  91. {
  92. throw ExceptionEx.ThrowServiceException(ex);
  93. }
  94. }
  95. }
  96. #endregion
  97. }
  98. }