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] =?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