Browse Source

轮播图接入数据

lifa 1 year ago
parent
commit
19a0b70aab

+ 4 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/IndexOutput.cs

@@ -66,6 +66,10 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
     /// </summary>
     public class Imgs
     {
+        public Imgs()
+        {
+
+        }
         public Imgs(string imgUrl, string jumpType, string jumpParam, string workTime, string failureTime, string sort)
         {
             ImgUrl = imgUrl;

+ 45 - 27
src/platform/ZhonTai.Admin/Services/DiTuiAPI/IndexService.cs

@@ -12,9 +12,11 @@ using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Attributes;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Dto;
+using ZhonTai.Admin.Domain.Banner;
 using ZhonTai.Admin.Domain.Project;
 using ZhonTai.Admin.Domain.User;
 using ZhonTai.Admin.Repositories;
+using ZhonTai.Admin.Repositories.Banner;
 using ZhonTai.Admin.Repositories.Notice;
 using ZhonTai.Admin.Repositories.Project;
 using ZhonTai.Admin.Services.DiTuiAPI.Dto;
@@ -33,12 +35,14 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         private ProjectRepository _projectRepository;
         private NoticeRepository _noticeRepository;
         private OrgRepository _orgRepository;
+        private BannerRepository _bannerRepository;
 
-        public IndexService(ProjectRepository projectRepository,NoticeRepository noticeRepository,OrgRepository orgRepository)
+        public IndexService(ProjectRepository projectRepository,NoticeRepository noticeRepository,OrgRepository orgRepository, BannerRepository bannerRepository)
         {
             _projectRepository = projectRepository;
             _noticeRepository = noticeRepository;
             _orgRepository = orgRepository;
+            _bannerRepository = bannerRepository;
         }
 
         /// <summary>
@@ -62,32 +66,46 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             indexOutPut.Tips = "推广要求:杜绝任何虚假、作弊、违法行为!";
 
             List<Imgs> imgsList = new List<Imgs>();
-            imgsList.Add(new Imgs(
-                "https://test-dt.zhongjie51.com/assetsImg/lunbo1.png",
-                "1",
-                "11",
-                "2023-01-11 11:11:11",
-                "2023-11-11 11:11:11",
-                "99"
-                ));
-            imgsList.Add(new Imgs(
-                "https://test-dt.zhongjie51.com/assetsImg/lunbo2.png",
-                "2",
-                "222",
-                "2023-02-02 12:12:12",
-                "2023-12-22 14:59:49",
-                "99"
-                ));
-            imgsList.Add(new Imgs(
-                "https://test-dt.zhongjie51.com/assetsImg/lunbo3.png",
-                "3",
-                "333",
-                "2023-03-03 12:12:12",
-                "2023-12-30 14:59:49",
-                "99"
-                ));
-
-            indexOutPut.Imgs = imgsList;
+            var bannerResult = await _bannerRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                .Where(a => a.Status == 1)
+                .OrderByDescending(a => a.Rank)
+                .ToListAsync(a => new Imgs
+                {
+                    ImgUrl = a.ImgUrl,
+                    JumpType = a.SkipWay.ToString(),
+                    JumpParam = a.SkipContent,
+                    WorkTime = DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss"),
+                    FailureTime = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"),
+                    Sort = a.Rank.ToString()
+                }) ;
+            #region moke数据
+            //imgsList.Add(new Imgs(
+            //    "https://test-dt.zhongjie51.com/assetsImg/lunbo1.png",
+            //    "1",
+            //    "11",
+            //    "2023-01-11 11:11:11",
+            //    "2023-11-11 11:11:11",
+            //    "99"
+            //    ));
+            //imgsList.Add(new Imgs(
+            //    "https://test-dt.zhongjie51.com/assetsImg/lunbo2.png",
+            //    "2",
+            //    "222",
+            //    "2023-02-02 12:12:12",
+            //    "2023-12-22 14:59:49",
+            //    "99"
+            //    ));
+            //imgsList.Add(new Imgs(
+            //    "https://test-dt.zhongjie51.com/assetsImg/lunbo3.png",
+            //    "3",
+            //    "333",
+            //    "2023-03-03 12:12:12",
+            //    "2023-12-30 14:59:49",
+            //    "99"
+            //    ));
+            #endregion
+
+            indexOutPut.Imgs = bannerResult;
 
 
             //List<Notices> notices = new List<Notices>();