Merge branch 'furion' of https://gitee.com/ccnetcore/Yi into furion

This commit is contained in:
橙子
2023-09-18 23:31:44 +08:00
3 changed files with 39 additions and 3 deletions

View File

@@ -8,6 +8,8 @@
<ItemGroup>
<PackageReference Include="EasyTool.Core" Version="2023.914.2-pre-230916124403" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.43" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.43" />
<PackageReference Include="Furion.Pure" Version="4.8.8.43" />

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
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;
@@ -11,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<AccessLogEntity> _repository;
public AccessLogService(IRepository<AccessLogEntity> repository) { _repository = repository; }
public DateTime GetWeekFirst()
{
var week = DateTime.Now.DayOfWeek;
switch (week)
{
case DayOfWeek.Sunday:
return DateTime.Now.AddDays(-6).Date;
case DayOfWeek.Monday:
return DateTime.Now.AddDays(-0).Date;
case DayOfWeek.Tuesday:
return DateTime.Now.AddDays(-1).Date;
case DayOfWeek.Wednesday:
return DateTime.Now.AddDays(-2).Date;
case DayOfWeek.Thursday:
return DateTime.Now.AddDays(-3).Date;
case DayOfWeek.Friday:
return DateTime.Now.AddDays(-4).Date;
case DayOfWeek.Saturday:
return DateTime.Now.AddDays(-5).Date;
default:
throw new ArgumentException("日期错误");
}
}
/// <summary>
/// 触发
/// </summary>
@@ -49,7 +82,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 >= GetWeekFirst()).OrderByDescending(x => x.CreationTime).DistinctBy(x => x.CreationTime.DayOfWeek).ToArray();
Dictionary<DayOfWeek, AccessLogDto> processedData = new Dictionary<DayOfWeek, AccessLogDto>();
// 初始化字典将每天的数据都设为0
@@ -64,7 +98,7 @@ namespace Yi.Furion.Application.Bbs.Services.Impl
{
DayOfWeek dayOfWeek = item.CreationTime.DayOfWeek;
// 如果当天有数据则更新字典中的值为对应的Number
var sss= data.Adapt<AccessLogDto>();
var sss = data.Adapt<AccessLogDto>();
processedData[dayOfWeek] = item.Adapt<AccessLogDto>();
}