Skip to content

Commit

Permalink
feat: ✨ 框架代码同步 (#129)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
nsnail authored May 29, 2024
1 parent d9c7085 commit b01b8b2
Show file tree
Hide file tree
Showing 29 changed files with 224 additions and 41 deletions.
2 changes: 1 addition & 1 deletion assets/seed-data/Sys_Menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Id": 373837717815301,
"Name": "home",
"Path": "/home",
"Sort": 100,
"Sort": 999,
"Title": "主控面板",
"Type": 1
},
Expand Down
20 changes: 20 additions & 0 deletions assets/seed-data/Sys_RoleApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,25 @@
{
"ApiId": "api/sys/user",
"RoleId": 371729946431493
},
{
"ApiId": "api/sys/site.msg/unread.count",
"RoleId": 371729946431493,
},
{
"ApiId": "api/sys/site.msg",
"RoleId": 371729946431493,
},
{
"ApiId": "api/sys/site.msg/get.mine",
"RoleId": 371729946431493,
},
{
"ApiId": "api/sys/site.msg/paged.query.mine",
"RoleId": 371729946431493,
},
{
"ApiId": "api/sys/site.msg/set.site.msg.status",
"RoleId": 371729946431493,
}
]
2 changes: 1 addition & 1 deletion build/code.quality.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.25.0.90414">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.25.1.91650">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<ProjectReference Include="../NetAdmin.AdmServer.Host/NetAdmin.AdmServer.Host.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0-release-24177-07"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
</ItemGroup>
</Project>
29 changes: 29 additions & 0 deletions src/backend/NetAdmin.Application/Services/RedLockerService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Domain.DbMaps.Dependency;
using RedLockNet;

namespace NetAdmin.Application.Services;

/// <summary>
/// RedLocker Service Base
/// </summary>
public abstract class RedLockerService<T1, T2>(DefaultRepository<T1> rpo, RedLocker redLocker)
: RepositoryService<T1, T2>(rpo)
where T1 : EntityBase
{
/// <summary>
/// 获取锁
/// </summary>
/// <exception cref="NetAdminGetLockerException">NetAdminGetLockerException</exception>
protected async Task<IRedLock> GetLockerAsync(string lockName)
{
// 加锁
var redLock = await redLocker.RedLockFactory.CreateLockAsync( //
lockName, TimeSpan.FromSeconds(Numbers.SECS_RED_LOCK_EXPIRY)
, TimeSpan.FromSeconds(Numbers.SECS_RED_LOCK_WAIT)
, TimeSpan.FromSeconds(Numbers.SECS_RED_LOCK_RETRY))
.ConfigureAwait(false);

return redLock.IsAcquired ? redLock : throw new NetAdminGetLockerException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class MobileAttribute : RegexAttribute
public MobileAttribute() //
: base(Chars.RGX_MOBILE)
{
ErrorMessageResourceName = nameof(Ln.手机号码不正确);
ErrorMessageResourceName = nameof(Ln.手机号不正确);
ErrorMessageResourceType = typeof(Ln);
}
}
4 changes: 4 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_Dept.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public record Sys_Dept : VersionEntity, IFieldEnabled, IFieldSummary, IFieldSort
/// <summary>
/// 部门描述
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Summary { get; init; }
}
16 changes: 16 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,33 @@ public record Sys_Job : VersionEntity, IFieldEnabled, IFieldSummary
/// <summary>
/// 请求体
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestBody { get; init; }

/// <summary>
/// 请求头
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestHeader { get; init; }

/// <summary>
/// 请求的网络地址
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestUrl { get; init; }

Expand All @@ -94,7 +106,11 @@ public record Sys_Job : VersionEntity, IFieldEnabled, IFieldSummary
public virtual JobStatues Status { get; init; }

/// <inheritdoc cref="IFieldSummary.Summary" />
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Summary { get; init; }

Expand Down
16 changes: 16 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_JobRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@ public record Sys_JobRecord : LiteImmutableEntity
/// <summary>
/// 请求体
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestBody { get; init; }

/// <summary>
/// 请求头
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestHeader { get; init; }

Expand All @@ -69,14 +77,22 @@ public record Sys_JobRecord : LiteImmutableEntity
/// <summary>
/// 响应体
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ResponseBody { get; init; }

/// <summary>
/// 响应头
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ResponseHeader { get; init; }

Expand Down
40 changes: 38 additions & 2 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_RequestLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 创建者来源地址
/// </summary>
[Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public string CreatedReferer { get; init; }

/// <summary>
/// 创建者客户端用户代理
/// </summary>
[Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string CreatedUserAgent { get; init; }

Expand All @@ -63,14 +71,22 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 异常信息
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Exception { get; init; }

/// <summary>
/// 附加数据
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ExtraData { get; init; }

Expand All @@ -91,14 +107,22 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 来源地址
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ReferUrl { get; init; }

/// <summary>
/// 请求内容
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestBody { get; init; }

Expand All @@ -112,7 +136,11 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 请求头信息
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string RequestHeaders { get; init; }

Expand All @@ -126,7 +154,11 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 响应内容
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ResponseBody { get; init; }

Expand All @@ -140,7 +172,11 @@ public record Sys_RequestLog : ImmutableEntity, IFieldCreatedClient
/// <summary>
/// 响应头
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string ResponseHeaders { get; init; }

Expand Down
4 changes: 4 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public record Sys_Role : VersionEntity, IFieldSort, IFieldEnabled, IFieldSummary
/// <summary>
/// 备注
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Summary { get; init; }

Expand Down
12 changes: 12 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_SiteMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public record Sys_SiteMsg : VersionEntity, IRegister, IFieldSummary
/// <summary>
/// 消息内容
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Content { get; init; }

Expand Down Expand Up @@ -55,14 +59,22 @@ public record Sys_SiteMsg : VersionEntity, IRegister, IFieldSummary
/// <summary>
/// 消息摘要
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Summary { get; init; }

/// <summary>
/// 消息主题
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Title { get; init; }

Expand Down
4 changes: 4 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public record Sys_User : VersionEntity, IFieldSummary, IFieldEnabled, IRegister
/// <summary>
/// 描述
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public virtual string Summary { get; init; }

Expand Down
4 changes: 4 additions & 0 deletions src/backend/NetAdmin.Domain/DbMaps/Sys/Sys_VerifyCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public record Sys_VerifyCode : VersionEntity
/// <summary>
/// 发送报告
/// </summary>
#if DBTYPE_SQLITE
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#endif
[JsonIgnore]
public string Report { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public sealed record CheckMobileAvailableReq : Sys_User
/// <inheritdoc cref="Sys_User.Mobile" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Mobile]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.手机号码不能为空))]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.手机号不能为空))]
public override string Mobile { get; init; }
}
3 changes: 3 additions & 0 deletions src/backend/NetAdmin.Domain/NetAdmin.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DefineConstants>DBTYPE_SQLITE</DefineConstants>
</PropertyGroup>
<Import Project="$(SolutionDir)/build/code.quality.props"/>
<ItemGroup>
<Content Include="$(SolutionDir)/assets/seed-data/**" LinkBase="SeedData" CopyToOutputDirectory="PreserveNewest"/>
Expand Down
Loading

0 comments on commit b01b8b2

Please sign in to comment.