HomeController.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Microsoft.AspNetCore.Mvc;
  2. using CZFW.Framework.Interface;
  3. using CZKJ.GBRS2.Interface;
  4. using CZKJ.GBRS2.WebMVC.Models;
  5. using System.Linq;
  6. using CZFW.Framework.Model.Entity;
  7. using CZFW.Framework.Model.Enum;
  8. using System.ComponentModel;
  9. using System.Collections.Generic;
  10. namespace CZKJ.GBRS2.WebMVC.Controllers
  11. {
  12. public class HomeController : Controller
  13. {
  14. IGallery _galleryLogic;
  15. IType _typeLogic;
  16. IArticle _articleLogic;
  17. IFiles _fileLogic;
  18. INavigation _navigationLogic;
  19. IProduct _productLogic;
  20. ISysConfig _sysConfigLogic;
  21. public HomeController(IGallery galleryLogic, IType typeLogic, IArticle articleLogic, IFiles fileLogic, INavigation navigationLogic, IProduct productLogic,ISysConfig sysConfigLogic)
  22. {
  23. _galleryLogic = galleryLogic;
  24. _typeLogic = typeLogic;
  25. _articleLogic = articleLogic;
  26. _fileLogic = fileLogic;
  27. _navigationLogic = navigationLogic;
  28. _productLogic = productLogic;
  29. _sysConfigLogic = sysConfigLogic;
  30. }
  31. public IActionResult Index()
  32. {
  33. return View();
  34. }
  35. public IActionResult oldIndex()
  36. {
  37. var model = new IndexModel();
  38. var idList = new List<int> { 107, 108, 109, 148, 128,150 };
  39. var galleryList = _galleryLogic.GetGalleryList(idList);
  40. model.GalleryList = galleryList.Where(x => x.TypeId == 107).ToList();
  41. model.ProductList = galleryList.Where(x => x.TypeId == 128).ToList();
  42. model.FastIConList = galleryList.Where(x => x.TypeId == 109).ToList();
  43. model.BackGalleryList = galleryList.Where(x => x.TypeId == 150).ToList();
  44. model.LeftServicegallery = galleryList.FirstOrDefault(x => x.TypeId == 108) ?? new GalleryEntity();
  45. var typeList = _typeLogic.GetEntities(x => x.ParentId == (int)DefaultDataEnum.NewsCenterParentId, x => x.SortOrder, ListSortDirection.Descending).Take(4).ToList();
  46. model.TypeList = typeList;
  47. var typeIdList = typeList.Select(x => x.Id).ToList();
  48. model.ChildrenList = _typeLogic.GetEntities(x => typeIdList.Contains(x.ParentId));
  49. model.ServiceList = galleryList.Where(x => x.TypeId == 148).ToList();
  50. var configList = _sysConfigLogic.GetSysConfig("Twitter", "Facebook", "Weibo", "WeChatCode");
  51. model.Wechat = configList.First(x => x.Key == "WeChatCode").Value;
  52. model.Weibo = configList.First(x => x.Key == "Weibo").Value;
  53. model.Facebook = configList.First(x => x.Key == "Facebook").Value;
  54. model.Twitter = configList.First(x => x.Key == "Twitter").Value;
  55. return View(model);
  56. }
  57. public IActionResult AboutUs()
  58. {
  59. var model = new AboutUsModel();
  60. //依次为:顶部广告位 企业愿景广告位(大事记 法律声明 分支机构) 分支机构 (领导讲话 党建工作)股东背景广告位集合
  61. IList<int> idList = new List<int> { 136, 137, 138, 139, 140, 141 };
  62. var galleryList = _galleryLogic.GetEntities(x => idList.Contains(x.TypeId), x => x.SortOrder, ListSortDirection.Descending);
  63. model.Summary = _articleLogic.GetEntity(52);
  64. model.TopGallery = galleryList.FirstOrDefault(x => x.TypeId == 136);
  65. model.EnterpriseVision = galleryList.FirstOrDefault(x => x.TypeId == 137);
  66. model.CenterGalleryList = galleryList.Where(x => x.TypeId == 138).ToList();
  67. model.Department = galleryList.FirstOrDefault(x => x.TypeId == 139);
  68. model.LastGalleryList = galleryList.Where(x => x.TypeId == 140).ToList();
  69. model.BackgroundList = galleryList.Where(x => x.TypeId == 141).ToList();
  70. return View(model);
  71. }
  72. /// <summary>
  73. /// 资料下载
  74. /// </summary>
  75. /// <param name="pageIndex"></param>
  76. /// <param name="pageSize"></param>
  77. /// <returns></returns>
  78. public IActionResult Download(int pageIndex = 1, int pageSize = 10)
  79. {
  80. int rowsCount;
  81. var list = _fileLogic.GetEntities(out rowsCount, null, pageIndex, pageSize, x=>x.SortOrder, ListSortDirection.Descending);
  82. ViewBag.RowsCount = rowsCount;
  83. ViewBag.PageIndex = pageIndex;
  84. return View(list);
  85. }
  86. public IActionResult Map()
  87. {
  88. return View(_navigationLogic.GetNavigationTreeByMark("0$15231983314041342$"));
  89. }
  90. public IActionResult Search(string keywords, int aPageIndex = 1, int aPageSize = 10, int pPageIndex = 1, int pPageSize = 10)
  91. {
  92. var model = new HomeSearchModel();
  93. int aRowsCount;
  94. int pRowsCount;
  95. model.ArticleList = _articleLogic.GetSearchResult(keywords, aPageIndex, aPageSize, out aRowsCount);
  96. model.ProductList = _productLogic.GetSearchResult(keywords, pPageIndex, pPageSize, out pRowsCount);
  97. model.aPageIndex = aPageIndex;
  98. model.aRowsCount = aRowsCount;
  99. model.pPageIndex = pPageIndex;
  100. model.pRowsCount = pRowsCount;
  101. model.Keywords = keywords;
  102. return View(model);
  103. }
  104. }
  105. }