😎1、暂时先清空内置的定时任务数据 2、优化代码

This commit is contained in:
zuohuaijun 2025-08-30 15:52:41 +08:00
parent 96f1709af7
commit a6466a3901
10 changed files with 46 additions and 94 deletions

View File

@ -52,7 +52,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.2.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.11.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.13.0" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.253" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.255" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.200" />
<PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.7" />

View File

@ -84,8 +84,10 @@ public sealed class RequiredIFAttribute(
{
case Operator.Equal:
return TargetValue == null ? IsEmpty(targetValue) : CompareValues(targetValue, TargetValue, Comparison);
case Operator.NotEqual:
return TargetValue == null ? !IsEmpty(targetValue) : CompareValues(targetValue, TargetValue, Comparison);
case Operator.GreaterThan:
case Operator.LessThan:
case Operator.GreaterThanOrEqual:
@ -94,6 +96,7 @@ public sealed class RequiredIFAttribute(
case Operator.NotContains:
if (targetValue is IEnumerable enumerable) return enumerable.Cast<object>().Any(item => CompareValues(item, TargetValue, Comparison));
return TargetValue == null ? !IsEmpty(targetValue) : CompareValues(targetValue, TargetValue, Comparison);
default:
return false;
}
@ -131,11 +134,13 @@ public sealed class RequiredIFAttribute(
};
}
return false;
case Operator.Contains:
case Operator.NotContains:
if (targetValue is not IEnumerable enumerable) return false;
bool contains = enumerable.Cast<object>().Any(item => item != null && item.Equals(sourceValue));
return comparison == Operator.Contains ? contains : !contains;
default:
return false;
}

View File

@ -4,8 +4,6 @@
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using HandlebarsDotNet;
namespace Admin.NET.Core;
/// <summary>

View File

@ -380,13 +380,13 @@ public static class SqlSugarSetup
// 初始化文本简称表数据
if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) dbProvider.InitTextAbbData();
#region ,,
// 由于修改定时任务后数据库无法更新,暂时先清空内置的定时任务数据
if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId)
{
dbProvider.Deleteable<SysJobDetail>().Where(u => u.JobId == "job_log").ExecuteCommandAsync();
dbProvider.Deleteable<SysJobTrigger>().Where(u => u.TriggerId == "trigger_log").ExecuteCommandAsync();
var jobIds = dbProvider.Queryable<SysJobDetail>().Where(u => u.CreateType == JobCreateTypeEnum.BuiltIn).Select(u => u.JobId).ToList();
dbProvider.Deleteable<SysJobDetail>().Where(u => jobIds.Contains(u.JobId)).ExecuteCommand();
dbProvider.Deleteable<SysJobTrigger>().Where(u => jobIds.Contains(u.JobId)).ExecuteCommandAsync();
}
#endregion ,,
}
/// <summary>

View File

@ -560,7 +560,7 @@ public static class CommonHelper
/// <returns></returns>
public static bool IsMobile(string userAgent)
{
var mobilePatterns = new []{ "android.*mobile", "iphone", "ipod", "windows phone", "blackberry", "nokia", "mobile", "opera mini", "opera mobi", "palm", "webos", "bb\\d+", "meego" };
var mobilePatterns = new[] { "android.*mobile", "iphone", "ipod", "windows phone", "blackberry", "nokia", "mobile", "opera mini", "opera mobi", "palm", "webos", "bb\\d+", "meego" };
return mobilePatterns.Any(pattern => Regex.IsMatch(userAgent, pattern, RegexOptions.IgnoreCase));
}
}

View File

@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<NoWarn>1701;1702;1591;8632</NoWarn>
<DocumentationFile></DocumentationFile>
<ImplicitUsings>enable</ImplicitUsings>
<PreserveCompilationContext>true</PreserveCompilationContext>
<Nullable>disable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Copyright>Admin.NET</Copyright>
<Description>Admin.NET 通用权限开发平台</Description>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<NoWarn>1701;1702;1591;8632</NoWarn>
<DocumentationFile></DocumentationFile>
<ImplicitUsings>enable</ImplicitUsings>
<PreserveCompilationContext>true</PreserveCompilationContext>
<Nullable>disable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Copyright>Admin.NET</Copyright>
<Description>Admin.NET 通用权限开发平台</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Furion.Xunit" Version="4.9.7.114" />
<PackageReference Include="Furion.Pure" Version="4.9.7.114">
<ExcludeAssets>compile</ExcludeAssets>
</PackageReference>
<PackageReference Include="xunit.assert" Version="2.9.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Furion.Xunit" Version="4.9.7.114" />
<PackageReference Include="Furion.Pure" Version="4.9.7.114">
<ExcludeAssets>compile</ExcludeAssets>
</PackageReference>
<PackageReference Include="xunit.assert" Version="2.9.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Web.Core\Admin.NET.Web.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Web.Core\Admin.NET.Web.Core.csproj" />
</ItemGroup>
</Project>
</Project>

View File

@ -19,7 +19,7 @@ public class RequiredIFTest
private static bool IsValid(object instance) => Validator.TryValidateObject(instance, new ValidationContext(instance), null, true);
#endregion
#endregion
#region 1 [RequiredIF(nameof(TarProperty), 1)]
@ -39,11 +39,12 @@ public class RequiredIFTest
private class RequiredIfTest1Input
{
public int TarProperty { get; set; }
[RequiredIF(nameof(TarProperty), 1, ErrorMessage = "TarProperty为1时SomeProperty不能为空")]
public string SomeProperty { get; set; }
}
#endregion
#endregion 1 [RequiredIF(nameof(TarProperty), 1)]
#region 2 [RequiredIF(nameof(TarProperty), 1, Operator.NotEqual)]
@ -62,11 +63,12 @@ public class RequiredIFTest
private class RequiredIfTest2Input
{
public int TarProperty { get; set; }
[RequiredIF(nameof(TarProperty), 1, Operator.NotEqual, ErrorMessage = "TarProperty不为1时SomeProperty不能为空")]
public string SomeProperty { get; set; }
}
#endregion
#endregion 2 [RequiredIF(nameof(TarProperty), 1, Operator.NotEqual)]
#region 3 [RequiredIF(nameof(TarProperty), new[]{1,2}, Operator.Contains)]
@ -85,11 +87,12 @@ public class RequiredIFTest
private class RequiredIfTest3Input
{
public int[] TarProperty { get; set; }
[RequiredIF(nameof(TarProperty), new object[] { 1, 2 }, Operator.Contains, ErrorMessage = "TarProperty包含1或2时SomeProperty不能为空")]
public string SomeProperty { get; set; }
}
#endregion
#endregion 3 [RequiredIF(nameof(TarProperty), new[]{1,2}, Operator.Contains)]
#region 4 [RequiredIF(nameof(TarProperty), new[]{1,2}, Operator.NotContains)]
@ -112,7 +115,7 @@ public class RequiredIFTest
public string SomeProperty { get; set; }
}
#endregion
#endregion 4 [RequiredIF(nameof(TarProperty), new[]{1,2}, Operator.NotContains)]
#region longstringIList
@ -153,7 +156,7 @@ public class RequiredIFTest
public string SomeProperty { get; set; }
}
#endregion
#endregion longstringIList
#region null比较IComparable
@ -210,5 +213,5 @@ public class RequiredIFTest
public int TargetValue { get; set; }
}
#endregion
#endregion null比较IComparable
}

View File

@ -4,62 +4,8 @@
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
global using Admin.NET.Core.Service;
global using Admin.NET.Core;
global using Furion;
global using Furion.ConfigurableOptions;
global using Furion.DatabaseAccessor;
global using Furion.DataEncryption;
global using Furion.DataValidation;
global using Furion.DependencyInjection;
global using Furion.DynamicApiController;
global using Furion.EventBus;
global using Furion.FriendlyException;
global using Furion.HttpRemote;
global using Furion.JsonSerialization;
global using Furion.Logging;
global using Furion.Logging.Extensions;
global using Furion.Schedule;
global using Furion.UnifyResult;
global using Furion.ViewEngine;
global using Magicodes.ExporterAndImporter.Core;
global using Magicodes.ExporterAndImporter.Core.Extension;
global using Magicodes.ExporterAndImporter.Excel;
global using Mapster;
global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.Filters;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Microsoft.SemanticKernel;
global using NewLife;
global using NewLife.Caching;
global using Newtonsoft.Json.Linq;
global using SKIT.FlurlHttpClient;
global using SKIT.FlurlHttpClient.Wechat.Api;
global using SKIT.FlurlHttpClient.Wechat.Api.Models;
global using SKIT.FlurlHttpClient.Wechat.TenpayV3;
global using SKIT.FlurlHttpClient.Wechat.TenpayV3.Events;
global using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models;
global using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings;
global using SqlSugar;
global using System.Collections;
global using System.Collections.Concurrent;
global using System.ComponentModel;
global using System.ComponentModel.DataAnnotations;
global using System.Data;
global using System.Diagnostics;
global using System.Linq.Dynamic.Core;
global using System.Linq.Expressions;
global using System.Reflection;
global using System.Runtime.InteropServices;
global using System.Text;
global using System.Text.RegularExpressions;
global using System.Web;
global using UAParser;
global using Xunit;
global using Yitter.IdGenerator;
global using Xunit;

View File

@ -10,6 +10,7 @@ using Furion.Xunit;
using Xunit.Abstractions;
[assembly: TestFramework("Admin.NET.Test.TestProgram", "Admin.NET.Test")]
namespace Admin.NET.Test;
/// <summary>

View File

@ -185,7 +185,6 @@ public class CustomJsonHelperTest
Assert.Equal(obj.StringList, deserialized.StringList);
}
// 测试模型类
private class BasicTypesModel
{