Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CommunityInfoApi.cs 5.5 KiB

před 4 roky
před 4 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using Nancy;
  2. using Learun.Util;
  3. using System.Collections.Generic;
  4. using Learun.Application.TwoDevelopment.PersonnelManagement;
  5. using System;
  6. namespace Learun.Application.WebApi
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2020-01-04 11:47
  13. /// 描 述:社团管理
  14. /// </summary>
  15. public class CommunityInfoApi : BaseApi
  16. {
  17. private CommunityInfoIBLL communityInfoIBLL = new CommunityInfoBLL();
  18. private CommunityMemberIBLL communityMemberIBLL = new CommunityMemberBLL();
  19. /// <summary>
  20. /// 注册接口
  21. /// <summary>
  22. public CommunityInfoApi()
  23. : base("/Learun/adms/PersonnelManagement/CommunityInfo")
  24. {
  25. Get["/pagelist"] = GetPageList;
  26. Get["/list"] = GetList;
  27. Get["/form"] = GetForm;
  28. Post["/delete"] = DeleteForm;
  29. Post["/save"] = SaveForm;
  30. Post["/join"] = JoinForm;
  31. Get["/communityMemberpagelist"] = GetCommunityMemberPageList;
  32. }
  33. #region 获取数据
  34. /// <summary>
  35. /// 获取页面显示列表分页数据
  36. /// <summary>
  37. /// <param name="_"></param>
  38. /// <returns></returns>
  39. public Response GetPageList(dynamic _)
  40. {
  41. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  42. var data = communityInfoIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  43. var jsonData = new
  44. {
  45. rows = data,
  46. total = parameter.pagination.total,
  47. page = parameter.pagination.page,
  48. records = parameter.pagination.records
  49. };
  50. return Success(jsonData);
  51. }
  52. /// <summary>
  53. /// 获取页面显示列表数据
  54. /// <summary>
  55. /// <param name="_"></param>
  56. /// <returns></returns>
  57. public Response GetList(dynamic _)
  58. {
  59. string queryJson = this.GetReqData();
  60. var data = communityInfoIBLL.GetList(queryJson);
  61. return Success(data);
  62. }
  63. /// <summary>
  64. /// 获取表单数据
  65. /// <summary>
  66. /// <param name="_"></param>
  67. /// <returns></returns>
  68. public Response GetForm(dynamic _)
  69. {
  70. string keyValue = this.GetReqData();
  71. var CommunityInfoData = communityInfoIBLL.GetCommunityInfoEntity(keyValue);
  72. var jsonData = new
  73. {
  74. CommunityInfo = CommunityInfoData,
  75. };
  76. return Success(jsonData);
  77. }
  78. #endregion
  79. #region 提交数据
  80. /// <summary>
  81. /// 删除实体数据
  82. /// <param name="_"></param>
  83. /// <summary>
  84. /// <returns></returns>
  85. public Response DeleteForm(dynamic _)
  86. {
  87. string keyValue = this.GetReqData();
  88. communityInfoIBLL.DeleteEntity(keyValue);
  89. return Success("删除成功!");
  90. }
  91. /// <summary>
  92. /// 保存实体数据(新增、修改)
  93. /// <param name="_"></param>
  94. /// <summary>
  95. /// <returns></returns>
  96. public Response SaveForm(dynamic _)
  97. {
  98. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  99. CommunityInfoEntity entity = parameter.strEntity.ToObject<CommunityInfoEntity>();
  100. communityInfoIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity);
  101. return Success("保存成功!");
  102. }
  103. /// <summary>
  104. /// 申请加入社团
  105. /// <param name="_"></param>
  106. /// <summary>
  107. /// <returns></returns>
  108. public Response JoinForm(dynamic _)
  109. {
  110. string keyValue = this.GetReqData();
  111. if (this.userInfo.Description != "学生")
  112. {
  113. return Fail("当前账号不是学生账号!");
  114. }
  115. CommunityMemberEntity entity = new CommunityMemberEntity()
  116. {
  117. CommunityId = keyValue,
  118. StuNo = this.userInfo.account,
  119. StuName = this.userInfo.realName,
  120. JoinTime = DateTime.Now.Date,
  121. CreateTime = DateTime.Now,
  122. CreateUserId = this.userInfo.userId,
  123. CreateUserName = this.userInfo.realName
  124. };
  125. communityMemberIBLL.SaveEntity("", entity);
  126. return Success("保存成功!");
  127. }
  128. /// <summary>
  129. /// 我的社团
  130. /// <summary>
  131. /// <param name="_"></param>
  132. /// <returns></returns>
  133. public Response GetCommunityMemberPageList(dynamic _)
  134. {
  135. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  136. var data = communityMemberIBLL.GetPageList(parameter.pagination, parameter.queryJson, this.userInfo.account);
  137. var jsonData = new
  138. {
  139. rows = data,
  140. total = parameter.pagination.total,
  141. page = parameter.pagination.page,
  142. records = parameter.pagination.records
  143. };
  144. return Success(jsonData);
  145. }
  146. #endregion
  147. #region 私有类
  148. /// <summary>
  149. /// 表单实体类
  150. /// <summary>
  151. private class ReqFormEntity
  152. {
  153. public string keyValue { get; set; }
  154. public string strEntity { get; set; }
  155. }
  156. #endregion
  157. }
  158. }