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.
 
 
 
 
 
 

227 lines
6.4 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.Extention.PortalSiteManage;
  3. using Learun.Util;
  4. using System;
  5. using System.IO;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. namespace Learun.Application.Web.Areas.LR_PortalSite.Controllers
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  12. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-01-2 09:35
  15. /// 描 述:子页面管理
  16. /// </summary>
  17. public class PageController : MvcControllerBase
  18. {
  19. private PageIBLL pageIBLL = new PageBLL();
  20. private ImgIBLL imgIBLL = new ImgBLL();
  21. #region 视图功能
  22. /// <summary>
  23. /// 主页面
  24. /// </summary>
  25. /// <returns></returns>
  26. [HttpGet]
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 表单页面
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. public ActionResult Form()
  37. {
  38. return View();
  39. }
  40. /// <summary>
  41. /// 选择类型页面
  42. /// </summary>
  43. /// <returns></returns>
  44. [HttpGet]
  45. public ActionResult SelectForm()
  46. {
  47. return View();
  48. }
  49. /// <summary>
  50. /// 设置名称
  51. /// </summary>
  52. /// <returns></returns>
  53. [HttpGet]
  54. public ActionResult SetNameForm() {
  55. return View();
  56. }
  57. /// <summary>
  58. /// 设置内容
  59. /// </summary>
  60. /// <returns></returns>
  61. [HttpGet]
  62. public ActionResult SetContentForm()
  63. {
  64. return View();
  65. }
  66. /// <summary>
  67. /// 设置分类项
  68. /// </summary>
  69. /// <returns></returns>
  70. [HttpGet]
  71. public ActionResult SetCategoryForm()
  72. {
  73. return View();
  74. }
  75. #endregion
  76. #region 获取数据
  77. /// <summary>
  78. /// 获取列表分页数据
  79. /// <param name="pagination">分页参数</param>
  80. /// <summary>
  81. /// <returns></returns>
  82. [HttpGet]
  83. [AjaxOnly]
  84. public ActionResult GetPageList(string pagination, string queryJson)
  85. {
  86. Pagination paginationobj = pagination.ToObject<Pagination>();
  87. var data = pageIBLL.GetPageList(paginationobj, queryJson);
  88. var jsonData = new
  89. {
  90. rows = data,
  91. total = paginationobj.total,
  92. page = paginationobj.page,
  93. records = paginationobj.records
  94. };
  95. return Success(jsonData);
  96. }
  97. /// <summary>
  98. /// 获取列表分页数据
  99. /// <param name="pagination">分页参数</param>
  100. /// <summary>
  101. /// <returns></returns>
  102. [HttpGet]
  103. [AjaxOnly]
  104. public ActionResult GetList()
  105. {
  106. var data = pageIBLL.GetList();
  107. return Success(data);
  108. }
  109. /// <summary>
  110. /// 获取表单数据
  111. /// <param name="keyValue">主键</param>
  112. /// <summary>
  113. /// <returns></returns>
  114. [HttpGet]
  115. [AjaxOnly]
  116. public ActionResult GetFormData(string keyValue)
  117. {
  118. var data = pageIBLL.GetEntity(keyValue);
  119. return Success(data);
  120. }
  121. #endregion
  122. #region 提交数据
  123. /// <summary>
  124. /// 删除实体数据
  125. /// <param name="keyValue">主键</param>
  126. /// <summary>
  127. /// <returns></returns>
  128. [HttpPost]
  129. [AjaxOnly]
  130. public ActionResult DeleteForm(string keyValue)
  131. {
  132. var entity = pageIBLL.GetEntity(keyValue);
  133. pageIBLL.DeleteEntity(keyValue);
  134. if (!string.IsNullOrEmpty(entity.F_Img))
  135. {
  136. imgIBLL.DeleteEntity(entity.F_Img);
  137. }
  138. return Success("删除成功!");
  139. }
  140. /// <summary>
  141. /// 保存实体数据(新增、修改)
  142. /// <param name="keyValue">主键</param>
  143. /// <summary>
  144. /// <returns></returns>
  145. [HttpPost]
  146. [ValidateAntiForgeryToken]
  147. [AjaxOnly, ValidateInput(false)]
  148. public ActionResult SaveForm(string keyValue, PageEntity entity)
  149. {
  150. pageIBLL.SaveEntity(keyValue, entity);
  151. return Success("保存成功!");
  152. }
  153. /// <summary>
  154. /// 保存图片和存储数据
  155. /// </summary>
  156. /// <param name="keyValue">主键</param>
  157. /// <param name="entity">实体</param>
  158. /// <returns></returns>
  159. [ValidateInput(false)]
  160. [HttpPost]
  161. public ActionResult UploadFile(string keyValue, PageEntity entity)
  162. {
  163. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  164. //没有文件上传,直接返回
  165. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  166. {
  167. pageIBLL.SaveEntity(keyValue, entity);
  168. }
  169. else
  170. {
  171. string FileEextension = Path.GetExtension(files[0].FileName);
  172. ImgEntity imgEntity = null;
  173. if (string.IsNullOrEmpty(entity.F_Img))
  174. {
  175. imgEntity = new ImgEntity();
  176. }
  177. else
  178. {
  179. imgEntity = imgIBLL.GetEntity(entity.F_Img);
  180. }
  181. imgEntity.F_Name = files[0].FileName;
  182. imgEntity.F_ExName = FileEextension;
  183. byte[] bytes = new byte[files[0].InputStream.Length];
  184. files[0].InputStream.Read(bytes, 0, bytes.Length);
  185. imgEntity.F_Content = Convert.ToBase64String(bytes);
  186. imgIBLL.SaveEntity(entity.F_Img, imgEntity);
  187. entity.F_Img = imgEntity.F_Id;
  188. pageIBLL.SaveEntity(keyValue, entity);
  189. }
  190. return Success("保存成功。");
  191. }
  192. #endregion
  193. #region 扩展方法
  194. /// <summary>
  195. /// 获取设置图片
  196. /// </summary>
  197. /// <param name="keyValue">主键</param>
  198. /// <returns></returns>
  199. [HttpGet]
  200. public ActionResult GetImg(string keyValue)
  201. {
  202. pageIBLL.GetImg(keyValue);
  203. return Success("获取成功。");
  204. }
  205. #endregion
  206. }
  207. }