Browse Source

广告增加过期时间

懒得勤快 5 years ago
parent
commit
c39d86acb0

+ 4 - 0
src/Masuit.MyBlogs.Core/Extensions/Hangfire/HangfireBackJob.cs

@@ -155,6 +155,10 @@ namespace Masuit.MyBlogs.Core.Extensions.Hangfire
             DateTime time = DateTime.Now.AddMonths(-1);
             _searchDetailsService.DeleteEntitySaved(s => s.SearchTime < time);
             TrackData.DumpLog();
+            _advertisementService.GetQuery(a => DateTime.Now >= a.ExpireTime).UpdateFromQuery(a => new Advertisement()
+            {
+                Status = Status.Unavailable
+            });
         }
 
         /// <summary>

+ 7 - 1
src/Masuit.MyBlogs.Core/Models/DTO/AdvertisementDto.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations;
 
 namespace Masuit.MyBlogs.Core.Models.DTO
 {
@@ -49,5 +50,10 @@ namespace Masuit.MyBlogs.Core.Models.DTO
         public string Types { get; set; }
 
         public string CategoryIds { get; set; }
+
+        /// <summary>
+        /// 到期时间
+        /// </summary>
+        public DateTime? ExpireTime { get; set; }
     }
 }

+ 5 - 0
src/Masuit.MyBlogs.Core/Models/Entity/Advertisement.cs

@@ -84,5 +84,10 @@ namespace Masuit.MyBlogs.Core.Models.Entity
         public int DisplayCount { get; set; }
 
         public string CategoryIds { get; set; }
+
+        /// <summary>
+        /// 到期时间
+        /// </summary>
+        public DateTime? ExpireTime { get; set; }
     }
 }

+ 5 - 0
src/Masuit.MyBlogs.Core/Models/ViewModel/AdvertisementViewModel.cs

@@ -82,5 +82,10 @@ namespace Masuit.MyBlogs.Core.Models.ViewModel
 
         public string CategoryIds { get; set; }
         public string CategoryNames { get; set; }
+
+        /// <summary>
+        /// 到期时间
+        /// </summary>
+        public DateTime? ExpireTime { get; set; }
     }
 }

+ 17 - 2
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/partner.js

@@ -82,8 +82,10 @@
 		}).catch(swal.noop);
 	}
 	$scope.add = function() {
-		$scope.partner = {};
-		$scope.isAdd = true;
+		$scope.partner = {
+			ExpireTime:"2099-12-31"
+        };
+        $scope.isAdd = true;
 		$scope.allowUpload=false;
 		layer.open({
 			type: 1,
@@ -101,6 +103,7 @@
 	}
 	$scope.edit = function (item) {
 		$scope.partner = angular.copy(item);
+		$scope.partner.ExpireTime=$scope.partner.ExpireTime == null?"2099-12-31":$scope.partner.ExpireTime;
 		$scope.isAdd = false;
 		$scope.allowUpload=false;
 		layer.closeAll();
@@ -213,4 +216,16 @@
 			}
 		});
 	}
+	jeDate('#timespan',{
+		isinitVal: true,
+		festival: true,
+		isTime: true,
+		ishmsVal: true,
+		format: 'YYYY-MM-DD hh:mm:ss',
+		minDate: new Date().Format("yyyy-MM-dd 00:00:00"),
+		maxDate: '2099-12-31 23:59:59',
+		donefun: function (obj) {
+			$scope.partner.ExpireTime = obj.val;
+		}
+	});
 }]);

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/partner.min.js


+ 27 - 1
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/partner.html

@@ -3,6 +3,22 @@
         max-height: 800px;
         overflow-y: auto;
     }
+    .wicon {
+        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAASAgMAAAA1aVZ3AAAACVBMVEUAAAD///9nyrNdI4MmAAAAAXRSTlMAQObYZgAAAChJREFUCNdjWAUCCxjg9DQgtTKBAUN8aigQJGCho6KiYDSJ8ggaYR8Ao74zAKjm+cYAAAAASUVORK5CYII=");
+        background-repeat: no-repeat;
+        background-position: right center;
+    }
+
+    .workinput {
+        width: 100%;
+        line-height: 21px;
+        border: 1px #ddd solid;
+        border-radius: 4px;
+        padding: 5px;
+        background-color: transparent;
+        float: left;
+        font-size: 14px;
+    }
 </style>
 <div>
     <div class="form-inline pull-right">
@@ -169,6 +185,12 @@
                     </div>
                 </div>
             </div>
+            <div class="input-group">
+                <label for="desc" class="input-group-addon control-label">过期时间:</label>
+                <div class="fg-line">
+                    <input type="text" class="workinput wicon" id="timespan" ng-model="partner.ExpireTime" readonly="readonly" />
+                </div>
+            </div>
             <div class="form-group">
                 <div class="col-xs-12">
                     <div class="fg-line">
@@ -196,9 +218,13 @@
                 </tr>
                 <tr>
                     <td>推广地址</td>
-                    <td colspan="2">
+                    <td>
                         <a ng-href="{{partner.Url}}" target="_blank">{{partner.Url}}</a>
                     </td>
+                    <td>过期时间</td>
+                    <td>
+                        {{partner.ExpireTime|date:'yyyy-MM-dd HH:mm:ss'}}
+                    </td>
                 </tr>
                 <tr>
                     <td>类型:</td>

Some files were not shown because too many files changed in this diff