From 15dd8a60d7a729ca22d086662580ba150488f9a7 Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 17 Sep 2023 09:52:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?easy.tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.Infrastructure.csproj | 2 ++ .../Bbs/Services/Impl/AccessLogService.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Yi.Framework.Infrastructure.csproj b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Yi.Framework.Infrastructure.csproj index dee903e2..7e3ece7c 100644 --- a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Yi.Framework.Infrastructure.csproj +++ b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Yi.Framework.Infrastructure.csproj @@ -8,6 +8,8 @@ + + diff --git a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs index 6ff6549a..c931c0d6 100644 --- a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs +++ b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -49,7 +50,8 @@ namespace Yi.Furion.Application.Bbs.Services.Impl private AccessLogDto[] WeekTimeHandler(AccessLogEntity[] data) { - data = data.Where(x => x.CreationTime.DayOfWeek == DateTime.Now.DayOfWeek).ToArray(); + data = data.Where(x=>x.CreationTime>=EasyTool.DateTimeUtil.GetFirstDayOfWeek()).OrderByDescending(x=>x.CreationTime).DistinctBy(x=>x.CreationTime.DayOfWeek).ToArray(); + Dictionary processedData = new Dictionary(); // 初始化字典,将每天的数据都设为0 From 2c2eb0cb8d6ea43be5c967d0aea390b10cc5c1b0 Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 17 Sep 2023 10:50:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dlinux=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=91=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bbs/Services/Impl/AccessLogService.cs | 40 ++++++++++++++++-- .../Yi.Furion.Web.Entry/yi-sqlsugar-dev.db | Bin 221184 -> 229376 bytes 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs index c931c0d6..003f0056 100644 --- a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs +++ b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; +using EasyTool.Extension; using Mapster; using Yi.Framework.Infrastructure.Ddd.Repositories; using Yi.Furion.Core.Bbs.Dtos.AccessLog; @@ -12,11 +13,42 @@ using Yi.Furion.Core.Bbs.Entities; namespace Yi.Furion.Application.Bbs.Services.Impl { [ApiDescriptionSettings("BBS")] - public class AccessLogService : IAccessLogService,IDynamicApiController + public class AccessLogService : IAccessLogService, IDynamicApiController { private readonly IRepository _repository; public AccessLogService(IRepository repository) { _repository = repository; } + public DateTime GetWeekFirst() + { + var week = DateTime.Now.DayOfWeek; + switch (week) + { + case DayOfWeek.Sunday: + return DateTime.Now.AddDays(-7).Date; + + case DayOfWeek.Monday: + return DateTime.Now.AddDays(-1).Date; + + case DayOfWeek.Tuesday: + return DateTime.Now.AddDays(-2).Date; + + case DayOfWeek.Wednesday: + return DateTime.Now.AddDays(-3).Date; + + case DayOfWeek.Thursday: + return DateTime.Now.AddDays(-4).Date; + + case DayOfWeek.Friday: + return DateTime.Now.AddDays(-5).Date; + + case DayOfWeek.Saturday: + return DateTime.Now.AddDays(-6).Date; + + default: + throw new ArgumentException("日期错误"); + } + } + /// /// 触发 /// @@ -50,8 +82,8 @@ namespace Yi.Furion.Application.Bbs.Services.Impl private AccessLogDto[] WeekTimeHandler(AccessLogEntity[] data) { - data = data.Where(x=>x.CreationTime>=EasyTool.DateTimeUtil.GetFirstDayOfWeek()).OrderByDescending(x=>x.CreationTime).DistinctBy(x=>x.CreationTime.DayOfWeek).ToArray(); - + data = data.Where(x => x.CreationTime >= GetWeekFirst()).OrderByDescending(x => x.CreationTime).DistinctBy(x => x.CreationTime.DayOfWeek).ToArray(); + Dictionary processedData = new Dictionary(); // 初始化字典,将每天的数据都设为0 @@ -66,7 +98,7 @@ namespace Yi.Furion.Application.Bbs.Services.Impl { DayOfWeek dayOfWeek = item.CreationTime.DayOfWeek; // 如果当天有数据,则更新字典中的值为对应的Number - var sss= data.Adapt(); + var sss = data.Adapt(); processedData[dayOfWeek] = item.Adapt(); } diff --git a/Yi.Furion.Net6/Yi.Furion.Web.Entry/yi-sqlsugar-dev.db b/Yi.Furion.Net6/Yi.Furion.Web.Entry/yi-sqlsugar-dev.db index 602627094d13664f947202a8c0aa5f73b5682664..8f7450951be88ee600afdac0808256bd12e32cdf 100644 GIT binary patch delta 196 zcmZoTz}wKkH$hsEnSp`90*GNia-xngD>H*$GGk*(YYOAm6s86F%#sYxr?VF@88AO* z+&ppOTC+w^Lw0d_dBlEkE(RLA7x)Z${F{B$_O+&ReAF~n6N#L>yeRY3_NK3Sem zht01vHz~Dfx}YAT@Z<%oER$n6xu)l7G0IQp(O^{MR8Y_~G-4BXm7mV2!YCmMH!t20 Q&a~M6tdL3S-68=60JUT`pa1{> delta 65 zcmZo@;A=R*J3(5IiGhK^42WSsVxo>QD-(mB`-;Yt))dCADNGCUnZ+5OO=mA)GT1C6 Nu%2=IvqC1RcL2HR5K{mE From ffb5898ea10a7e28e58d2759cbf303a36006a2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Mon, 18 Sep 2023 10:36:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bbs/Services/Impl/AccessLogService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs index 003f0056..a5326f0f 100644 --- a/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs +++ b/Yi.Furion.Net6/Yi.Furion.Application/Bbs/Services/Impl/AccessLogService.cs @@ -24,25 +24,25 @@ namespace Yi.Furion.Application.Bbs.Services.Impl switch (week) { case DayOfWeek.Sunday: - return DateTime.Now.AddDays(-7).Date; + return DateTime.Now.AddDays(-6).Date; case DayOfWeek.Monday: - return DateTime.Now.AddDays(-1).Date; + return DateTime.Now.AddDays(-0).Date; case DayOfWeek.Tuesday: - return DateTime.Now.AddDays(-2).Date; + return DateTime.Now.AddDays(-1).Date; case DayOfWeek.Wednesday: - return DateTime.Now.AddDays(-3).Date; + return DateTime.Now.AddDays(-2).Date; case DayOfWeek.Thursday: - return DateTime.Now.AddDays(-4).Date; + return DateTime.Now.AddDays(-3).Date; case DayOfWeek.Friday: - return DateTime.Now.AddDays(-5).Date; + return DateTime.Now.AddDays(-4).Date; case DayOfWeek.Saturday: - return DateTime.Now.AddDays(-6).Date; + return DateTime.Now.AddDays(-5).Date; default: throw new ArgumentException("日期错误");