mirror of
				https://github.com/nsnail/NetAdmin.git
				synced 2025-11-04 05:05:27 +08:00 
			
		
		
		
	chore: 🔨 css 基础单位 (#98)
This commit is contained in:
		@@ -0,0 +1,19 @@
 | 
			
		||||
using NetAdmin.Domain.DbMaps.Sys;
 | 
			
		||||
 | 
			
		||||
namespace NetAdmin.Domain.Dto.Sys.Dic.Content;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
///     请求:获取字典值
 | 
			
		||||
/// </summary>
 | 
			
		||||
public sealed record GetDicValueReq : Sys_DicContent
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
 | 
			
		||||
    [Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.字典目录编号不能为空))]
 | 
			
		||||
    public override long CatalogId { get; init; }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
 | 
			
		||||
    [Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.键名称不能为空))]
 | 
			
		||||
    public override string Key { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@@ -16,7 +16,7 @@ public sealed record QueryRequestLogRsp : Sys_RequestLog, IRegister
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     操作系统
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string Os => UserAgentParser.Create(CreatedUserAgent).Platform;
 | 
			
		||||
    public string Os => UserAgentParser.Create(CreatedUserAgent)?.Platform;
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc cref="Sys_RequestLog.ApiId" />
 | 
			
		||||
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
 | 
			
		||||
 
 | 
			
		||||
@@ -41,4 +41,12 @@ public static class StringExtensions
 | 
			
		||||
    {
 | 
			
		||||
        return _regex.Replace(me, string.Empty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     去掉前部字符串
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static string TrimStart(this string me, string clearStr)
 | 
			
		||||
    {
 | 
			
		||||
        return Regex.Replace(me, $"^{clearStr}", string.Empty);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -278,7 +278,7 @@ public sealed class UserAgentParser
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static UserAgentParser Create(string userAgentString)
 | 
			
		||||
    {
 | 
			
		||||
        return new UserAgentParser(userAgentString);
 | 
			
		||||
        return userAgentString == null ? null : new UserAgentParser(userAgentString);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private bool SetBrowser()
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,11 @@ public interface IDicModule
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Task<QueryDicContentRsp> GetContentAsync(QueryDicContentReq req);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     获取字典值
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public Task<string> GetDicValueAsync(GetDicValueReq req);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     分页查询字典目录
 | 
			
		||||
    /// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,28 @@ public sealed class DicService(IDicCatalogService catalogService, IDicContentSer
 | 
			
		||||
        return contentService.GetAsync(req);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public async Task<string> GetDicValueAsync(GetDicValueReq req)
 | 
			
		||||
    {
 | 
			
		||||
        req.ThrowIfInvalid();
 | 
			
		||||
        var df = new DynamicFilterInfo {
 | 
			
		||||
                                           Filters = [
 | 
			
		||||
                                               new DynamicFilterInfo {
 | 
			
		||||
                                                                         Field    = nameof(QueryDicContentReq.CatalogId)
 | 
			
		||||
                                                                       , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                                                       , Value    = req.CatalogId
 | 
			
		||||
                                                                     }
 | 
			
		||||
                                             , new DynamicFilterInfo {
 | 
			
		||||
                                                                         Field    = nameof(QueryDicContentReq.Key)
 | 
			
		||||
                                                                       , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                                                       , Value    = req.Key
 | 
			
		||||
                                                                     }
 | 
			
		||||
                                           ]
 | 
			
		||||
                                       };
 | 
			
		||||
        var queryParam = new QueryReq<QueryDicContentReq> { Count = 1, DynamicFilter = df };
 | 
			
		||||
        return (await QueryContentAsync(queryParam).ConfigureAwait(false)).FirstOrDefault()?.Value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<PagedQueryRsp<QueryDicCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDicCatalogReq> req)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -79,6 +79,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public async Task FinishJobAsync(UpdateJobReq req)
 | 
			
		||||
    {
 | 
			
		||||
        req.ThrowIfInvalid();
 | 
			
		||||
        var nextExecTime = GetNextExecTime(req.ExecutionCron);
 | 
			
		||||
        _ = await UpdateAsync(req with {
 | 
			
		||||
                                           Status = JobStatues.Idle
 | 
			
		||||
@@ -100,22 +101,24 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
 | 
			
		||||
    public async Task<QueryJobRsp> GetNextJobAsync()
 | 
			
		||||
    {
 | 
			
		||||
        var df = new DynamicFilterInfo {
 | 
			
		||||
                                           Filters =  [ new DynamicFilterInfo { Field = nameof(QueryJobReq.NextExecTime)
 | 
			
		||||
                                         , Value = DateTime.UtcNow
 | 
			
		||||
                                         , Operator = DynamicFilterOperators.LessThan
 | 
			
		||||
                                       }
 | 
			
		||||
          ,  new DynamicFilterInfo {
 | 
			
		||||
                                       Field    = nameof(QueryJobReq.Status)
 | 
			
		||||
                                     , Value    = JobStatues.Idle
 | 
			
		||||
                                     , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                   }
 | 
			
		||||
          , new DynamicFilterInfo {
 | 
			
		||||
                                      Field    = nameof(QueryJobReq.Enabled)
 | 
			
		||||
                                    , Value    = true
 | 
			
		||||
                                    , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                  }
 | 
			
		||||
            ]
 | 
			
		||||
        };
 | 
			
		||||
                                           Filters = [
 | 
			
		||||
                                               new DynamicFilterInfo {
 | 
			
		||||
                                                                         Field    = nameof(QueryJobReq.NextExecTime)
 | 
			
		||||
                                                                       , Value    = DateTime.UtcNow
 | 
			
		||||
                                                                       , Operator = DynamicFilterOperators.LessThan
 | 
			
		||||
                                                                     }
 | 
			
		||||
                                             , new DynamicFilterInfo {
 | 
			
		||||
                                                                         Field    = nameof(QueryJobReq.Status)
 | 
			
		||||
                                                                       , Value    = JobStatues.Idle
 | 
			
		||||
                                                                       , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                                                     }
 | 
			
		||||
                                             , new DynamicFilterInfo {
 | 
			
		||||
                                                                         Field    = nameof(QueryJobReq.Enabled)
 | 
			
		||||
                                                                       , Value    = true
 | 
			
		||||
                                                                       , Operator = DynamicFilterOperators.Eq
 | 
			
		||||
                                                                     }
 | 
			
		||||
                                           ]
 | 
			
		||||
                                       };
 | 
			
		||||
        var job = await QueryInternal(new QueryReq<QueryJobReq> { DynamicFilter = df, Count = 1 }, true)
 | 
			
		||||
                        .Where(a => !Rpo.Orm.Select<Sys_JobRecord>()
 | 
			
		||||
                                        .As("b")
 | 
			
		||||
@@ -163,6 +166,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<PagedQueryRsp<QueryJobRecordRsp>> RecordPagedQueryAsync(PagedQueryReq<QueryJobRecordReq> req)
 | 
			
		||||
    {
 | 
			
		||||
        req.ThrowIfInvalid();
 | 
			
		||||
        return jobRecordService.PagedQueryAsync(req);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -217,7 +221,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
 | 
			
		||||
                       , a => a.Id == req.Keywords.Int64Try(0) || a.JobName.Contains(req.Keywords))
 | 
			
		||||
                     .OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending);
 | 
			
		||||
        return !orderByRandom && (!req.Prop?.Equals(nameof(req.Filter.Id), StringComparison.OrdinalIgnoreCase) ?? true)
 | 
			
		||||
            ? ret.OrderByDescending(a => a.Id)
 | 
			
		||||
            ? ret.OrderByDescending(a => a.LastExecTime)
 | 
			
		||||
            : ret.OrderByRandom();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -13,8 +13,12 @@ public sealed class CacheCache(IDistributedCache cache, ICacheService service) /
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<CacheStatisticsRsp> CacheStatisticsAsync()
 | 
			
		||||
    {
 | 
			
		||||
        #if !DEBUG
 | 
			
		||||
        return GetOrCreateAsync( //
 | 
			
		||||
            GetCacheKey(string.Empty), Service.CacheStatisticsAsync, TimeSpan.FromMinutes(1));
 | 
			
		||||
        #else
 | 
			
		||||
        return Service.CacheStatisticsAsync();
 | 
			
		||||
        #endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,18 @@ public sealed class DicCache(IDistributedCache cache, IDicService service) //
 | 
			
		||||
        return Service.GetContentAsync(req);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<string> GetDicValueAsync(GetDicValueReq req)
 | 
			
		||||
    {
 | 
			
		||||
        #if !DEBUG
 | 
			
		||||
        return GetOrCreateAsync(                                                  //
 | 
			
		||||
            GetCacheKey(req.GetHashCode().ToString(CultureInfo.InvariantCulture)) //
 | 
			
		||||
          , () => Service.GetDicValueAsync(req), TimeSpan.FromMinutes(1));
 | 
			
		||||
        #else
 | 
			
		||||
        return Service.GetDicValueAsync(req);
 | 
			
		||||
        #endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<PagedQueryRsp<QueryDicCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDicCatalogReq> req)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,13 @@ public sealed class UserCache(IDistributedCache cache, IUserService service, IVe
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<IEnumerable<QueryUserRsp>> QueryAsync(QueryReq<QueryUserReq> req)
 | 
			
		||||
    {
 | 
			
		||||
        #if !DEBUG
 | 
			
		||||
        return GetOrCreateAsync(                                                  //
 | 
			
		||||
            GetCacheKey(req.GetHashCode().ToString(CultureInfo.InvariantCulture)) //
 | 
			
		||||
          , () => Service.QueryAsync(req), TimeSpan.FromMinutes(1));
 | 
			
		||||
        #else
 | 
			
		||||
        return Service.QueryAsync(req);
 | 
			
		||||
        #endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
@@ -185,8 +191,12 @@ public sealed class UserCache(IDistributedCache cache, IUserService service, IVe
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public Task<UserInfoRsp> UserInfoAsync()
 | 
			
		||||
    {
 | 
			
		||||
        #if !DEBUG
 | 
			
		||||
        return GetOrCreateAsync( //
 | 
			
		||||
            GetCacheKey(Service.UserToken.Id.ToString(CultureInfo.InvariantCulture)), Service.UserInfoAsync
 | 
			
		||||
,                                                                                     TimeSpan.FromMinutes(1));
 | 
			
		||||
        #else
 | 
			
		||||
        return Service.UserInfoAsync();
 | 
			
		||||
        #endif
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -85,6 +85,14 @@ public sealed class DicController(IDicCache cache) : ControllerBase<IDicCache, I
 | 
			
		||||
        return Cache.GetContentAsync(req);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     获取字典值
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public Task<string> GetDicValueAsync(GetDicValueReq req)
 | 
			
		||||
    {
 | 
			
		||||
        return Cache.GetDicValueAsync(req);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     分页查询字典目录
 | 
			
		||||
    /// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
 | 
			
		||||
            <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
        </PackageReference>
 | 
			
		||||
        <PackageReference Include="coverlet.collector" Version="6.0.1">
 | 
			
		||||
        <PackageReference Include="coverlet.collector" Version="6.0.2">
 | 
			
		||||
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
 | 
			
		||||
            <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
        </PackageReference>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user