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.
 
 
 
 
 
 

268 lines
8.0 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Util;
  3. using System.Web.Mvc;
  4. namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
  5. {
  6. /// <summary>
  7. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  8. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  9. /// 创建人:陈彬彬
  10. /// 日 期:2017.04.01
  11. /// 描 述:数据源管理
  12. /// </summary>
  13. public class DataSourceController : MvcControllerBase
  14. {
  15. DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
  16. #region 获取视图
  17. /// <summary>
  18. /// 管理页面
  19. /// </summary>
  20. /// <returns></returns>
  21. [HttpGet]
  22. public ActionResult Index()
  23. {
  24. return View();
  25. }
  26. /// <summary>
  27. /// 表单页面
  28. /// </summary>
  29. /// <returns></returns>
  30. [HttpGet]
  31. public ActionResult Form()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 测试页面
  37. /// </summary>
  38. /// <returns></returns>
  39. [HttpGet]
  40. public ActionResult TestForm()
  41. {
  42. return View();
  43. }
  44. /// <summary>
  45. /// 选择页面
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpGet]
  49. public ActionResult SelectForm()
  50. {
  51. return View();
  52. }
  53. #endregion
  54. #region 获取数据
  55. /// <summary>
  56. /// 获取分页数据
  57. /// </summary>
  58. /// <param name="pagination">分页参数</param>
  59. /// <param name="keyword">关键字</param>
  60. /// <returns></returns>
  61. [HttpGet]
  62. [AjaxOnly]
  63. public ActionResult GetPageList(string pagination, string keyword)
  64. {
  65. Pagination paginationobj = pagination.ToObject<Pagination>();
  66. var data = dataSourceIBLL.GetPageList(paginationobj, keyword);
  67. var jsonData = new
  68. {
  69. rows = data,
  70. total = paginationobj.total,
  71. page = paginationobj.page,
  72. records = paginationobj.records,
  73. };
  74. return JsonResult(jsonData);
  75. }
  76. /// <summary>
  77. /// 获取所有数据源数据列表
  78. /// </summary>
  79. /// <returns></returns>
  80. [HttpGet]
  81. [AjaxOnly]
  82. public ActionResult GetList()
  83. {
  84. var data = dataSourceIBLL.GetList();
  85. return JsonResult(data);
  86. }
  87. /// <summary>
  88. /// 获取所有数据源实体根据编号
  89. /// </summary>
  90. /// <param name="keyValue">编号</param>
  91. /// <returns></returns>
  92. [HttpGet]
  93. [AjaxOnly]
  94. public ActionResult GetEntityByCode(string keyValue)
  95. {
  96. if (string.IsNullOrEmpty(keyValue))
  97. {
  98. return Success("");
  99. }
  100. else
  101. {
  102. var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
  103. return JsonResult(data);
  104. }
  105. }
  106. /// <summary>
  107. /// 获取所有数据源实体根据编号
  108. /// </summary>
  109. /// <param name="keyValue">编号</param>
  110. /// <returns></returns>
  111. [HttpGet]
  112. [AjaxOnly]
  113. public ActionResult GetNameByCode(string keyValue)
  114. {
  115. if (string.IsNullOrEmpty(keyValue))
  116. {
  117. return SuccessString("");
  118. }
  119. else
  120. {
  121. var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
  122. if (data != null)
  123. {
  124. return SuccessString(data.F_Name);
  125. }
  126. else
  127. {
  128. return SuccessString("");
  129. }
  130. }
  131. }
  132. #endregion
  133. #region 提交数据
  134. /// <summary>
  135. /// 保存表单数据
  136. /// </summary>
  137. /// <param name="keyValue">主键</param>
  138. /// <param name="entity">实体</param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. [ValidateAntiForgeryToken]
  142. [AjaxOnly]
  143. public ActionResult SaveForm(string keyValue, DataSourceEntity entity)
  144. {
  145. bool res = dataSourceIBLL.SaveEntity(keyValue, entity);
  146. if (res)
  147. {
  148. return Success("保存成功!");
  149. }
  150. else
  151. {
  152. return Fail("保存失败,编码重复!");
  153. }
  154. }
  155. /// <summary>
  156. /// 删除表单数据
  157. /// </summary>
  158. /// <param name="keyValue">主键</param>
  159. /// <returns></returns>
  160. [HttpPost]
  161. [AjaxOnly]
  162. public ActionResult DeleteForm(string keyValue)
  163. {
  164. dataSourceIBLL.DeleteEntity(keyValue);
  165. return Success("删除成功!");
  166. }
  167. #endregion
  168. #region 扩展方法
  169. /// <summary>
  170. /// 获取数据源数据
  171. /// </summary>
  172. /// <param name="code">数据源编号</param>
  173. /// <param name="strWhere">sql查询条件语句</param>
  174. /// <param name="queryJson">数据源请求条件字串</param>
  175. /// <returns></returns>
  176. [HttpGet]
  177. [AjaxOnly]
  178. public ActionResult GetDataTable(string code, string strWhere, string queryJson)
  179. {
  180. var data = dataSourceIBLL.GetDataTable(code, strWhere, queryJson);
  181. return JsonResult(data);
  182. }
  183. /// <summary>
  184. /// 获取数据源数据
  185. /// </summary>
  186. /// <param name="pagination">分页参数</param>
  187. /// <param name="code">数据源编号</param>
  188. /// <param name="strWhere">sql查询条件语句</param>
  189. /// <param name="queryJson">数据源请求条件字串</param>
  190. /// <returns></returns>
  191. [HttpGet]
  192. [AjaxOnly]
  193. public ActionResult GetDataTablePage(string pagination, string code, string strWhere, string queryJson)
  194. {
  195. Pagination paginationobj = pagination.ToObject<Pagination>();
  196. var data = dataSourceIBLL.GetDataTable(code, paginationobj, strWhere, queryJson);
  197. var jsonData = new
  198. {
  199. rows = data,
  200. total = paginationobj.total,
  201. page = paginationobj.page,
  202. records = paginationobj.records,
  203. };
  204. return JsonResult(jsonData);
  205. }
  206. /// <summary>
  207. /// 获取数据源列名
  208. /// </summary>
  209. /// <param name="code">数据源编码</param>
  210. /// <returns></returns>
  211. [HttpGet]
  212. [AjaxOnly]
  213. public ActionResult GetDataColName(string code)
  214. {
  215. var data = dataSourceIBLL.GetDataColName(code);
  216. return JsonResult(data);
  217. }
  218. /// <summary>
  219. /// 获取数据源数据
  220. /// </summary>
  221. /// <param name="code">数据源编号</param>
  222. /// <param name="strWhere">sql查询条件语句</param>
  223. /// <param name="queryJson">数据源请求条件字串</param>
  224. /// <returns></returns>
  225. [HttpGet]
  226. [AjaxOnly]
  227. public ActionResult GetMap(string code, string ver)
  228. {
  229. var data = dataSourceIBLL.GetDataTable(code, "");
  230. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  231. if (md5 == ver)
  232. {
  233. return Success("no update");
  234. }
  235. else
  236. {
  237. var jsondata = new
  238. {
  239. data = data,
  240. ver = md5
  241. };
  242. return JsonResult(jsondata);
  243. }
  244. }
  245. /// <summary>
  246. /// 获取表单数据
  247. /// <summary>
  248. /// <returns></returns>
  249. [HttpGet]
  250. [AjaxOnly]
  251. public ActionResult GetTree(string code, string parentId, string Id, string showId)
  252. {
  253. var data = dataSourceIBLL.GetTree(code, parentId, Id, showId);
  254. return JsonResult(data);
  255. }
  256. #endregion
  257. }
  258. }