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.
 
 
 
 
 
 

349 lines
9.5 KiB

  1. using Learun.Application.Extention.PortalSiteManage;
  2. using System;
  3. using System.IO;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. namespace Learun.Application.Web.Areas.LR_PortalSite.Controllers
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  10. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2019-01-2 09:35
  13. /// 描 述:首页设置
  14. /// </summary>
  15. public class HomeConfigController : MvcControllerBase
  16. {
  17. private HomeConfigIBLL homeConfigIBLL = new HomeConfigBLL();
  18. #region 视图功能
  19. /// <summary>
  20. /// 首页配置页面
  21. /// </summary>
  22. /// <returns></returns>
  23. [HttpGet]
  24. public ActionResult Index()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 设置文字
  30. /// </summary>
  31. /// <returns></returns>
  32. [HttpGet]
  33. public ActionResult SetTextForm()
  34. {
  35. return View();
  36. }
  37. /// <summary>
  38. /// 顶部菜单设置
  39. /// </summary>
  40. /// <returns></returns>
  41. [HttpGet]
  42. public ActionResult TopMenuIndex()
  43. {
  44. return View();
  45. }
  46. /// <summary>
  47. /// 顶部菜单设置(表单)
  48. /// </summary>
  49. /// <returns></returns>
  50. [HttpGet]
  51. public ActionResult TopMenuForm()
  52. {
  53. return View();
  54. }
  55. /// <summary>
  56. /// 底部菜单设置
  57. /// </summary>
  58. /// <returns></returns>
  59. [HttpGet]
  60. public ActionResult BottomMenuIndex()
  61. {
  62. return View();
  63. }
  64. /// <summary>
  65. /// 底部菜单设置(表单)
  66. /// </summary>
  67. /// <returns></returns>
  68. [HttpGet]
  69. public ActionResult BottomMenuForm()
  70. {
  71. return View();
  72. }
  73. /// <summary>
  74. /// 配置轮播图
  75. /// </summary>
  76. /// <returns></returns>
  77. [HttpGet]
  78. public ActionResult PictureForm()
  79. {
  80. return View();
  81. }
  82. /// <summary>
  83. /// 添加模块(选择类型)
  84. /// </summary>
  85. /// <returns></returns>
  86. [HttpGet]
  87. public ActionResult SelectModuleForm()
  88. {
  89. return View();
  90. }
  91. /// <summary>
  92. /// 模块1配置
  93. /// </summary>
  94. /// <returns></returns>
  95. [HttpGet]
  96. public ActionResult ModuleForm1() {
  97. return View();
  98. }
  99. /// <summary>
  100. /// 模块2配置
  101. /// </summary>
  102. /// <returns></returns>
  103. [HttpGet]
  104. public ActionResult ModuleForm2()
  105. {
  106. return View();
  107. }
  108. /// <summary>
  109. /// 模块3配置
  110. /// </summary>
  111. /// <returns></returns>
  112. [HttpGet]
  113. public ActionResult ModuleForm3()
  114. {
  115. return View();
  116. }
  117. /// <summary>
  118. /// 模块3添加tab标签
  119. /// </summary>
  120. /// <returns></returns>
  121. [HttpGet]
  122. public ActionResult AddTabForm()
  123. {
  124. return View();
  125. }
  126. /// <summary>
  127. /// 模块4配置
  128. /// </summary>
  129. /// <returns></returns>
  130. [HttpGet]
  131. public ActionResult ModuleForm4()
  132. {
  133. return View();
  134. }
  135. /// <summary>
  136. /// 模块5配置
  137. /// </summary>
  138. /// <returns></returns>
  139. [HttpGet]
  140. public ActionResult ModuleForm5()
  141. {
  142. return View();
  143. }
  144. #endregion
  145. #region 获取数据
  146. /// <summary>
  147. /// 获取全部数据
  148. /// <summary>
  149. /// <returns></returns>
  150. [HttpGet]
  151. [AjaxOnly]
  152. public ActionResult GetAllList()
  153. {
  154. var data = homeConfigIBLL.GetALLList();
  155. return Success(data);
  156. }
  157. /// <summary>
  158. /// 获取数据
  159. /// <summary>
  160. /// <returns></returns>
  161. [HttpGet]
  162. [AjaxOnly]
  163. public ActionResult GetList(string type)
  164. {
  165. var data = homeConfigIBLL.GetList(type);
  166. return Success(data);
  167. }
  168. /// <summary>
  169. /// 获取树形数据
  170. /// <summary>
  171. /// <returns></returns>
  172. [HttpGet]
  173. [AjaxOnly]
  174. public ActionResult GetTree()
  175. {
  176. var data = homeConfigIBLL.GetTree();
  177. return Success(data);
  178. }
  179. /// <summary>
  180. /// 获取实体数据
  181. /// <summary>
  182. /// <returns></returns>
  183. [HttpGet]
  184. [AjaxOnly]
  185. public ActionResult GetEntity(string keyValue)
  186. {
  187. var data = homeConfigIBLL.GetEntity(keyValue);
  188. return Success(data);
  189. }
  190. #endregion
  191. #region 提交数据
  192. /// <summary>
  193. /// 删除实体数据
  194. /// <param name="keyValue">主键</param>
  195. /// <summary>
  196. /// <returns></returns>
  197. [HttpPost]
  198. [AjaxOnly]
  199. public ActionResult DeleteForm(string keyValue)
  200. {
  201. homeConfigIBLL.DeleteEntity(keyValue);
  202. return Success("删除成功!");
  203. }
  204. /// <summary>
  205. /// 保存实体数据(新增、修改)
  206. /// <param name="keyValue">主键</param>
  207. /// <summary>
  208. /// <returns></returns>
  209. [HttpPost]
  210. public ActionResult SaveForm(string keyValue, HomeConfigEntity entity)
  211. {
  212. homeConfigIBLL.SaveEntity(keyValue, entity);
  213. return SuccessString(entity.F_Id);
  214. }
  215. /// <summary>
  216. /// 保存实体数据(新增、修改)
  217. /// <param name="keyValue">主键</param>
  218. /// <summary>
  219. /// <returns></returns>
  220. [HttpPost]
  221. public ActionResult UpdateForm(string keyValue1,string keyValue2)
  222. {
  223. HomeConfigEntity entity1 = homeConfigIBLL.GetEntity(keyValue1);
  224. HomeConfigEntity entity2 = homeConfigIBLL.GetEntity(keyValue2);
  225. if (entity1 != null && entity2 != null) {
  226. int sort = (int)entity1.F_Sort;
  227. entity1.F_Sort = entity2.F_Sort;
  228. entity2.F_Sort = sort;
  229. homeConfigIBLL.SaveEntity(entity1.F_Id, entity1);
  230. homeConfigIBLL.SaveEntity(entity2.F_Id, entity2);
  231. }
  232. return Success("更新成功!");
  233. }
  234. /// <summary>
  235. /// 保存实体数据(新增、修改)
  236. /// <param name="keyValue">主键</param>
  237. /// <summary>
  238. /// <returns></returns>
  239. [HttpPost]
  240. public ActionResult SaveText(string type, string text)
  241. {
  242. homeConfigIBLL.SaveText(text, type);
  243. return Success("保存成功!");
  244. }
  245. /// <summary>
  246. /// 保存图片和存储数据
  247. /// </summary>
  248. /// <param name="type">类型</param>
  249. /// <returns></returns>
  250. [HttpPost]
  251. public ActionResult UploadFile(string type)
  252. {
  253. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  254. //没有文件上传,直接返回
  255. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  256. {
  257. return HttpNotFound();
  258. }
  259. else
  260. {
  261. string FileEextension = Path.GetExtension(files[0].FileName);
  262. byte[] bytes = new byte[files[0].InputStream.Length];
  263. files[0].InputStream.Read(bytes, 0, bytes.Length);
  264. string strBase64 = Convert.ToBase64String(bytes);
  265. homeConfigIBLL.SaveImg(strBase64, files[0].FileName, FileEextension, type);
  266. }
  267. return Success("保存成功。");
  268. }
  269. /// <summary>
  270. /// 保存图片和存储数据
  271. /// </summary>
  272. /// <param name="keyValue">主键</param>
  273. /// <param name="sort">排序码</param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. public ActionResult UploadFile2(string keyValue,int sort)
  277. {
  278. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  279. //没有文件上传,直接返回
  280. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  281. {
  282. return HttpNotFound();
  283. }
  284. else
  285. {
  286. string FileEextension = Path.GetExtension(files[0].FileName);
  287. byte[] bytes = new byte[files[0].InputStream.Length];
  288. files[0].InputStream.Read(bytes, 0, bytes.Length);
  289. string strBase64 = Convert.ToBase64String(bytes);
  290. homeConfigIBLL.SaveImg2(strBase64, files[0].FileName, FileEextension, keyValue, sort);
  291. }
  292. return Success("保存成功。");
  293. }
  294. #endregion
  295. #region 扩展功能
  296. /// <summary>
  297. /// 获取设置图片
  298. /// </summary>
  299. /// <param name="type">类型</param>
  300. /// <returns></returns>
  301. [HttpGet]
  302. public ActionResult GetImg(string type)
  303. {
  304. homeConfigIBLL.GetImg(type);
  305. return Success("获取成功。");
  306. }
  307. /// <summary>
  308. /// 获取设置图片
  309. /// </summary>
  310. /// <param name="keyValue">主键</param>
  311. /// <returns></returns>
  312. [HttpGet]
  313. public ActionResult GetImg2(string keyValue)
  314. {
  315. homeConfigIBLL.GetImg2(keyValue);
  316. return Success("获取成功。");
  317. }
  318. #endregion
  319. }
  320. }