From eb9073057a12825f64627fee94e99b6bd452c7e5 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 12:59:36 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B9=81=E4=BD=93?= =?UTF-8?q?=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Properties/Resources.zh-Hant.resx | 112 ++++++++++++++++++ .../Starfish.Webapp/Properties/Resources.resx | 2 +- .../Properties/Resources.zh-Hant.resx | 101 ++++++++++++++++ 3 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 Source/Starfish.Client/Properties/Resources.zh-Hant.resx create mode 100644 Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx diff --git a/Source/Starfish.Client/Properties/Resources.zh-Hant.resx b/Source/Starfish.Client/Properties/Resources.zh-Hant.resx new file mode 100644 index 0000000..3c47deb --- /dev/null +++ b/Source/Starfish.Client/Properties/Resources.zh-Hant.resx @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 沒有在Starfish找到App配置項目。 + + + 沒有在Starfish找到Host配置項目。 + + + 不支援協定{0}。 + + + 沒有找到Starfish配置項。 + + \ No newline at end of file diff --git a/Source/Starfish.Webapp/Properties/Resources.resx b/Source/Starfish.Webapp/Properties/Resources.resx index af6a346..f5d0b22 100644 --- a/Source/Starfish.Webapp/Properties/Resources.resx +++ b/Source/Starfish.Webapp/Properties/Resources.resx @@ -166,7 +166,7 @@ Detail - setting + Setting Detail diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From 4e245bf5d441492056549b7f0b58dec232321ff0 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 13:01:45 +0800 Subject: [PATCH 02/10] =?UTF-8?q?Id=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAlon?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Starfish.Service/Domain/Aggregates/AppInfo.cs | 6 +++--- Source/Starfish.Service/Domain/Aggregates/Team.cs | 10 +++++----- .../Starfish.Service/Domain/Aggregates/TeamMember.cs | 10 +++++----- Source/Starfish.Service/Domain/Aggregates/Token.cs | 2 +- Source/Starfish.Service/Domain/Aggregates/User.cs | 9 +++++++-- Source/Starfish.Service/Domain/Aggregates/UserRole.cs | 4 ++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs b/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs index 4fdc5c9..ec92dd8 100644 --- a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs +++ b/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs @@ -20,7 +20,7 @@ private AppInfo() { } - private AppInfo(int teamId) + private AppInfo(long teamId) : this() { TeamId = teamId; @@ -29,7 +29,7 @@ private AppInfo(int teamId) /// /// 团队Id /// - public int TeamId { get; set; } + public long TeamId { get; set; } /// /// 名称 @@ -73,7 +73,7 @@ private AppInfo(int teamId) /// /// /// - internal static AppInfo Create(int teamId, string name, string code) + internal static AppInfo Create(long teamId, string name, string code) { var entity = new AppInfo(teamId); entity.SetCode(code); diff --git a/Source/Starfish.Service/Domain/Aggregates/Team.cs b/Source/Starfish.Service/Domain/Aggregates/Team.cs index 4f09bd3..06cff70 100644 --- a/Source/Starfish.Service/Domain/Aggregates/Team.cs +++ b/Source/Starfish.Service/Domain/Aggregates/Team.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 团队聚合根对象 /// -public sealed class Team : Aggregate, +public sealed class Team : Aggregate, IAuditing { public string Alias { get; set; } @@ -15,7 +15,7 @@ public sealed class Team : Aggregate, public string Description { get; set; } - public int OwnerId { get; set; } + public long OwnerId { get; set; } public int MemberCount { get; set; } @@ -29,7 +29,7 @@ public sealed class Team : Aggregate, public HashSet Members { get; set; } - internal static Team Create(string name, string description, int ownerId) + internal static Team Create(string name, string description, long ownerId) { var team = new Team { @@ -72,7 +72,7 @@ internal void SetDescription(string description) Description = description; } - internal void AddMember(int userId) + internal void AddMember(long userId) { Members ??= []; @@ -86,7 +86,7 @@ internal void AddMember(int userId) MemberCount++; } - internal void RemoveMember(int userId) + internal void RemoveMember(long userId) { if (Members == null || Members.All(t => t.UserId != userId)) { diff --git a/Source/Starfish.Service/Domain/Aggregates/TeamMember.cs b/Source/Starfish.Service/Domain/Aggregates/TeamMember.cs index ea07b0d..4a689e4 100644 --- a/Source/Starfish.Service/Domain/Aggregates/TeamMember.cs +++ b/Source/Starfish.Service/Domain/Aggregates/TeamMember.cs @@ -5,21 +5,21 @@ namespace Nerosoft.Starfish.Domain; /// /// 团队成员实体 /// -public sealed class TeamMember : Entity, IHasCreateTime +public sealed class TeamMember : Entity, IHasCreateTime { private TeamMember() { } - private TeamMember(int userId) + private TeamMember(long userId) : this() { UserId = userId; } - public int UserId { get; set; } + public long UserId { get; set; } - public int TeamId { get; set; } + public long TeamId { get; set; } public DateTime CreateTime { get; set; } @@ -27,7 +27,7 @@ private TeamMember(int userId) public Team Team { get; set; } - internal static TeamMember Create(int userId) + internal static TeamMember Create(long userId) { return new TeamMember(userId); } diff --git a/Source/Starfish.Service/Domain/Aggregates/Token.cs b/Source/Starfish.Service/Domain/Aggregates/Token.cs index b73741b..80ec73c 100644 --- a/Source/Starfish.Service/Domain/Aggregates/Token.cs +++ b/Source/Starfish.Service/Domain/Aggregates/Token.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 令牌 /// -public class Token : Entity +public class Token : Entity { /// /// 初始化实例。 diff --git a/Source/Starfish.Service/Domain/Aggregates/User.cs b/Source/Starfish.Service/Domain/Aggregates/User.cs index d6289df..c35c38b 100644 --- a/Source/Starfish.Service/Domain/Aggregates/User.cs +++ b/Source/Starfish.Service/Domain/Aggregates/User.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 用户聚合根 /// -public sealed class User : Aggregate, IHasCreateTime, IHasUpdateTime, ITombstone +public sealed class User : Aggregate, IHasCreateTime, IHasUpdateTime, ITombstone { /// /// 初始化实例 @@ -17,7 +17,7 @@ public sealed class User : Aggregate, IHasCreateTime, IHasUpdateTime, ITomb private User() { } - + /// /// 初始化用户聚合根 /// @@ -78,6 +78,11 @@ private User(string userName, string passwordHash, string passwordSalt) /// 预留账号不允许删除、设置角色等 public bool Reserved { get; set; } + /// + /// 来源 + /// + public int Source { get; set; } + /// /// 创建时间 /// diff --git a/Source/Starfish.Service/Domain/Aggregates/UserRole.cs b/Source/Starfish.Service/Domain/Aggregates/UserRole.cs index b12e645..b3b71ce 100644 --- a/Source/Starfish.Service/Domain/Aggregates/UserRole.cs +++ b/Source/Starfish.Service/Domain/Aggregates/UserRole.cs @@ -5,7 +5,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 用户角色 /// -public class UserRole : Entity +public class UserRole : Entity { private UserRole() { @@ -20,7 +20,7 @@ private UserRole(string name) /// /// 用户Id /// - public int UserId { get; set; } + public long UserId { get; set; } /// /// 角色名称 From 0c8362c6471c253744136ce349d313f2c9f046e4 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 13:06:07 +0800 Subject: [PATCH 03/10] =?UTF-8?q?Id=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAlon?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/Business/AppInfoGeneralBusiness.cs | 8 ++++---- .../Domain/Business/AppInfoSecretBusiness.cs | 2 +- .../Domain/Business/AppInfoStatusBusiness.cs | 2 +- .../Domain/Business/TeamGeneralBusiness.cs | 10 +++++----- .../Domain/Business/TeamMemberBusiness.cs | 8 ++++---- .../Domain/Business/UserGeneralBusiness.cs | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs index 7558fa8..b570538 100644 --- a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs @@ -18,7 +18,7 @@ public class AppInfoGeneralBusiness : EditableObjectBase internal AppInfo Aggregate { get; private set; } public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id); - public static readonly PropertyInfo TeamIdProperty = RegisterProperty(p => p.TeamId); + public static readonly PropertyInfo TeamIdProperty = RegisterProperty(p => p.TeamId); public static readonly PropertyInfo NameProperty = RegisterProperty(p => p.Name); public static readonly PropertyInfo CodeProperty = RegisterProperty(p => p.Code); public static readonly PropertyInfo SecretProperty = RegisterProperty(p => p.Secret); @@ -30,7 +30,7 @@ public long Id set => LoadProperty(IdProperty, value); } - public int TeamId + public long TeamId { get => GetProperty(TeamIdProperty); set => SetProperty(TeamIdProperty, value); @@ -73,7 +73,7 @@ protected override Task CreateAsync(CancellationToken cancellationToken = defaul } [FactoryFetch] - protected async Task FetchAsync(int id, CancellationToken cancellationToken = default) + protected async Task FetchAsync(long id, CancellationToken cancellationToken = default) { var aggregate = await AppInfoRepository.GetAsync(id, true, [], cancellationToken); @@ -148,7 +148,7 @@ public override async Task ExecuteAsync(IRuleContext context, CancellationToken } var team = await target.TeamRepository.GetAsync(target.TeamId, false, cancellationToken); - if (team.OwnerId != target.Identity.GetUserIdOfInt32()) + if (team.OwnerId != target.Identity.GetUserIdOfInt64()) { context.AddErrorResult(Resources.IDS_ERROR_TEAM_ONLY_ALLOW_OWNER_CHANGE_MEMBER); } diff --git a/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs index a312429..1bca7e3 100644 --- a/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs @@ -25,7 +25,7 @@ protected async Task ExecuteAsync(long id, string secret, CancellationToken canc } var team = await TeamRepository.GetAsync(aggregate.TeamId, false, cancellationToken); - if (team.OwnerId != Identity.GetUserIdOfInt32()) + if (team.OwnerId != Identity.GetUserIdOfInt64()) { throw new UnauthorizedAccessException(Resources.IDS_ERROR_TEAM_ONLY_ALLOW_OWNER_CHANGE_MEMBER); } diff --git a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs index 798eafc..396e5ce 100644 --- a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs @@ -25,7 +25,7 @@ protected async Task ExecuteAsync(long id, AppStatus status, CancellationToken c } var team = await TeamRepository.GetAsync(aggregate.TeamId, false, cancellationToken); - if (team.OwnerId != Identity.GetUserIdOfInt32()) + if (team.OwnerId != Identity.GetUserIdOfInt64()) { throw new UnauthorizedAccessException(Resources.IDS_ERROR_TEAM_ONLY_ALLOW_OWNER_CHANGE_MEMBER); } diff --git a/Source/Starfish.Service/Domain/Business/TeamGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/TeamGeneralBusiness.cs index 5dd8fd3..b61e433 100644 --- a/Source/Starfish.Service/Domain/Business/TeamGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/TeamGeneralBusiness.cs @@ -13,12 +13,12 @@ public class TeamGeneralBusiness : EditableObjectBase, IDom private Team Aggregate { get; set; } - public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id); + public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id); public static readonly PropertyInfo NameProperty = RegisterProperty(p => p.Name); public static readonly PropertyInfo AliasProperty = RegisterProperty(p => p.Alias); public static readonly PropertyInfo DescriptionProperty = RegisterProperty(p => p.Description); - public int Id + public long Id { get => GetProperty(IdProperty); private set => LoadProperty(IdProperty, value); @@ -54,7 +54,7 @@ protected override Task CreateAsync(CancellationToken cancellationToken = defaul } [FactoryFetch] - protected async Task FetchAsync(int id, CancellationToken cancellationToken = default) + protected async Task FetchAsync(long id, CancellationToken cancellationToken = default) { var aggregate = await TeamRepository.GetAsync(id, true, [], cancellationToken); @@ -72,7 +72,7 @@ protected async Task FetchAsync(int id, CancellationToken cancellationToken = de [FactoryInsert] protected override Task InsertAsync(CancellationToken cancellationToken = default) { - var team = Team.Create(Name, Description, Identity.GetUserIdOfInt32()); + var team = Team.Create(Name, Description, Identity.GetUserIdOfInt64()); if (!string.IsNullOrWhiteSpace(Alias)) { team.SetAlias(Alias); @@ -115,7 +115,7 @@ public override Task ExecuteAsync(IRuleContext context, CancellationToken cancel if (!target.IsInsert) { - if (target.Aggregate.OwnerId != target.Identity.GetUserIdOfInt32()) + if (target.Aggregate.OwnerId != target.Identity.GetUserIdOfInt64()) { context.AddErrorResult(Resources.IDS_ERROR_TEAM_ONLY_ALLOW_OWNER_UPDATE); } diff --git a/Source/Starfish.Service/Domain/Business/TeamMemberBusiness.cs b/Source/Starfish.Service/Domain/Business/TeamMemberBusiness.cs index 626692c..1ce1019 100644 --- a/Source/Starfish.Service/Domain/Business/TeamMemberBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/TeamMemberBusiness.cs @@ -16,9 +16,9 @@ public class TeamMemberBusiness : EditableObjectBase private Team Aggregate { get; set; } - public static readonly PropertyInfo UserIdsProperty = RegisterProperty(p => p.UserIds); + public static readonly PropertyInfo UserIdsProperty = RegisterProperty(p => p.UserIds); - public int[] UserIds + public long[] UserIds { get => GetProperty(UserIdsProperty); set => SetProperty(UserIdsProperty, value); @@ -31,7 +31,7 @@ protected override void AddRules() } [FactoryFetch] - protected async Task FetchAsync(int id, CancellationToken cancellationToken = default) + protected async Task FetchAsync(long id, CancellationToken cancellationToken = default) { var aggregate = await TeamRepository.GetAsync(id, true, [nameof(Team.Members)], cancellationToken); @@ -87,7 +87,7 @@ public override Task ExecuteAsync(IRuleContext context, CancellationToken cancel { var target = (TeamMemberBusiness)context.Target; - if (target.Aggregate.OwnerId != target.Identity.GetUserIdOfInt32()) + if (target.Aggregate.OwnerId != target.Identity.GetUserIdOfInt64()) { context.AddErrorResult(Resources.IDS_ERROR_TEAM_ONLY_ALLOW_OWNER_CHANGE_MEMBER); } diff --git a/Source/Starfish.Service/Domain/Business/UserGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/UserGeneralBusiness.cs index 9939d2e..4bdd1e8 100644 --- a/Source/Starfish.Service/Domain/Business/UserGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/UserGeneralBusiness.cs @@ -22,7 +22,7 @@ public UserGeneralBusiness(IServiceProvider provider) private User Aggregate { get; set; } - public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id); + public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id); public static readonly PropertyInfo UserNameProperty = RegisterProperty(p => p.UserName); public static readonly PropertyInfo PasswordProperty = RegisterProperty(p => p.Password); public static readonly PropertyInfo NickNameProperty = RegisterProperty(p => p.NickName); @@ -30,7 +30,7 @@ public UserGeneralBusiness(IServiceProvider provider) public static readonly PropertyInfo PhoneProperty = RegisterProperty(p => p.Phone); public static readonly PropertyInfo> RolesProperty = RegisterProperty>(p => p.Roles); - public int Id + public long Id { get => GetProperty(IdProperty); private set => LoadProperty(IdProperty, value); @@ -87,7 +87,7 @@ protected override Task CreateAsync(CancellationToken cancellationToken = defaul } [FactoryFetch] - protected async Task FetchAsync(int id, CancellationToken cancellationToken = default) + protected async Task FetchAsync(long id, CancellationToken cancellationToken = default) { var user = await Repository.GetAsync(id, query => query.AsTracking().Include(nameof(User.Roles)), cancellationToken); From 49f1e30f8b589cf5be8cb6e81923a01d70042bd6 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 13:06:18 +0800 Subject: [PATCH 04/10] =?UTF-8?q?Id=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAlon?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Starfish.Service/Domain/Exceptions/TeamNotFoundException.cs | 2 +- .../Starfish.Service/Domain/Exceptions/UserNotFoundException.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Starfish.Service/Domain/Exceptions/TeamNotFoundException.cs b/Source/Starfish.Service/Domain/Exceptions/TeamNotFoundException.cs index 536be5c..712a71e 100644 --- a/Source/Starfish.Service/Domain/Exceptions/TeamNotFoundException.cs +++ b/Source/Starfish.Service/Domain/Exceptions/TeamNotFoundException.cs @@ -2,7 +2,7 @@ public class TeamNotFoundException : NotFoundException { - public TeamNotFoundException(int id) + public TeamNotFoundException(long id) : base(string.Format(Resources.IDS_ERROR_TEAM_NOT_EXISTS, id)) { } diff --git a/Source/Starfish.Service/Domain/Exceptions/UserNotFoundException.cs b/Source/Starfish.Service/Domain/Exceptions/UserNotFoundException.cs index e93b63b..812baf5 100644 --- a/Source/Starfish.Service/Domain/Exceptions/UserNotFoundException.cs +++ b/Source/Starfish.Service/Domain/Exceptions/UserNotFoundException.cs @@ -9,7 +9,7 @@ public class UserNotFoundException : NotFoundException /// 初始化实例。 /// /// - public UserNotFoundException(int id) + public UserNotFoundException(long id) : base(string.Format(Resources.IDS_ERROR_USER_NOT_EXISTS, id)) { } From 434c02c32fd02d7504e828d0e8bdafc6c2d3ce3d Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 13:07:49 +0800 Subject: [PATCH 05/10] =?UTF-8?q?Id=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAlon?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Starfish.Service/Domain/Repositories/ITeamRepository.cs | 6 +++--- .../Domain/Repositories/ITokenRepository.cs | 2 +- .../Starfish.Service/Domain/Repositories/IUserRepository.cs | 6 +++--- .../Repository/Repositories/TeamRepository.cs | 6 +++--- .../Repository/Repositories/TokenRepository.cs | 2 +- .../Repository/Repositories/UserRepository.cs | 6 +++--- .../Repository/Specifications/TeamSpecification.cs | 4 ++-- .../Repository/Specifications/UserSpecification.cs | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs b/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs index 92add5a..915678b 100644 --- a/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs +++ b/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs @@ -3,7 +3,7 @@ namespace Nerosoft.Starfish.Domain; -public interface ITeamRepository : IBaseRepository +public interface ITeamRepository : IBaseRepository { /// /// 查询指定用户所属团队 @@ -11,7 +11,7 @@ public interface ITeamRepository : IBaseRepository /// /// /// - Task> GetTeamsOfUserAsync(int userId, CancellationToken cancellationToken = default); + Task> GetTeamsOfUserAsync(long userId, CancellationToken cancellationToken = default); - Task> GetMembersAsync(int id, CancellationToken cancellationToken = default); + Task> GetMembersAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/ITokenRepository.cs b/Source/Starfish.Service/Domain/Repositories/ITokenRepository.cs index fd52f36..f9e19c2 100644 --- a/Source/Starfish.Service/Domain/Repositories/ITokenRepository.cs +++ b/Source/Starfish.Service/Domain/Repositories/ITokenRepository.cs @@ -6,6 +6,6 @@ namespace Nerosoft.Starfish.Domain; /// /// 令牌仓储接口 /// -public interface ITokenRepository : IBaseRepository +public interface ITokenRepository : IBaseRepository { } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/IUserRepository.cs b/Source/Starfish.Service/Domain/Repositories/IUserRepository.cs index 60d3953..3046704 100644 --- a/Source/Starfish.Service/Domain/Repositories/IUserRepository.cs +++ b/Source/Starfish.Service/Domain/Repositories/IUserRepository.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 用户仓储接口 /// -public interface IUserRepository : IBaseRepository +public interface IUserRepository : IBaseRepository { /// /// 根据用户名查询用户 @@ -32,7 +32,7 @@ public interface IUserRepository : IBaseRepository /// /// /// - Task CheckEmailExistsAsync(string email, int ignoreId, CancellationToken cancellationToken = default); + Task CheckEmailExistsAsync(string email, long ignoreId, CancellationToken cancellationToken = default); /// /// 检查手机号是否存在 @@ -41,5 +41,5 @@ public interface IUserRepository : IBaseRepository /// /// /// - Task CheckPhoneExistsAsync(string phone, int ignoreId, CancellationToken cancellationToken = default); + Task CheckPhoneExistsAsync(string phone, long ignoreId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs b/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs index d53eede..a5740d6 100644 --- a/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs +++ b/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs @@ -5,14 +5,14 @@ namespace Nerosoft.Starfish.Repository; -public class TeamRepository : BaseRepository, ITeamRepository +public class TeamRepository : BaseRepository, ITeamRepository { public TeamRepository(IContextProvider provider) : base(provider) { } - public Task> GetTeamsOfUserAsync(int userId, CancellationToken cancellationToken = default) + public Task> GetTeamsOfUserAsync(long userId, CancellationToken cancellationToken = default) { var memberSet = Context.Set(); var teamSet = Context.Set(); @@ -23,7 +23,7 @@ join member in memberSet on team.Id equals member.TeamId return query.ToListAsync(cancellationToken); } - public Task> GetMembersAsync(int id, CancellationToken cancellationToken = default) + public Task> GetMembersAsync(long id, CancellationToken cancellationToken = default) { var query = Context.Set() .Include(t => t.User) diff --git a/Source/Starfish.Service/Repository/Repositories/TokenRepository.cs b/Source/Starfish.Service/Repository/Repositories/TokenRepository.cs index ca8dc89..9f40883 100644 --- a/Source/Starfish.Service/Repository/Repositories/TokenRepository.cs +++ b/Source/Starfish.Service/Repository/Repositories/TokenRepository.cs @@ -7,7 +7,7 @@ namespace Nerosoft.Starfish.Repository; /// /// 令牌仓储 /// -public class TokenRepository : BaseRepository, ITokenRepository +public class TokenRepository : BaseRepository, ITokenRepository { /// /// 初始化 diff --git a/Source/Starfish.Service/Repository/Repositories/UserRepository.cs b/Source/Starfish.Service/Repository/Repositories/UserRepository.cs index 56cb227..1776344 100644 --- a/Source/Starfish.Service/Repository/Repositories/UserRepository.cs +++ b/Source/Starfish.Service/Repository/Repositories/UserRepository.cs @@ -8,7 +8,7 @@ namespace Nerosoft.Starfish.Repository; /// /// 用户仓储 /// -public sealed class UserRepository : BaseRepository, IUserRepository +public sealed class UserRepository : BaseRepository, IUserRepository { /// /// 初始化. @@ -34,7 +34,7 @@ public Task CheckUserNameExistsAsync(string userName, CancellationToken ca } /// - public Task CheckEmailExistsAsync(string email, int ignoreId, CancellationToken cancellationToken = default) + public Task CheckEmailExistsAsync(string email, long ignoreId, CancellationToken cancellationToken = default) { ISpecification[] specifications = [ @@ -45,7 +45,7 @@ public Task CheckEmailExistsAsync(string email, int ignoreId, Cancellation return AnyAsync(predicate, null, cancellationToken); } - public Task CheckPhoneExistsAsync(string phone, int ignoreId, CancellationToken cancellationToken = default) + public Task CheckPhoneExistsAsync(string phone, long ignoreId, CancellationToken cancellationToken = default) { ISpecification[] specifications = [ diff --git a/Source/Starfish.Service/Repository/Specifications/TeamSpecification.cs b/Source/Starfish.Service/Repository/Specifications/TeamSpecification.cs index 268be5f..abe3985 100644 --- a/Source/Starfish.Service/Repository/Specifications/TeamSpecification.cs +++ b/Source/Starfish.Service/Repository/Specifications/TeamSpecification.cs @@ -5,7 +5,7 @@ namespace Nerosoft.Starfish.Repository; internal static class TeamSpecification { - public static Specification IdEquals(int id) + public static Specification IdEquals(long id) { return new DirectSpecification(t => t.Id == id); } @@ -45,7 +45,7 @@ public static Specification Matches(string keyword) return new CompositeSpecification(PredicateOperator.OrElse, specifications); } - public static Specification HasMember(int userId) + public static Specification HasMember(long userId) { return new DirectSpecification(t => t.Members.Any(m => m.UserId == userId)); } diff --git a/Source/Starfish.Service/Repository/Specifications/UserSpecification.cs b/Source/Starfish.Service/Repository/Specifications/UserSpecification.cs index 90593a9..2b115da 100644 --- a/Source/Starfish.Service/Repository/Specifications/UserSpecification.cs +++ b/Source/Starfish.Service/Repository/Specifications/UserSpecification.cs @@ -13,7 +13,7 @@ public static class UserSpecification /// /// /// - public static Specification IdEquals(int id) + public static Specification IdEquals(long id) { return new DirectSpecification(t => t.Id == id); } @@ -23,7 +23,7 @@ public static Specification IdEquals(int id) /// /// /// - public static Specification IdNotEquals(int id) + public static Specification IdNotEquals(long id) { return new DirectSpecification(t => t.Id != id); } From c64525927c3c8dfc520a45b8d5154b2ac6bf7046 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 13:09:15 +0800 Subject: [PATCH 06/10] =?UTF-8?q?Id=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAlon?= =?UTF-8?q?g.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Identity/ChangePasswordCommand.cs | 4 +- .../Commands/Identity/UserDeleteCommand.cs | 4 +- .../Commands/Identity/UserRoleSetCommand.cs | 4 +- .../Commands/Identity/UserUpdateCommand.cs | 4 +- .../Commands/Team/TeamMemberEditCommand.cs | 6 +- .../Commands/Team/TeamUpdateCommand.cs | 4 +- .../Contracts/ITeamApplicationService.cs | 14 +- .../Contracts/IUserApplicationService.cs | 12 +- .../Events/UserAuthSucceedEvent.cs | 4 +- .../Handlers/AppInfoCommandHandler.cs | 6 +- .../Implements/TeamApplicationService.cs | 16 +- .../Implements/UserApplicationService.cs | 12 +- .../Contexts/InMemoryModelBuilder.cs | 193 +++++++++++++++++- .../Repository/Contexts/MssqlModelBuilder.cs | 189 ++++++++++++++++- .../Repository/Contexts/MysqlModelBuilder.cs | 189 ++++++++++++++++- .../Repository/Contexts/PgsqlModelBuilder.cs | 183 +++++++++++++++++ .../Repository/Contexts/SqliteModelBuilder.cs | 28 +++ .../UseCases/Apps/AppInfoCountUseCase.cs | 2 +- .../UseCases/Apps/AppInfoDetailUseCase.cs | 2 +- .../UseCases/Apps/AppInfoQueryUseCase.cs | 2 +- .../UseCases/Apps/AppInfoUpdateUseCase.cs | 7 +- .../Apps/ChangeAppInfoStatusUseCase.cs | 10 - .../Identity/ChangePasswordUseCase.cs | 2 +- .../Identity/IdentityCommonComponent.cs | 2 +- .../Identity/IdentityUseCaseOutput.cs | 2 +- .../UseCases/Identity/ResetPasswordUseCase.cs | 2 +- .../UseCases/Identity/UserCreateUseCase.cs | 4 +- .../UseCases/Identity/UserDeleteUseCase.cs | 2 +- .../UseCases/Identity/UserDetailUseCase.cs | 2 +- .../UseCases/Identity/UserSetRoleUseCase.cs | 2 +- .../UseCases/Identity/UserUpdateUseCase.cs | 2 +- .../UseCases/Team/TeamCountUseCase.cs | 2 +- .../UseCases/Team/TeamCreateUseCase.cs | 4 +- .../UseCases/Team/TeamDetailUseCase.cs | 4 +- .../UseCases/Team/TeamMemberAppendUseCase.cs | 2 +- .../UseCases/Team/TeamMemberQueryUseCase.cs | 2 +- .../UseCases/Team/TeamMemberQuitUseCase.cs | 2 +- .../UseCases/Team/TeamMemberRemoveUseCase.cs | 2 +- .../UseCases/Team/TeamQueryUseCase.cs | 3 +- .../UseCases/Team/TeamUpdateUseCase.cs | 2 +- .../Starfish.Transit/Apps/AppInfoCreateDto.cs | 2 +- .../Starfish.Transit/Apps/AppInfoDetailDto.cs | 5 + .../Identity/UserDetailDto.cs | 2 +- .../Starfish.Transit/Identity/UserItemDto.cs | 2 +- Source/Starfish.Transit/Team/TeamDetailDto.cs | 4 +- Source/Starfish.Transit/Team/TeamItemDto.cs | 4 +- Source/Starfish.Transit/Team/TeamMemberDto.cs | 2 +- .../Controllers/TeamController.cs | 24 +-- .../Controllers/UserController.cs | 20 +- .../Pages/Team/AppendMember.razor | 6 +- .../Starfish.Webapp/Pages/Team/Detail.razor | 12 +- Source/Starfish.Webapp/Pages/Team/Edit.razor | 6 +- Source/Starfish.Webapp/Pages/Team/Index.razor | 6 +- .../Starfish.Webapp/Pages/User/Detail.razor | 4 +- Source/Starfish.Webapp/Pages/User/Edit.razor | 6 +- Source/Starfish.Webapp/Pages/User/Index.razor | 6 +- .../Pages/User/ResetPassword.razor | 4 +- .../Starfish.Webapp/Rest/Defines/ITeamApi.cs | 12 +- .../Starfish.Webapp/Rest/Defines/IUserApi.cs | 8 +- 59 files changed, 911 insertions(+), 162 deletions(-) diff --git a/Source/Starfish.Service/Application/Commands/Identity/ChangePasswordCommand.cs b/Source/Starfish.Service/Application/Commands/Identity/ChangePasswordCommand.cs index a2a981b..d61d8be 100644 --- a/Source/Starfish.Service/Application/Commands/Identity/ChangePasswordCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Identity/ChangePasswordCommand.cs @@ -11,7 +11,7 @@ public ChangePasswordCommand() { } - public ChangePasswordCommand(int userId, string password) + public ChangePasswordCommand(long userId, string password) : this() { UserId = userId; @@ -21,7 +21,7 @@ public ChangePasswordCommand(int userId, string password) /// /// 用户Id /// - public int UserId { get; set; } + public long UserId { get; set; } /// /// 新密码 diff --git a/Source/Starfish.Service/Application/Commands/Identity/UserDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Identity/UserDeleteCommand.cs index 101ff35..3d57bcf 100644 --- a/Source/Starfish.Service/Application/Commands/Identity/UserDeleteCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Identity/UserDeleteCommand.cs @@ -5,13 +5,13 @@ namespace Nerosoft.Starfish.Application; /// /// 用户删除命令 /// -public sealed class UserDeleteCommand : Command +public sealed class UserDeleteCommand : Command { /// /// 初始化实例。 /// /// - public UserDeleteCommand(int userId) + public UserDeleteCommand(long userId) : base(userId) { } diff --git a/Source/Starfish.Service/Application/Commands/Identity/UserRoleSetCommand.cs b/Source/Starfish.Service/Application/Commands/Identity/UserRoleSetCommand.cs index cb33507..0341177 100644 --- a/Source/Starfish.Service/Application/Commands/Identity/UserRoleSetCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Identity/UserRoleSetCommand.cs @@ -2,9 +2,9 @@ namespace Nerosoft.Starfish.Application; -public class UserRoleSetCommand : Command> +public class UserRoleSetCommand : Command> { - public UserRoleSetCommand(int id, List roles) + public UserRoleSetCommand(long id, List roles) : base(id, roles) { } diff --git a/Source/Starfish.Service/Application/Commands/Identity/UserUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Identity/UserUpdateCommand.cs index 108b44e..3be9ed9 100644 --- a/Source/Starfish.Service/Application/Commands/Identity/UserUpdateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Identity/UserUpdateCommand.cs @@ -6,9 +6,9 @@ namespace Nerosoft.Starfish.Application; /// /// 用户更新命令 /// -public sealed class UserUpdateCommand : Command +public sealed class UserUpdateCommand : Command { - public UserUpdateCommand(int userId, UserUpdateDto data) + public UserUpdateCommand(long userId, UserUpdateDto data) : base(userId, data) { } diff --git a/Source/Starfish.Service/Application/Commands/Team/TeamMemberEditCommand.cs b/Source/Starfish.Service/Application/Commands/Team/TeamMemberEditCommand.cs index 42dbf11..7e94bff 100644 --- a/Source/Starfish.Service/Application/Commands/Team/TeamMemberEditCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Team/TeamMemberEditCommand.cs @@ -4,16 +4,16 @@ namespace Nerosoft.Starfish.Application; public class TeamMemberEditCommand : Command { - public TeamMemberEditCommand(int teamId, List userIds, string type) + public TeamMemberEditCommand(long teamId, List userIds, string type) { TeamId = teamId; UserIds = userIds; Type = type; } - public int TeamId { get; set; } + public long TeamId { get; set; } - public List UserIds { get; set; } + public List UserIds { get; set; } public string Type { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Commands/Team/TeamUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Team/TeamUpdateCommand.cs index fa583ae..ea79d99 100644 --- a/Source/Starfish.Service/Application/Commands/Team/TeamUpdateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Team/TeamUpdateCommand.cs @@ -5,13 +5,13 @@ namespace Nerosoft.Starfish.Application; public class TeamUpdateCommand : Command { - public TeamUpdateCommand(int id, TeamEditDto data) + public TeamUpdateCommand(long id, TeamEditDto data) { Id = id; Data = data; } - public int Id { get; set; } + public long Id { get; set; } public TeamEditDto Data { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Contracts/ITeamApplicationService.cs b/Source/Starfish.Service/Application/Contracts/ITeamApplicationService.cs index 2b68004..4e594c4 100644 --- a/Source/Starfish.Service/Application/Contracts/ITeamApplicationService.cs +++ b/Source/Starfish.Service/Application/Contracts/ITeamApplicationService.cs @@ -9,17 +9,17 @@ public interface ITeamApplicationService : IApplicationService Task CountAsync(TeamCriteria criteria, CancellationToken cancellationToken = default); - Task GetAsync(int id, CancellationToken cancellationToken = default); + Task GetAsync(long id, CancellationToken cancellationToken = default); - Task CreateAsync(TeamEditDto data, CancellationToken cancellationToken = default); + Task CreateAsync(TeamEditDto data, CancellationToken cancellationToken = default); - Task UpdateAsync(int id, TeamEditDto data, CancellationToken cancellationToken = default); + Task UpdateAsync(long id, TeamEditDto data, CancellationToken cancellationToken = default); - Task> QueryMembersAsync(int id, CancellationToken cancellationToken = default); + Task> QueryMembersAsync(long id, CancellationToken cancellationToken = default); - Task AppendMembersAsync(int id, List userIds, CancellationToken cancellationToken = default); + Task AppendMembersAsync(long id, List userIds, CancellationToken cancellationToken = default); - Task RemoveMembersAsync(int id, List userIds, CancellationToken cancellationToken = default); + Task RemoveMembersAsync(long id, List userIds, CancellationToken cancellationToken = default); - Task QuitAsync(int id, CancellationToken cancellationToken = default); + Task QuitAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Contracts/IUserApplicationService.cs b/Source/Starfish.Service/Application/Contracts/IUserApplicationService.cs index 27ff1b8..7cb317b 100644 --- a/Source/Starfish.Service/Application/Contracts/IUserApplicationService.cs +++ b/Source/Starfish.Service/Application/Contracts/IUserApplicationService.cs @@ -14,7 +14,7 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task CreateAsync(UserCreateDto data, CancellationToken cancellationToken = default); + Task CreateAsync(UserCreateDto data, CancellationToken cancellationToken = default); /// /// 编辑用户 @@ -23,7 +23,7 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task UpdateAsync(int id, UserUpdateDto data, CancellationToken cancellationToken = default); + Task UpdateAsync(long id, UserUpdateDto data, CancellationToken cancellationToken = default); /// /// 查询符合条件的用户列表 @@ -49,7 +49,7 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task GetAsync(int id, CancellationToken cancellationToken = default); + Task GetAsync(long id, CancellationToken cancellationToken = default); /// /// 删除用户 @@ -57,7 +57,7 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task DeleteAsync(int id, CancellationToken cancellationToken = default); + Task DeleteAsync(long id, CancellationToken cancellationToken = default); /// /// 设置用户角色 @@ -66,7 +66,7 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task SetRolesAsync(int id, List roles, CancellationToken cancellationToken = default); + Task SetRolesAsync(long id, List roles, CancellationToken cancellationToken = default); /// /// 修改密码 @@ -84,5 +84,5 @@ public interface IUserApplicationService : IApplicationService /// /// /// - Task ResetPasswordAsync(int id, string password, CancellationToken cancellationToken = default); + Task ResetPasswordAsync(long id, string password, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Events/UserAuthSucceedEvent.cs b/Source/Starfish.Service/Application/Events/UserAuthSucceedEvent.cs index fa001db..bb66a66 100644 --- a/Source/Starfish.Service/Application/Events/UserAuthSucceedEvent.cs +++ b/Source/Starfish.Service/Application/Events/UserAuthSucceedEvent.cs @@ -20,7 +20,7 @@ public UserAuthSucceedEvent() /// /// /// - public UserAuthSucceedEvent(string authType, Dictionary data, int userId) + public UserAuthSucceedEvent(string authType, Dictionary data, long userId) { AuthType = authType; Data = data; @@ -40,7 +40,7 @@ public UserAuthSucceedEvent(string authType, Dictionary data, in /// /// 用户Id /// - public int UserId { get; set; } + public long UserId { get; set; } /// /// 用户名 diff --git a/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs b/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs index 1a13369..32a3835 100644 --- a/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs +++ b/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs @@ -16,18 +16,14 @@ public class AppInfoCommandHandler : CommandHandlerBase, IHandler, IHandler { - private readonly IAppInfoRepository _repository; - /// /// 构造函数 /// /// /// - /// - public AppInfoCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory, IAppInfoRepository repository) + public AppInfoCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory) : base(unitOfWork, factory) { - _repository = repository; } /// diff --git a/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs b/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs index dd0d365..17f778d 100644 --- a/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs @@ -22,7 +22,7 @@ public Task CountAsync(TeamCriteria criteria, CancellationToken cancellatio .ContinueWith(task => task.Result.Result, cancellationToken); } - public Task GetAsync(int id, CancellationToken cancellationToken = default) + public Task GetAsync(long id, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamDetailInput(id); @@ -30,7 +30,7 @@ public Task GetAsync(int id, CancellationToken cancellationToken .ContinueWith(task => task.Result.Result, cancellationToken); } - public Task CreateAsync(TeamEditDto data, CancellationToken cancellationToken = default) + public Task CreateAsync(TeamEditDto data, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamCreateInput(data); @@ -38,14 +38,14 @@ public Task CreateAsync(TeamEditDto data, CancellationToken cancellationTok .ContinueWith(task => task.Result.Result, cancellationToken); } - public Task UpdateAsync(int id, TeamEditDto data, CancellationToken cancellationToken = default) + public Task UpdateAsync(long id, TeamEditDto data, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamUpdateInput(id, data); return useCase.ExecuteAsync(input, cancellationToken); } - public Task> QueryMembersAsync(int id, CancellationToken cancellationToken = default) + public Task> QueryMembersAsync(long id, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamMemberQueryInput(id); @@ -53,24 +53,24 @@ public Task> QueryMembersAsync(int id, CancellationToken can .ContinueWith(task => task.Result.Result, cancellationToken); } - public Task AppendMembersAsync(int id, List userIds, CancellationToken cancellationToken = default) + public Task AppendMembersAsync(long id, List userIds, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamMemberAppendInput(id, userIds); return useCase.ExecuteAsync(input, cancellationToken); } - public Task RemoveMembersAsync(int id, List userIds, CancellationToken cancellationToken = default) + public Task RemoveMembersAsync(long id, List userIds, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new TeamMemberRemoveInput(id, userIds); return useCase.ExecuteAsync(input, cancellationToken); } - public Task QuitAsync(int id, CancellationToken cancellationToken = default) + public Task QuitAsync(long id, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); - var input = new TeamMemberQuitInput(id, User.GetUserIdOfInt32()); + var input = new TeamMemberQuitInput(id, User.GetUserIdOfInt64()); return useCase.ExecuteAsync(input, cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Implements/UserApplicationService.cs b/Source/Starfish.Service/Application/Implements/UserApplicationService.cs index 58f0bf8..55e0841 100644 --- a/Source/Starfish.Service/Application/Implements/UserApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/UserApplicationService.cs @@ -10,7 +10,7 @@ namespace Nerosoft.Starfish.Application; public class UserApplicationService : BaseApplicationService, IUserApplicationService { /// - public Task CreateAsync(UserCreateDto data, CancellationToken cancellationToken = default) + public Task CreateAsync(UserCreateDto data, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new UserCreateInput(data); @@ -19,7 +19,7 @@ public Task CreateAsync(UserCreateDto data, CancellationToken cancellationT } /// - public Task UpdateAsync(int id, UserUpdateDto data, CancellationToken cancellationToken = default) + public Task UpdateAsync(long id, UserUpdateDto data, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new UserUpdateInput(id, data); @@ -43,7 +43,7 @@ public Task CountAsync(UserCriteria criteria, CancellationToken cancellatio } /// - public Task GetAsync(int id, CancellationToken cancellationToken = default) + public Task GetAsync(long id, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new UserDetailInput(id); @@ -52,7 +52,7 @@ public Task GetAsync(int id, CancellationToken cancellationToken } /// - public Task DeleteAsync(int id, CancellationToken cancellationToken = default) + public Task DeleteAsync(long id, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new UserDeleteInput(id); @@ -60,7 +60,7 @@ public Task DeleteAsync(int id, CancellationToken cancellationToken = default) } /// - public Task SetRolesAsync(int id, List roles, CancellationToken cancellationToken = default) + public Task SetRolesAsync(long id, List roles, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new UserSetRoleInput(id, roles); @@ -74,7 +74,7 @@ public Task ChangePasswordAsync(string oldPassword, string newPassword, Cancella return useCase.ExecuteAsync(input, cancellationToken); } - public Task ResetPasswordAsync(int id, string password, CancellationToken cancellationToken = default) + public Task ResetPasswordAsync(long id, string password, CancellationToken cancellationToken = default) { var useCase = LazyServiceProvider.GetService(); var input = new ResetPasswordInput(id, password); diff --git a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs index 357f7ed..46d663a 100644 --- a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs @@ -13,12 +13,191 @@ public class InMemoryModelBuilder : IModelBuilder /// public void Configure(ModelBuilder modelBuilder) { - modelBuilder.Entity() - .Property(t => t.Id); - modelBuilder.Entity() - .Property(t => t.Id); - modelBuilder.Entity() - .Property(t => t.Id) - .HasValueGenerator(); + modelBuilder.Entity(entity => + { + entity.ToTable("user"); + + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.UserName) + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Roles) + .WithOne(t => t.User) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("user_role"); + + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(UserRole.UserId), nameof(UserRole.Name)], "IDX_USER_ROLE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.User) + .WithMany(t => t.Roles) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("token"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("operate_log"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("app_info"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.Code); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId); + entity.HasIndex(t => t.Environment); + + entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.App) + .WithMany() + .HasForeignKey(t => t.AppId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Items) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Revisions) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_item"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.HasIndex(t => t.Key); + + entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Items) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_revision"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Revisions) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_archive"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId) + .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team"); + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.Alias).HasDatabaseName("IDX_TEAM_ALIAS").IsUnique(); + entity.HasIndex(t => t.Name).HasDatabaseName("IDX_TEAM_NAME"); + entity.HasIndex(t => t.OwnerId).HasDatabaseName("IDX_TEAM_OWNER"); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Members) + .WithOne(t => t.Team) + .HasForeignKey(t => t.TeamId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team_member"); + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Team) + .WithMany(t => t.Members) + .HasForeignKey(t => t.TeamId); + + entity.HasOne(t => t.User) + .WithMany() + .HasForeignKey(t => t.UserId); + }); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs index ce5fb1e..3c3b15e 100644 --- a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs @@ -1,4 +1,6 @@ using Microsoft.EntityFrameworkCore; +using Nerosoft.Euonia.Repository.EfCore; +using Nerosoft.Starfish.Domain; using Nerosoft.Starfish.Service; namespace Nerosoft.Starfish.Repository; @@ -7,6 +9,191 @@ internal class MssqlModelBuilder : IModelBuilder { public void Configure(ModelBuilder modelBuilder) { - throw new NotImplementedException(); + modelBuilder.Entity(entity => + { + entity.ToTable("user"); + + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.UserName) + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Roles) + .WithOne(t => t.User) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("user_role"); + + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(UserRole.UserId), nameof(UserRole.Name)], "IDX_USER_ROLE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.User) + .WithMany(t => t.Roles) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("token"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("operate_log"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("app_info"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.Code); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId); + entity.HasIndex(t => t.Environment); + + entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.App) + .WithMany() + .HasForeignKey(t => t.AppId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Items) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Revisions) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_item"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.HasIndex(t => t.Key); + + entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Items) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_revision"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Revisions) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_archive"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId) + .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team"); + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.Alias).IsUnique(); + entity.HasIndex(t => t.Name); + entity.HasIndex(t => t.OwnerId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Members) + .WithOne(t => t.Team) + .HasForeignKey(t => t.TeamId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team_member"); + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Team) + .WithMany(t => t.Members) + .HasForeignKey(t => t.TeamId); + + entity.HasOne(t => t.User) + .WithMany() + .HasForeignKey(t => t.UserId); + }); } } diff --git a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs index ec0bef2..d03c984 100644 --- a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs @@ -1,4 +1,6 @@ using Microsoft.EntityFrameworkCore; +using Nerosoft.Euonia.Repository.EfCore; +using Nerosoft.Starfish.Domain; using Nerosoft.Starfish.Service; namespace Nerosoft.Starfish.Repository; @@ -7,6 +9,191 @@ internal class MysqlModelBuilder : IModelBuilder { public void Configure(ModelBuilder modelBuilder) { - throw new NotImplementedException(); + modelBuilder.Entity(entity => + { + entity.ToTable("user"); + + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.UserName) + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Roles) + .WithOne(t => t.User) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("user_role"); + + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(UserRole.UserId), nameof(UserRole.Name)], "IDX_USER_ROLE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.User) + .WithMany(t => t.Roles) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("token"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("operate_log"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("app_info"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.Code); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId); + entity.HasIndex(t => t.Environment); + + entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.App) + .WithMany() + .HasForeignKey(t => t.AppId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Items) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Revisions) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_item"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.HasIndex(t => t.Key); + + entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Items) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_revision"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Revisions) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_archive"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId) + .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team"); + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.Alias).IsUnique(); + entity.HasIndex(t => t.Name); + entity.HasIndex(t => t.OwnerId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Members) + .WithOne(t => t.Team) + .HasForeignKey(t => t.TeamId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team_member"); + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Team) + .WithMany(t => t.Members) + .HasForeignKey(t => t.TeamId); + + entity.HasOne(t => t.User) + .WithMany() + .HasForeignKey(t => t.UserId); + }); } } diff --git a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs index ebe4e6b..23d5213 100644 --- a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Nerosoft.Euonia.Repository.EfCore; using Nerosoft.Starfish.Domain; using Nerosoft.Starfish.Service; @@ -11,6 +12,188 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { entity.ToTable("user"); + + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.UserName) + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Roles) + .WithOne(t => t.User) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("user_role"); + + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(UserRole.UserId), nameof(UserRole.Name)], "IDX_USER_ROLE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.User) + .WithMany(t => t.Roles) + .HasForeignKey(t => t.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("token"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("operate_log"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + modelBuilder.Entity(entity => + { + entity.ToTable("app_info"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.Code); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId); + entity.HasIndex(t => t.Environment); + + entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.App) + .WithMany() + .HasForeignKey(t => t.AppId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Items) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(t => t.Revisions) + .WithOne() + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_item"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.HasIndex(t => t.Key); + + entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Items) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_revision"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.SettingId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Setting) + .WithMany(t => t.Revisions) + .HasForeignKey(t => t.SettingId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("setting_archive"); + entity.HasKey(t => t.Id); + entity.HasIndex(t => t.AppId) + .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team"); + entity.HasKey(t => t.Id); + + entity.HasIndex(t => t.Alias).IsUnique(); + entity.HasIndex(t => t.Name); + entity.HasIndex(t => t.OwnerId); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasMany(t => t.Members) + .WithOne(t => t.Team) + .HasForeignKey(t => t.TeamId); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("team_member"); + entity.HasKey(t => t.Id); + + entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE") + .IsUnique(); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + + entity.HasOne(t => t.Team) + .WithMany(t => t.Members) + .HasForeignKey(t => t.TeamId); + + entity.HasOne(t => t.User) + .WithMany() + .HasForeignKey(t => t.UserId); }); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs index 6c8dd8b..d666629 100644 --- a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs @@ -22,6 +22,10 @@ public void Configure(ModelBuilder modelBuilder) entity.HasIndex(t => t.UserName) .IsUnique(); + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + entity.HasMany(t => t.Roles) .WithOne(t => t.User) .HasForeignKey(t => t.UserId); @@ -36,6 +40,10 @@ public void Configure(ModelBuilder modelBuilder) entity.HasIndex([nameof(UserRole.UserId), nameof(UserRole.Name)], "IDX_USER_ROLE_UNIQUE") .IsUnique(); + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + entity.HasOne(t => t.User) .WithMany(t => t.Roles) .HasForeignKey(t => t.UserId); @@ -44,10 +52,22 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { entity.ToTable("token"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); }); modelBuilder.Entity(entity => { entity.ToTable("operate_log"); + + entity.HasKey(t => t.Id); + + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); }); modelBuilder.Entity(entity => { @@ -150,6 +170,10 @@ public void Configure(ModelBuilder modelBuilder) entity.HasIndex(t => t.Name); entity.HasIndex(t => t.OwnerId); + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + entity.HasMany(t => t.Members) .WithOne(t => t.Team) .HasForeignKey(t => t.TeamId); @@ -163,6 +187,10 @@ public void Configure(ModelBuilder modelBuilder) entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE") .IsUnique(); + entity.Property(t => t.Id) + .IsRequired() + .HasValueGenerator(); + entity.HasOne(t => t.Team) .WithMany(t => t.Members) .HasForeignKey(t => t.TeamId); diff --git a/Source/Starfish.Service/UseCases/Apps/AppInfoCountUseCase.cs b/Source/Starfish.Service/UseCases/Apps/AppInfoCountUseCase.cs index 2990455..bfbe81b 100644 --- a/Source/Starfish.Service/UseCases/Apps/AppInfoCountUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/AppInfoCountUseCase.cs @@ -53,7 +53,7 @@ IQueryable Permission(IQueryable query) { if (!_user.IsInRole("SA")) { - var userId = _user.GetUserIdOfInt32(); + var userId = _user.GetUserIdOfInt64(); var teamQuery = _repository.Context.Set(); query = from app in query join member in teamQuery on app.TeamId equals member.TeamId diff --git a/Source/Starfish.Service/UseCases/Apps/AppInfoDetailUseCase.cs b/Source/Starfish.Service/UseCases/Apps/AppInfoDetailUseCase.cs index 68f5d5d..4a83d49 100644 --- a/Source/Starfish.Service/UseCases/Apps/AppInfoDetailUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/AppInfoDetailUseCase.cs @@ -59,7 +59,7 @@ IQueryable Permission(IQueryable query) { if (!_user.IsInRole("SA")) { - var userId = _user.GetUserIdOfInt32(); + var userId = _user.GetUserIdOfInt64(); var teamQuery = _repository.Context.Set(); query = from app in query join member in teamQuery on app.TeamId equals member.TeamId diff --git a/Source/Starfish.Service/UseCases/Apps/AppInfoQueryUseCase.cs b/Source/Starfish.Service/UseCases/Apps/AppInfoQueryUseCase.cs index 39a83f5..d42a3f3 100644 --- a/Source/Starfish.Service/UseCases/Apps/AppInfoQueryUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/AppInfoQueryUseCase.cs @@ -72,7 +72,7 @@ IQueryable Permission(IQueryable query) { if (!_identity.IsInRole("SA")) { - var userId = _identity.GetUserIdOfInt32(); + var userId = _identity.GetUserIdOfInt64(); var teamQuery = _repository.Context.Set(); query = from app in query join member in teamQuery on app.TeamId equals member.TeamId diff --git a/Source/Starfish.Service/UseCases/Apps/AppInfoUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Apps/AppInfoUpdateUseCase.cs index 014199e..4e18228 100644 --- a/Source/Starfish.Service/UseCases/Apps/AppInfoUpdateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/AppInfoUpdateUseCase.cs @@ -24,11 +24,6 @@ public record AppInfoUpdateInput(long Id, AppInfoUpdateDto Model) : IUseCaseInpu /// public class AppInfoUpdateUseCase : IAppInfoUpdateUseCase { - /// - /// 允许访问的角色 - /// - private readonly string[] _roles = { "SA", "RW" }; - private readonly IBus _bus; private readonly UserPrincipal _user; @@ -44,7 +39,7 @@ public Task ExecuteAsync(AppInfoUpdateInput input, CancellationToken cancellatio { throw new AuthenticationException(); } - + var command = new AppInfoUpdateCommand(input.Id, input.Model); return _bus.SendAsync(command, cancellationToken); } diff --git a/Source/Starfish.Service/UseCases/Apps/ChangeAppInfoStatusUseCase.cs b/Source/Starfish.Service/UseCases/Apps/ChangeAppInfoStatusUseCase.cs index 5f5a6f5..5649db7 100644 --- a/Source/Starfish.Service/UseCases/Apps/ChangeAppInfoStatusUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/ChangeAppInfoStatusUseCase.cs @@ -24,11 +24,6 @@ public record ChangeAppInfoStatusInput(long Id, AppStatus Status) : IUseCaseInpu /// public class ChangeAppInfoStatusUseCase : IChangeAppInfoStatusUseCase { - /// - /// 允许访问的角色 - /// - private readonly string[] _roles = ["SA", "RW"]; - private readonly IBus _bus; private readonly UserPrincipal _user; @@ -45,11 +40,6 @@ public Task ExecuteAsync(ChangeAppInfoStatusInput input, CancellationToken cance throw new AuthenticationException(); } - if (!_user.IsInRoles(_roles)) - { - throw new UnauthorizedAccessException(); - } - var command = new ChangeAppStatusCommand(input.Id, input.Status); return _bus.SendAsync(command, cancellationToken); } diff --git a/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs b/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs index 801402e..c48db36 100644 --- a/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs @@ -32,7 +32,7 @@ public async Task ExecuteAsync(ChangePasswordInput input, CancellationToken canc throw new AuthenticationException(); } - var user = await _repository.GetAsync(_user.GetUserIdOfInt32(), null, cancellationToken); + var user = await _repository.GetAsync(_user.GetUserIdOfInt64(), null, cancellationToken); if (user == null) { diff --git a/Source/Starfish.Service/UseCases/Identity/IdentityCommonComponent.cs b/Source/Starfish.Service/UseCases/Identity/IdentityCommonComponent.cs index 35bbbfb..8671d37 100644 --- a/Source/Starfish.Service/UseCases/Identity/IdentityCommonComponent.cs +++ b/Source/Starfish.Service/UseCases/Identity/IdentityCommonComponent.cs @@ -31,7 +31,7 @@ public IdentityCommonComponent(IConfiguration configuration) /// Item3-颁发时间 /// Item4-过期时间 /// - public Tuple GenerateAccessToken(int userId, string userName, IEnumerable roles = null) + public Tuple GenerateAccessToken(long userId, string userName, IEnumerable roles = null) { var issueTime = DateTime.UtcNow; var expiresAt = issueTime.AddDays(1); diff --git a/Source/Starfish.Service/UseCases/Identity/IdentityUseCaseOutput.cs b/Source/Starfish.Service/UseCases/Identity/IdentityUseCaseOutput.cs index dfa7dcf..16ff544 100644 --- a/Source/Starfish.Service/UseCases/Identity/IdentityUseCaseOutput.cs +++ b/Source/Starfish.Service/UseCases/Identity/IdentityUseCaseOutput.cs @@ -30,5 +30,5 @@ public abstract class IdentityUseCaseOutput : IUseCaseOutput /// /// 用户Id /// - public int UserId { get; set; } + public long UserId { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Identity/ResetPasswordUseCase.cs b/Source/Starfish.Service/UseCases/Identity/ResetPasswordUseCase.cs index 4ffeb2b..7220761 100644 --- a/Source/Starfish.Service/UseCases/Identity/ResetPasswordUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/ResetPasswordUseCase.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.UseCases; public interface IResetPasswordUseCase : INonOutputUseCase; -public record ResetPasswordInput(int Id, string Password) : IUseCaseInput; +public record ResetPasswordInput(long Id, string Password) : IUseCaseInput; public class ResetPasswordUseCase : IResetPasswordUseCase { diff --git a/Source/Starfish.Service/UseCases/Identity/UserCreateUseCase.cs b/Source/Starfish.Service/UseCases/Identity/UserCreateUseCase.cs index abe2bc2..bec4843 100644 --- a/Source/Starfish.Service/UseCases/Identity/UserCreateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/UserCreateUseCase.cs @@ -7,7 +7,7 @@ namespace Nerosoft.Starfish.UseCases; public interface IUserCreateUseCase : IUseCase; -public record UserCreateOutput(int Result) : IUseCaseOutput; +public record UserCreateOutput(long Result) : IUseCaseOutput; public record UserCreateInput(UserCreateDto Data) : IUseCaseInput; @@ -23,7 +23,7 @@ public UserCreateUseCase(IBus bus) public Task ExecuteAsync(UserCreateInput input, CancellationToken cancellationToken = default) { var command = new UserCreateCommand(input.Data); - return _bus.SendAsync(command, cancellationToken) + return _bus.SendAsync(command, cancellationToken) .ContinueWith(task => new UserCreateOutput(task.Result), cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Identity/UserDeleteUseCase.cs b/Source/Starfish.Service/UseCases/Identity/UserDeleteUseCase.cs index facf942..56d89ec 100644 --- a/Source/Starfish.Service/UseCases/Identity/UserDeleteUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/UserDeleteUseCase.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.UseCases; public interface IUserDeleteUseCase : INonOutputUseCase; -public record UserDeleteInput(int Id) : IUseCaseInput; +public record UserDeleteInput(long Id) : IUseCaseInput; public class UserDeleteUseCase : IUserDeleteUseCase { diff --git a/Source/Starfish.Service/UseCases/Identity/UserDetailUseCase.cs b/Source/Starfish.Service/UseCases/Identity/UserDetailUseCase.cs index 2c456e5..9be547f 100644 --- a/Source/Starfish.Service/UseCases/Identity/UserDetailUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/UserDetailUseCase.cs @@ -10,7 +10,7 @@ public interface IUserDetailUseCase : IUseCase; -public record UserSetRoleInput(int Id, List Roles) : IUseCaseInput; +public record UserSetRoleInput(long Id, List Roles) : IUseCaseInput; public class UserSetRoleUseCase : IUserSetRoleUseCase { diff --git a/Source/Starfish.Service/UseCases/Identity/UserUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Identity/UserUpdateUseCase.cs index c6e9283..a3cc8ab 100644 --- a/Source/Starfish.Service/UseCases/Identity/UserUpdateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/UserUpdateUseCase.cs @@ -7,7 +7,7 @@ namespace Nerosoft.Starfish.UseCases; public interface IUserUpdateUseCase : INonOutputUseCase; -public record UserUpdateInput(int Id, UserUpdateDto Data) : IUseCaseInput; +public record UserUpdateInput(long Id, UserUpdateDto Data) : IUseCaseInput; public class UserUpdateUseCase : IUserUpdateUseCase { diff --git a/Source/Starfish.Service/UseCases/Team/TeamCountUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamCountUseCase.cs index b52e0b2..acfd1a2 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamCountUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamCountUseCase.cs @@ -29,7 +29,7 @@ public Task ExecuteAsync(TeamCountInput input, CancellationToke var specification = input.Criteria.GetSpecification(); if (!_identity.IsInRole("SA")) { - specification &= TeamSpecification.HasMember(_identity.GetUserIdOfInt32()); + specification &= TeamSpecification.HasMember(_identity.GetUserIdOfInt64()); } var predicate = specification.Satisfy(); diff --git a/Source/Starfish.Service/UseCases/Team/TeamCreateUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamCreateUseCase.cs index b9e388b..324b2ff 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamCreateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamCreateUseCase.cs @@ -9,7 +9,7 @@ public interface ITeamCreateUseCase : IUseCase ExecuteAsync(TeamCreateInput input, CancellationToken cancellationToken = default) { var command = new TeamCreateCommand(input.Data); - return _bus.SendAsync(command, cancellationToken) + return _bus.SendAsync(command, cancellationToken) .ContinueWith(task => { task.WaitAndUnwrapException(cancellationToken); diff --git a/Source/Starfish.Service/UseCases/Team/TeamDetailUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamDetailUseCase.cs index 4c1d6c2..ed2a3f9 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamDetailUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamDetailUseCase.cs @@ -10,7 +10,7 @@ namespace Nerosoft.Starfish.UseCases; public interface ITeamDetailUseCase : IUseCase; -public record TeamDetailInput(int Id) : IUseCaseInput; +public record TeamDetailInput(long Id) : IUseCaseInput; public record TeamDetailOutput(TeamDetailDto Result) : IUseCaseOutput; @@ -30,7 +30,7 @@ public Task ExecuteAsync(TeamDetailInput input, CancellationTo var specification = TeamSpecification.IdEquals(input.Id); if (!_identity.IsInRole("SA")) { - specification &= TeamSpecification.HasMember(_identity.GetUserIdOfInt32()); + specification &= TeamSpecification.HasMember(_identity.GetUserIdOfInt64()); } var predicate = specification.Satisfy(); diff --git a/Source/Starfish.Service/UseCases/Team/TeamMemberAppendUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamMemberAppendUseCase.cs index d03e619..7ef65c9 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamMemberAppendUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamMemberAppendUseCase.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.UseCases; public interface ITeamMemberAppendUseCase : INonOutputUseCase; -public record TeamMemberAppendInput(int Id, List UserIds) : IUseCaseInput; +public record TeamMemberAppendInput(long Id, List UserIds) : IUseCaseInput; public class TeamMemberAppendUseCase : ITeamMemberAppendUseCase { diff --git a/Source/Starfish.Service/UseCases/Team/TeamMemberQueryUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamMemberQueryUseCase.cs index 6cd7d1c..af65463 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamMemberQueryUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamMemberQueryUseCase.cs @@ -8,7 +8,7 @@ public interface ITeamMemberQueryUseCase : IUseCase Result) : IUseCaseOutput; -public record TeamMemberQueryInput(int Id) : IUseCaseInput; +public record TeamMemberQueryInput(long Id) : IUseCaseInput; public class TeamMemberQueryUseCase : ITeamMemberQueryUseCase { diff --git a/Source/Starfish.Service/UseCases/Team/TeamMemberQuitUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamMemberQuitUseCase.cs index 80a55d2..3148181 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamMemberQuitUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamMemberQuitUseCase.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.UseCases; public interface ITeamMemberQuitUseCase : INonOutputUseCase; -public record TeamMemberQuitInput(int TeamId, int UserId) : IUseCaseInput; +public record TeamMemberQuitInput(long TeamId, long UserId) : IUseCaseInput; public class TeamMemberQuitUseCase : ITeamMemberQuitUseCase { diff --git a/Source/Starfish.Service/UseCases/Team/TeamMemberRemoveUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamMemberRemoveUseCase.cs index bf970a3..331b8b8 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamMemberRemoveUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamMemberRemoveUseCase.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.UseCases; public interface ITeamMemberRemoveUseCase : INonOutputUseCase; -public record TeamMemberRemoveInput(int Id, List UserIds) : IUseCaseInput; +public record TeamMemberRemoveInput(long Id, List UserIds) : IUseCaseInput; public class TeamMemberRemoveUseCase : ITeamMemberRemoveUseCase { diff --git a/Source/Starfish.Service/UseCases/Team/TeamQueryUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamQueryUseCase.cs index 4fa5fc8..395f15e 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamQueryUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamQueryUseCase.cs @@ -1,5 +1,4 @@ using System.Security.Authentication; -using Microsoft.EntityFrameworkCore; using Nerosoft.Euonia.Application; using Nerosoft.Euonia.Claims; using Nerosoft.Starfish.Domain; @@ -58,7 +57,7 @@ IQueryable Permission(IQueryable query) { if (!_identity.IsInRole("SA")) { - var userId = _identity.GetUserIdOfInt32(); + var userId = _identity.GetUserIdOfInt64(); var memberQuery = _repository.Context.Set(); query = from team in query diff --git a/Source/Starfish.Service/UseCases/Team/TeamUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Team/TeamUpdateUseCase.cs index db86c71..486b68b 100644 --- a/Source/Starfish.Service/UseCases/Team/TeamUpdateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Team/TeamUpdateUseCase.cs @@ -7,7 +7,7 @@ namespace Nerosoft.Starfish.UseCases; public interface ITeamUpdateUseCase : INonOutputUseCase; -public record TeamUpdateInput(int Id, TeamEditDto Data) : IUseCaseInput; +public record TeamUpdateInput(long Id, TeamEditDto Data) : IUseCaseInput; public class TeamUpdateUseCase : ITeamUpdateUseCase { diff --git a/Source/Starfish.Transit/Apps/AppInfoCreateDto.cs b/Source/Starfish.Transit/Apps/AppInfoCreateDto.cs index 8239a51..48eb56f 100644 --- a/Source/Starfish.Transit/Apps/AppInfoCreateDto.cs +++ b/Source/Starfish.Transit/Apps/AppInfoCreateDto.cs @@ -8,7 +8,7 @@ public class AppInfoCreateDto /// /// 团队Id /// - public int TeamId { get; set; } + public long TeamId { get; set; } /// /// 应用名称 diff --git a/Source/Starfish.Transit/Apps/AppInfoDetailDto.cs b/Source/Starfish.Transit/Apps/AppInfoDetailDto.cs index 3fd4ba0..8a7696a 100644 --- a/Source/Starfish.Transit/Apps/AppInfoDetailDto.cs +++ b/Source/Starfish.Transit/Apps/AppInfoDetailDto.cs @@ -10,6 +10,11 @@ public class AppInfoDetailDto /// public long Id { get; set; } + /// + /// 团队Id + /// + public long TeamId { get; set; } + /// /// 名称 /// diff --git a/Source/Starfish.Transit/Identity/UserDetailDto.cs b/Source/Starfish.Transit/Identity/UserDetailDto.cs index c5f92d7..9785b88 100644 --- a/Source/Starfish.Transit/Identity/UserDetailDto.cs +++ b/Source/Starfish.Transit/Identity/UserDetailDto.cs @@ -8,7 +8,7 @@ public class UserDetailDto /// /// Id /// - public int Id { get; set; } + public long Id { get; set; } /// /// 用户名 diff --git a/Source/Starfish.Transit/Identity/UserItemDto.cs b/Source/Starfish.Transit/Identity/UserItemDto.cs index ab62486..01fb5a3 100644 --- a/Source/Starfish.Transit/Identity/UserItemDto.cs +++ b/Source/Starfish.Transit/Identity/UserItemDto.cs @@ -8,7 +8,7 @@ public class UserItemDto /// /// Id /// - public int Id { get; set; } + public long Id { get; set; } /// /// 用户名 diff --git a/Source/Starfish.Transit/Team/TeamDetailDto.cs b/Source/Starfish.Transit/Team/TeamDetailDto.cs index ecc2ea1..b929873 100644 --- a/Source/Starfish.Transit/Team/TeamDetailDto.cs +++ b/Source/Starfish.Transit/Team/TeamDetailDto.cs @@ -8,7 +8,7 @@ public class TeamDetailDto /// /// Id /// - public int Id { get; set; } + public long Id { get; set; } /// /// 别名 @@ -28,7 +28,7 @@ public class TeamDetailDto /// /// 团队所有者Id /// - public int OwnerId { get; set; } + public long OwnerId { get; set; } /// /// 成员数量 diff --git a/Source/Starfish.Transit/Team/TeamItemDto.cs b/Source/Starfish.Transit/Team/TeamItemDto.cs index 48991ea..a0ae5b2 100644 --- a/Source/Starfish.Transit/Team/TeamItemDto.cs +++ b/Source/Starfish.Transit/Team/TeamItemDto.cs @@ -8,7 +8,7 @@ public class TeamItemDto /// /// Id /// - public int Id { get; set; } + public long Id { get; set; } /// /// 别名 @@ -28,7 +28,7 @@ public class TeamItemDto /// /// 团队所有者Id /// - public int OwnerId { get; set; } + public long OwnerId { get; set; } /// /// 成员数量 diff --git a/Source/Starfish.Transit/Team/TeamMemberDto.cs b/Source/Starfish.Transit/Team/TeamMemberDto.cs index 4067798..983c9fe 100644 --- a/Source/Starfish.Transit/Team/TeamMemberDto.cs +++ b/Source/Starfish.Transit/Team/TeamMemberDto.cs @@ -8,7 +8,7 @@ public class TeamMemberDto /// /// 用户Id /// - public int UserId { get; set; } + public long UserId { get; set; } /// /// 用户名 diff --git a/Source/Starfish.Webapi/Controllers/TeamController.cs b/Source/Starfish.Webapi/Controllers/TeamController.cs index 9eac61c..0595b7b 100644 --- a/Source/Starfish.Webapi/Controllers/TeamController.cs +++ b/Source/Starfish.Webapi/Controllers/TeamController.cs @@ -57,9 +57,9 @@ public async Task CountAsync([FromQuery] TeamCriteria criteria) /// /// /// - [HttpGet("{id:int}")] + [HttpGet("{id:long}")] [Produces(typeof(TeamDetailDto))] - public async Task GetAsync(int id) + public async Task GetAsync(long id) { var result = await _service.GetAsync(id, HttpContext.RequestAborted); return Ok(result); @@ -84,8 +84,8 @@ public async Task CreateAsync([FromBody] TeamEditDto data) /// /// /// - [HttpPut("{id:int}")] - public async Task UpdateAsync(int id, [FromBody] TeamEditDto data) + [HttpPut("{id:long}")] + public async Task UpdateAsync(long id, [FromBody] TeamEditDto data) { await _service.UpdateAsync(id, data, HttpContext.RequestAborted); return Ok(); @@ -96,9 +96,9 @@ public async Task UpdateAsync(int id, [FromBody] TeamEditDto data /// /// /// - [HttpGet("{id:int}/member")] + [HttpGet("{id:long}/member")] [Produces(typeof(List))] - public async Task QueryMembersAsync(int id) + public async Task QueryMembersAsync(long id) { var result = await _service.QueryMembersAsync(id, HttpContext.RequestAborted); return Ok(result); @@ -110,8 +110,8 @@ public async Task QueryMembersAsync(int id) /// /// /// - [HttpPost("{id:int}/member")] - public async Task AppendMembersAsync(int id, [FromBody] List userIds) + [HttpPost("{id:long}/member")] + public async Task AppendMembersAsync(long id, [FromBody] List userIds) { await _service.AppendMembersAsync(id, userIds, HttpContext.RequestAborted); return Ok(); @@ -123,8 +123,8 @@ public async Task AppendMembersAsync(int id, [FromBody] List /// /// /// - [HttpDelete("{id:int}/member")] - public async Task RemoveMembersAsync(int id, [FromBody] List userIds) + [HttpDelete("{id:long}/member")] + public async Task RemoveMembersAsync(long id, [FromBody] List userIds) { await _service.RemoveMembersAsync(id, userIds, HttpContext.RequestAborted); return Ok(); @@ -135,8 +135,8 @@ public async Task RemoveMembersAsync(int id, [FromBody] List /// /// /// - [HttpDelete("{id:int}/quit")] - public async Task QuitAsync(int id) + [HttpDelete("{id:long}/quit")] + public async Task QuitAsync(long id) { await _service.QuitAsync(id, HttpContext.RequestAborted); return Ok(); diff --git a/Source/Starfish.Webapi/Controllers/UserController.cs b/Source/Starfish.Webapi/Controllers/UserController.cs index 8743087..f166ea4 100644 --- a/Source/Starfish.Webapi/Controllers/UserController.cs +++ b/Source/Starfish.Webapi/Controllers/UserController.cs @@ -57,9 +57,9 @@ public async Task CountAsync([FromQuery] UserCriteria criteria) /// /// /// - [HttpGet("{id:int}")] + [HttpGet("{id:long}")] [Produces(typeof(UserDetailDto))] - public async Task GetAsync(int id) + public async Task GetAsync(long id) { var result = await _service.GetAsync(id, HttpContext.RequestAborted); return Ok(result); @@ -84,8 +84,8 @@ public async Task CreateAsync([FromBody] UserCreateDto data) /// /// /// - [HttpPut("{id:int}")] - public async Task UpdateAsync(int id, [FromBody] UserUpdateDto data) + [HttpPut("{id:long}")] + public async Task UpdateAsync(long id, [FromBody] UserUpdateDto data) { await _service.UpdateAsync(id, data, HttpContext.RequestAborted); return Ok(); @@ -96,8 +96,8 @@ public async Task UpdateAsync(int id, [FromBody] UserUpdateDto da /// /// /// - [HttpDelete("{id:int}")] - public async Task DeleteAsync(int id) + [HttpDelete("{id:long}")] + public async Task DeleteAsync(long id) { await _service.DeleteAsync(id, HttpContext.RequestAborted); return Ok(); @@ -109,8 +109,8 @@ public async Task DeleteAsync(int id) /// /// /// - [HttpPut("{id:int}/role")] - public async Task SetRoleAsync(int id, [FromBody] List roles) + [HttpPut("{id:long}/role")] + public async Task SetRoleAsync(long id, [FromBody] List roles) { await _service.SetRolesAsync(id, roles, HttpContext.RequestAborted); return Ok(); @@ -122,9 +122,9 @@ public async Task SetRoleAsync(int id, [FromBody] List ro /// /// /// - [HttpPut("{id:int}/password")] + [HttpPut("{id:long}/password")] [Authorize(Roles = "SA")] - public async Task ResetPasswordAsync(int id, [FromBody] ResetPasswordRequestDto data) + public async Task ResetPasswordAsync(long id, [FromBody] ResetPasswordRequestDto data) { await _service.ResetPasswordAsync(id, data.Password, HttpContext.RequestAborted); return Ok(); diff --git a/Source/Starfish.Webapp/Pages/Team/AppendMember.razor b/Source/Starfish.Webapp/Pages/Team/AppendMember.razor index e1fb184..0e4bfe8 100644 --- a/Source/Starfish.Webapp/Pages/Team/AppendMember.razor +++ b/Source/Starfish.Webapp/Pages/Team/AppendMember.razor @@ -1,4 +1,4 @@ -@implements IDialogContentComponent +@implements IDialogContentComponent @inject ITeamApi TeamApi @inject IUserApi UserApi @@ -21,7 +21,7 @@ @code { [Parameter] - public int Content { get; set; } + public long Content { get; set; } [CascadingParameter] public FluentDialog Dialog { get; set; } = default!; @@ -35,7 +35,7 @@ private async Task OnSearchAsync(OptionsSearchEventArgs e) { Criteria.Keyword = e.Text; - e.Items = await UserApi.SearchAsync(Criteria, 1, 20) + e.Items = await UserApi.SearchAsync(Criteria) .ContinueWith(task => { task.WaitAndUnwrapException(); diff --git a/Source/Starfish.Webapp/Pages/Team/Detail.razor b/Source/Starfish.Webapp/Pages/Team/Detail.razor index 6978ec2..566edcc 100644 --- a/Source/Starfish.Webapp/Pages/Team/Detail.razor +++ b/Source/Starfish.Webapp/Pages/Team/Detail.razor @@ -1,4 +1,4 @@ -@page "/team/{id:int}" +@page "/team/{id:long}" @inject ITeamApi TeamApi @inject IAppsApi AppsApi @@ -20,7 +20,7 @@ Updated at: @Data.UpdateTime.Date @Data.Description - @if (Data.OwnerId != Identity?.GetUserIdOfInt32()) + @if (Data.OwnerId != Identity?.GetUserIdOfInt64()) { @(Resources.IDS_COMMON_OPERATIONS) @@ -37,7 +37,7 @@ @foreach (var member in Members) { - @if (Data.OwnerId != Identity?.GetUserIdOfInt32()) + @if (Data.OwnerId != Identity?.GetUserIdOfInt64()) { AuthenticationState { get; set; } @@ -134,7 +134,7 @@ try { var criteria = new AppInfoCriteria { TeamId = Id }; - return AppsApi.QueryAsync(criteria, 1, 100) + return AppsApi.QueryAsync(criteria, 0, 100) .ContinueWith(task => { task.WaitAndUnwrapException(); @@ -148,7 +148,7 @@ } } - private async Task OnRemoveMemberClicked(int userId) + private async Task OnRemoveMemberClicked(long userId) { var confirmation = await DialogService.ShowConfirmationAsync(Resources.IDS_TEAM_DETAIL_REMOVE_CONFIRMATION_MESSAGE, primaryText: Resources.IDS_COMMON_YES, secondaryText: Resources.IDS_COMMON_NO, title: Resources.IDS_TEAM_DETAIL_REMOVE_CONFIRMATION_TITLE); var result = await confirmation.Result; diff --git a/Source/Starfish.Webapp/Pages/Team/Edit.razor b/Source/Starfish.Webapp/Pages/Team/Edit.razor index 9f213a3..c592d27 100644 --- a/Source/Starfish.Webapp/Pages/Team/Edit.razor +++ b/Source/Starfish.Webapp/Pages/Team/Edit.razor @@ -1,4 +1,4 @@ -@implements IDialogContentComponent +@implements IDialogContentComponent @inject ITeamApi Api @inject IToastService ToastService @@ -35,7 +35,7 @@ @code { [Parameter] - public int Content { get; set; } + public long Content { get; set; } [CascadingParameter] public FluentDialog Dialog { get; set; } = default!; @@ -103,7 +103,7 @@ await Dialog.CancelAsync(); } - private async Task LoadAsync(int id) + private async Task LoadAsync(long id) { if (id <= 0) { diff --git a/Source/Starfish.Webapp/Pages/Team/Index.razor b/Source/Starfish.Webapp/Pages/Team/Index.razor index 9e98282..e8852e7 100644 --- a/Source/Starfish.Webapp/Pages/Team/Index.razor +++ b/Source/Starfish.Webapp/Pages/Team/Index.razor @@ -32,7 +32,7 @@ - + @@ -94,13 +94,13 @@ }; } - private async Task HandleDetailClicked(int id) + private async Task HandleDetailClicked(long id) { Navigation.NavigateTo($"/team/{id}"); await Task.CompletedTask; } - private async Task OnEditClicked(int id) + private async Task OnEditClicked(long id) { var title = id == 0 ? Resources.IDS_TEAM_EDIT_TITLE_ADD : Resources.IDS_TEAM_EDIT_TITLE_EDIT; await DialogService.ShowDialogAsync(id, new DialogParameters { Title = title, Modal = true }); diff --git a/Source/Starfish.Webapp/Pages/User/Detail.razor b/Source/Starfish.Webapp/Pages/User/Detail.razor index bd21357..776e789 100644 --- a/Source/Starfish.Webapp/Pages/User/Detail.razor +++ b/Source/Starfish.Webapp/Pages/User/Detail.razor @@ -1,4 +1,4 @@ -@page "/user/{Id:int}" +@page "/user/{Id:long}" @attribute [Authorize(Roles = "SA")] @@ -49,7 +49,7 @@ @code { [Parameter] - public int Id { get; set; } + public long Id { get; set; } private UserDetailDto Data { get; } = new(); } \ No newline at end of file diff --git a/Source/Starfish.Webapp/Pages/User/Edit.razor b/Source/Starfish.Webapp/Pages/User/Edit.razor index de8ee84..0bf4457 100644 --- a/Source/Starfish.Webapp/Pages/User/Edit.razor +++ b/Source/Starfish.Webapp/Pages/User/Edit.razor @@ -1,4 +1,4 @@ -@implements IDialogContentComponent +@implements IDialogContentComponent @inject IUserApi Api @inject IToastService ToastService @@ -47,7 +47,7 @@ @code { [Parameter] - public int Content { get; set; } + public long Content { get; set; } [CascadingParameter] public FluentDialog Dialog { get; set; } = default!; @@ -131,7 +131,7 @@ await Dialog.CancelAsync(); } - private async Task LoadAsync(int id) + private async Task LoadAsync(long id) { if (id <= 0) { diff --git a/Source/Starfish.Webapp/Pages/User/Index.razor b/Source/Starfish.Webapp/Pages/User/Index.razor index 2e89b1c..3d25179 100644 --- a/Source/Starfish.Webapp/Pages/User/Index.razor +++ b/Source/Starfish.Webapp/Pages/User/Index.razor @@ -88,13 +88,13 @@ await Task.CompletedTask; } - private async Task OnDetailClicked(int id) + private async Task OnDetailClicked(long id) { Navigation.NavigateTo($"/user/{id}"); await Task.CompletedTask; } - private async Task OnEditClicked(int id) + private async Task OnEditClicked(long id) { var title = id == 0 ? Resources.IDS_USER_DIALOG_TITLE_ADD : Resources.IDS_USER_DIALOG_TITLE_EDIT; var dialog = await DialogService.ShowDialogAsync(id, new DialogParameters { Title = title, Modal = true }); @@ -110,7 +110,7 @@ await Pagination.SetCurrentPageIndexAsync(0); } - private async Task OnResetPasswordClicked(int id) + private async Task OnResetPasswordClicked(long id) { await DialogService.ShowDialogAsync(id, new DialogParameters { Modal = true }); } diff --git a/Source/Starfish.Webapp/Pages/User/ResetPassword.razor b/Source/Starfish.Webapp/Pages/User/ResetPassword.razor index 2a65691..88a39c6 100644 --- a/Source/Starfish.Webapp/Pages/User/ResetPassword.razor +++ b/Source/Starfish.Webapp/Pages/User/ResetPassword.razor @@ -1,4 +1,4 @@ -@implements IDialogContentComponent +@implements IDialogContentComponent @inject IUserApi UserApi @inject IToastService ToastService @@ -33,7 +33,7 @@ @code { [Parameter] - public int Content { get; set; } + public long Content { get; set; } [CascadingParameter] public FluentDialog Dialog { get; set; } = default!; diff --git a/Source/Starfish.Webapp/Rest/Defines/ITeamApi.cs b/Source/Starfish.Webapp/Rest/Defines/ITeamApi.cs index 530ea0b..86954bd 100644 --- a/Source/Starfish.Webapp/Rest/Defines/ITeamApi.cs +++ b/Source/Starfish.Webapp/Rest/Defines/ITeamApi.cs @@ -12,23 +12,23 @@ internal interface ITeamApi Task> CountAsync([Query] TeamCriteria criteria, CancellationToken cancellationToken = default); [Get("/api/team/{id}")] - Task> GetAsync(int id, CancellationToken cancellationToken = default); + Task> GetAsync(long id, CancellationToken cancellationToken = default); [Post("/api/team")] Task CreateAsync([Body] TeamEditDto data, CancellationToken cancellationToken = default); [Put("/api/team/{id}")] - Task UpdateAsync(int id, [Body] TeamEditDto data, CancellationToken cancellationToken = default); + Task UpdateAsync(long id, [Body] TeamEditDto data, CancellationToken cancellationToken = default); [Get("/api/team/{id}/member")] - Task>> GetMembersAsync(int id, CancellationToken cancellationToken = default); + Task>> GetMembersAsync(long id, CancellationToken cancellationToken = default); [Post("/api/team/{id}/member")] - Task AppendMemberAsync(int id, [Body] List userIds, CancellationToken cancellationToken = default); + Task AppendMemberAsync(long id, [Body] List userIds, CancellationToken cancellationToken = default); [Delete("/api/team/{id}/member")] - Task RemoveMemberAsync(int id, [Body] List userIds, CancellationToken cancellationToken = default); + Task RemoveMemberAsync(long id, [Body] List userIds, CancellationToken cancellationToken = default); [Delete("/api/team/{id}/quit")] - Task QuitAsync(int id, CancellationToken cancellationToken = default); + Task QuitAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Webapp/Rest/Defines/IUserApi.cs b/Source/Starfish.Webapp/Rest/Defines/IUserApi.cs index bae57fe..de4d45f 100644 --- a/Source/Starfish.Webapp/Rest/Defines/IUserApi.cs +++ b/Source/Starfish.Webapp/Rest/Defines/IUserApi.cs @@ -12,19 +12,19 @@ internal interface IUserApi Task> CountAsync([Query] UserCriteria criteria, CancellationToken cancellationToken = default); [Get("/api/user/{id}")] - Task> GetAsync(int id, CancellationToken cancellationToken = default); + Task> GetAsync(long id, CancellationToken cancellationToken = default); [Post("/api/user")] Task CreateAsync([Body] UserCreateDto data, CancellationToken cancellationToken = default); [Put("/api/user/{id}")] - Task UpdateAsync(int id, [Body] UserUpdateDto data, CancellationToken cancellationToken = default); + Task UpdateAsync(long id, [Body] UserUpdateDto data, CancellationToken cancellationToken = default); [Delete("/api/user/{id}")] - Task DeleteAsync(int id, CancellationToken cancellationToken = default); + Task DeleteAsync(long id, CancellationToken cancellationToken = default); [Put("/api/user/{id}/password")] - Task ResetPassword(int id, [Body] ResetPasswordRequestDto data, CancellationToken cancellationToken = default); + Task ResetPassword(long id, [Body] ResetPasswordRequestDto data, CancellationToken cancellationToken = default); [Put("/api/user/password")] Task ChangePassword([Body] ChangePasswordRequestDto data, CancellationToken cancellationToken = default); From c4511511fb55c6e284832eecd9fd3aa58f6e5891 Mon Sep 17 00:00:00 2001 From: damon Date: Tue, 23 Jan 2024 22:51:16 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E7=B9=81=E4=BD=93=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/Setting/SettingDeleteCommand.cs | 4 +- .../Commands/Setting/SettingPublishCommand.cs | 4 +- .../Commands/Setting/SettingUpdateCommand.cs | 4 +- .../DictionaryApplicationService.cs | 1 - .../Domain/Business/AppInfoStatusBusiness.cs | 2 +- .../Domain/Business/SettingGeneralBusiness.cs | 11 + .../Exceptions/AppInfoNotEnabledException.cs | 9 + .../InvalidAppInfoStatusException.cs | 9 +- .../Properties/Resources.resx | 3 + .../Properties/Resources.zh-Hans.resx | 3 + .../Properties/Resources.zh-Hant.resx | 3 + .../Setting/GetSettingItemCountUseCase.cs | 3 - .../Properties/Resources.zh-Hans.resx | 24 +- .../Properties/Resources.zh-Hant.resx | 447 ++++++++++++++++-- .../Rest/ServiceCollectionExtensions.cs | 5 +- 15 files changed, 460 insertions(+), 72 deletions(-) create mode 100644 Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs index 6fad445..3792542 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs @@ -1,6 +1,4 @@ -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Application; +namespace Nerosoft.Starfish.Application; /// /// 删除配置节点命令 diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs b/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs index d21b639..ac9fbdb 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs @@ -1,6 +1,4 @@ -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Application; +namespace Nerosoft.Starfish.Application; /// /// 配置节点发布命令 diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs index 65ed58d..4de2c33 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs @@ -1,6 +1,4 @@ -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Application; +namespace Nerosoft.Starfish.Application; public class SettingUpdateCommand : SettingAbstractCommand { diff --git a/Source/Starfish.Service/Application/Implements/DictionaryApplicationService.cs b/Source/Starfish.Service/Application/Implements/DictionaryApplicationService.cs index 96afdbd..1f49f04 100644 --- a/Source/Starfish.Service/Application/Implements/DictionaryApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/DictionaryApplicationService.cs @@ -1,5 +1,4 @@ using Nerosoft.Euonia.Application; -using Nerosoft.Starfish.Domain; using Nerosoft.Starfish.Transit; namespace Nerosoft.Starfish.Application; diff --git a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs index 396e5ce..8637292 100644 --- a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs @@ -40,7 +40,7 @@ protected async Task ExecuteAsync(long id, AppStatus status, CancellationToken c break; case AppStatus.None: default: - throw new InvalidAppInfoStatusException(Resources.IDS_ERROR_APPINFO_STATUS_INVALID); + throw new ArgumentOutOfRangeException(Resources.IDS_ERROR_APPINFO_STATUS_INVALID); } await AppInfoRepository.UpdateAsync(aggregate, true, cancellationToken); diff --git a/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs index e7f8ec0..f89bdf8 100644 --- a/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs @@ -88,6 +88,17 @@ protected async Task FetchAsync(long appId, string environment, CancellationToke protected override async Task InsertAsync(CancellationToken cancellationToken = default) { var appInfo = await AppInfoRepository.GetAsync(AppId, cancellationToken); + + if (appInfo == null) + { + throw new AppInfoNotFoundException(AppId); + } + + if (appInfo.Status != AppStatus.Enabled) + { + throw new AppInfoNotEnabledException(AppId); + } + var aggregate = Setting.Create(AppId, Environment, Items); await SettingRepository.InsertAsync(aggregate, true, cancellationToken); Id = aggregate.Id; diff --git a/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs b/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs new file mode 100644 index 0000000..4323a70 --- /dev/null +++ b/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs @@ -0,0 +1,9 @@ +namespace Nerosoft.Starfish.Domain; + +public class AppInfoNotEnabledException : BadRequestException +{ + public AppInfoNotEnabledException(long appId) + : base(string.Format(Resources.IDS_ERROR_APPINFO_NOT_ENABLED, appId)) + { + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs b/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs index 32f0c90..7ff95d2 100644 --- a/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs +++ b/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs @@ -5,10 +5,11 @@ /// public class InvalidAppInfoStatusException : BadRequestException { - /// - /// 构造函数 - /// - /// + public InvalidAppInfoStatusException() + : base(Resources.IDS_ERROR_APPINFO_STATUS_INVALID) + { + } + public InvalidAppInfoStatusException(string message) : base(message) { diff --git a/Source/Starfish.Service/Properties/Resources.resx b/Source/Starfish.Service/Properties/Resources.resx index 10e1a50..226887b 100644 --- a/Source/Starfish.Service/Properties/Resources.resx +++ b/Source/Starfish.Service/Properties/Resources.resx @@ -159,6 +159,9 @@ App unique code is not available. + + App not enabled, [Id]:{0}. + App not exists, [Id]:{0}. diff --git a/Source/Starfish.Service/Properties/Resources.zh-Hans.resx b/Source/Starfish.Service/Properties/Resources.zh-Hans.resx index 4b2eb0c..ff081b8 100644 --- a/Source/Starfish.Service/Properties/Resources.zh-Hans.resx +++ b/Source/Starfish.Service/Properties/Resources.zh-Hans.resx @@ -159,6 +159,9 @@ 应用唯一编码不可用。 + + 应用没有启用,[Id]:{0}。 + 应用不存在,[Id]:{0}。 diff --git a/Source/Starfish.Service/Properties/Resources.zh-Hant.resx b/Source/Starfish.Service/Properties/Resources.zh-Hant.resx index e210119..2dd7315 100644 --- a/Source/Starfish.Service/Properties/Resources.zh-Hant.resx +++ b/Source/Starfish.Service/Properties/Resources.zh-Hant.resx @@ -139,6 +139,9 @@ 應用程式唯一代碼不可用。 + + 應用程式沒有啟用,[Id]:{0}。 + 應用程式不存在,[Id]:{0}。 diff --git a/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs b/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs index ad0673c..8684c14 100644 --- a/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs +++ b/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs @@ -1,8 +1,5 @@ using Nerosoft.Euonia.Application; -using Nerosoft.Euonia.Repository.EfCore; using Nerosoft.Starfish.Domain; -using Nerosoft.Starfish.Repository; -using Nerosoft.Starfish.Transit; namespace Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx index ef249f9..afa6e74 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx @@ -193,13 +193,13 @@ 修改时间 - 开发 + 开发环境 - 性能评估 + 性能评估测试 - 生产 + 生产环境 模拟测试 @@ -268,7 +268,7 @@ 操作时间 - 请求识别Id + 请求识别码 类型 @@ -289,7 +289,7 @@ 操作时间 - 请求跟踪Id + 请求识别码 类型 @@ -373,7 +373,7 @@ 发布 - 更新内容 + 发布内容 版本号 @@ -391,7 +391,7 @@ 数据库 - Redis Key名称 + Redis键名称 同步到Redis @@ -409,7 +409,7 @@ 确定要移除团队成员吗? - 移除成员 + 移除团队成员 团队别名 @@ -421,13 +421,13 @@ 团队名称 - 新增团队 + 新建团队 编辑团队 - 新增团队 + 新建团队 别名 @@ -445,10 +445,10 @@ 负责人 - 新增用户 + 新建用户 - 新增用户 + 新建用户 编辑用户 diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx index 4fdb1b6..8bd28e5 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx @@ -1,6 +1,6 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 應用代碼 + + + 應用描述 + + + 應用名稱 + + + 訪問密鑰 + + + 選擇所屬團隊 + + + 新增應用 + + + 編輯應用 + + + 新增 + + + 代碼 + + + 姓名 + + + 狀態 + + + 確定要刪除此應用“{0}”嗎? + + + 刪除應用 + + + 存取密鑰將被加密儲存且無法解密,請自行保管。 如果忘記密鑰,請重新設定。 + + + 重置密鑰 + + + 應用詳情 + + + 應用配置 + + + 團隊詳情 + + + 用戶詳情 + + + 取消 + + + 關閉 + + + 操作 + + + 創建時間 + + + Id + + + 修改時間 + + + 開發環境 + + + 性能評估測試 + + + 生產環境 + + + 模擬測試 + + + 系統整合測試 + + + 用戶驗收測試 + + + 登出 + + + + + + 操作 + + + 輸入關鍵字搜尋 + + + 保存 + + + 搜尋 + + + 提交 + + + + + + 登入 + + + 登入 + + + 請輸入密碼 + + + 請輸入用戶名 + + + 驗證碼登錄 + + + 用戶名登錄 + + + 日誌詳情 + + + 日誌內容 + + + 錯誤訊息 + + + 模塊 + + + 操作時間 + + + 請求識別碼 + + + 類型 + + + 用戶名 + + + 查看詳情 + + + 日誌內容 + + + 錯誤訊息 + + + 操作時間 + + + 請求識別碼 + + + 類型 + + + 用戶名 + + + 應用 + + + 首頁 + + + 日志 + + + 團隊 + + + 用戶 + + + 共 <strong>{0}</strong> 條 + + + 注冊 + + + 確認密碼 + + + 電子郵件 + + + 顯示的名稱 + + + 密碼 + + + 手機號碼 + + + 用戶名 + + + 從Json創建 + + + 從文本創建 + + + 編輯Json + + + 編輯文字 + + + 編輯配置 + + + 應用環境 + + + 刪除 + + + 編輯Json + + + 編輯文本 + + + 發布配置 + + + 同步到Redis + + + 發布 + + + 發布內容 + + + 版本號 + + + 發佈配置 + + + 開始同步 + + + 連接字串 + + + 數據庫 + + + Redis鍵名稱 + + + 同步到Redis + + + 添加成員 + + + 添加成員 + + + 編輯 + + + 確定要移除團隊成員嗎? + + + 移除團隊成員 + + + 團隊別名 + + + 團隊介紹 + + + 團隊名稱 + + + 新建團隊 + + + 編輯團隊 + + + 新建團隊 + + + 別名 + + + 描述 + + + 成員數 + + + 名稱 + + + 負責人 + + + 新建用戶 + + + 新建用戶 + + + 編輯用戶 + + + 電子郵件 + + + 昵稱 + + + 手機號碼 + + + 角色 + + + 用戶名 + + + 確認密碼 + + + 電子郵件 + + + 昵稱 + + + 密碼 + + + 用戶名 + \ No newline at end of file diff --git a/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs b/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs index 7f92c4d..549df2b 100644 --- a/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs +++ b/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ -using System.Net; +using System.Diagnostics.CodeAnalysis; +using System.Net; using System.Net.Sockets; using Microsoft.Extensions.Options; using Polly; @@ -77,11 +78,13 @@ private static TService GetRestService(this IServiceProvider provider, return RestService.For(client, _refitSettings); } + [SuppressMessage("ReSharper", "UnusedMember.Local")] private static IAsyncPolicy GetTimeoutPolicy() { return Policy.TimeoutAsync(TimeSpan.FromSeconds(15)); } + [SuppressMessage("ReSharper", "UnusedMember.Local")] private static IAsyncPolicy GetRetryPolicy() { return HttpPolicyExtensions.HandleTransientHttpError() From bc847182753a68c84885fdf514f53cdac977135c Mon Sep 17 00:00:00 2001 From: damon Date: Wed, 24 Jan 2024 23:50:03 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9format=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/ApplicationServiceModule.cs | 14 ++------------ .../Contracts/ISettingApplicationService.cs | 10 +++++++++- .../Implements/SettingApplicationService.cs | 9 +++++---- Source/Starfish.Webapi/Constants.cs | 6 ++++++ .../Controllers/SettingController.cs | 4 ++-- Source/Starfish.Webapp/Seedwork/Constants.cs | 11 ++++++++--- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Source/Starfish.Service/Application/ApplicationServiceModule.cs b/Source/Starfish.Service/Application/ApplicationServiceModule.cs index 4e072b9..cd10f2a 100644 --- a/Source/Starfish.Service/Application/ApplicationServiceModule.cs +++ b/Source/Starfish.Service/Application/ApplicationServiceModule.cs @@ -45,18 +45,8 @@ public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddSingleton(); - context.Services.AddSingleton(); - context.Services.AddSingleton(); - - context.Services.AddNamedService((name, provider) => - { - return name switch - { - "json" => provider.GetService(), - "text" => provider.GetService(), - _ => throw new NotSupportedException() - }; - }); + context.Services.AddKeyedSingleton("json"); + context.Services.AddKeyedSingleton("text"); ConfigureCachingServices(context.Services); diff --git a/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs b/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs index e039b65..ae69ccb 100644 --- a/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs +++ b/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs @@ -98,5 +98,13 @@ public interface ISettingApplicationService : IApplicationService /// Task GetSettingRawAsync(long appId, string environment, CancellationToken cancellationToken = default); - Task GetItemsInTextAsync(long appId, string environment, string type, CancellationToken cancellationToken = default); + /// + /// 获取指定格式的配置 + /// + /// + /// + /// + /// + /// + Task GetItemsInTextAsync(long appId, string environment, string format, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs b/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs index 02af483..65492b9 100644 --- a/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using Nerosoft.Euonia.Application; +using Nerosoft.Euonia.Application; using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Transit; using Nerosoft.Starfish.UseCases; @@ -85,9 +84,11 @@ public Task GetSettingRawAsync(long appId, string environment, Cancellat .ContinueWith(t => t.Result.Result, cancellationToken); } - public Task GetItemsInTextAsync(long appId, string environment, string type, CancellationToken cancellationToken = default) + /// + public Task GetItemsInTextAsync(long appId, string environment, string format, CancellationToken cancellationToken = default) { - var parser = LazyServiceProvider.GetRequiredService().GetNamedService(type.ToLower(CultureInfo.CurrentCulture)); + var parser = LazyServiceProvider.GetRequiredService() + .GetKeyedService(format.Normalize(TextCaseType.Lower)); return GetItemListAsync(appId, environment, 0, int.MaxValue, cancellationToken) .ContinueWith(task => { diff --git a/Source/Starfish.Webapi/Constants.cs b/Source/Starfish.Webapi/Constants.cs index b74e8ff..0ca17c4 100644 --- a/Source/Starfish.Webapi/Constants.cs +++ b/Source/Starfish.Webapi/Constants.cs @@ -15,4 +15,10 @@ public static class Query public const int Skip = 0; public const int Count = 20; } + + public static class Setting + { + public const string FormatJson = "plain/json"; + public const string FormatText = "plain/text"; + } } \ No newline at end of file diff --git a/Source/Starfish.Webapi/Controllers/SettingController.cs b/Source/Starfish.Webapi/Controllers/SettingController.cs index 8e10ba5..7616512 100644 --- a/Source/Starfish.Webapi/Controllers/SettingController.cs +++ b/Source/Starfish.Webapi/Controllers/SettingController.cs @@ -40,10 +40,10 @@ public async Task GetItemListAsync(long id, string environment, i { switch (format) { - case "text/plain": + case Constants.Setting.FormatText: var text = await _service.GetItemsInTextAsync(id, environment, "text", HttpContext.RequestAborted); return Ok(text); - case "text/json": + case Constants.Setting.FormatJson: var json = await _service.GetItemsInTextAsync(id, environment, "json", HttpContext.RequestAborted); return Ok(json); default: diff --git a/Source/Starfish.Webapp/Seedwork/Constants.cs b/Source/Starfish.Webapp/Seedwork/Constants.cs index 7d1a9a5..b9fcf66 100644 --- a/Source/Starfish.Webapp/Seedwork/Constants.cs +++ b/Source/Starfish.Webapp/Seedwork/Constants.cs @@ -13,10 +13,15 @@ public static class Query public const int Skip = 0; public const int Count = 20; } - + public static class Setting { - public const string FormatJson = "text/json"; - public const string FormatText = "text/plain"; + public const string FormatJson = "plain/json"; + public const string FormatText = "plain/text"; + } + + public static class Message + { + public const string ExceptionThrown = "exception_thrown"; } } \ No newline at end of file From a9403edc6941c2de84474ce40c8bc9934a6829b8 Mon Sep 17 00:00:00 2001 From: damon Date: Wed, 24 Jan 2024 23:50:22 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Starfish.Webapp/Properties/Resources.resx | 6 ++++++ Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx | 6 ++++++ Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/Source/Starfish.Webapp/Properties/Resources.resx b/Source/Starfish.Webapp/Properties/Resources.resx index f5d0b22..3f3b178 100644 --- a/Source/Starfish.Webapp/Properties/Resources.resx +++ b/Source/Starfish.Webapp/Properties/Resources.resx @@ -336,6 +336,12 @@ User name + + Are you sure delete this setting? + + + Delete setting + Create from Json diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx index afa6e74..89df8b6 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx @@ -336,6 +336,12 @@ 用户名 + + 确定要删除配置吗? + + + 删除配置 + 从Json创建 diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx index 8bd28e5..08130cd 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx @@ -316,6 +316,12 @@ 用戶名 + + 確定要刪除配置嗎? + + + 刪除配置 + 從Json創建 From 721bd76e7884067922f37c182ab8cec421641c60 Mon Sep 17 00:00:00 2001 From: damon Date: Wed, 24 Jan 2024 23:50:43 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 94970bd..5fcb780 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ Starfish是一个轻量但功能强大的分布式 .NET 应用程序配置中心 > 💚 Completed/已完成 ⌛ In progress/进行中 🕝 Planned/计划中 - [ ] ⌛ Support multiple data sources/支持多种数据源 - - [ ] ⌛ MySQL + - [x] 💚 MySQL - [ ] ⌛ SqlServer - [ ] ⌛ PostgreSQL - [ ] 🕝 MongoDB - - [ ] ⌛ Sqlite + - [x] 💚 Sqlite - [ ] ⌛ Support multiple platforms/支持多种平台 - [x] 💚 Web API/Web Application/gRPC Service in .NET6/7/8 - [x] 💚 .NET MAUI @@ -36,7 +36,7 @@ Starfish是一个轻量但功能强大的分布式 .NET 应用程序配置中心 - [ ] ⌛ Support multiple languages admin panel/支持多语言管理面板 - [x] 💚 en/英语 - [x] 💚 zh-Hans/简体中文 - - [ ] 🕝 zh-Hant/繁体中文 + - [ ] ⌛ zh-Hant/繁体中文 ## 💰 Donate/捐助 @@ -72,10 +72,6 @@ This project is licensed under the AGPL-3.0 License - see the [LICENSE](LICENSE) ``` Starfish -├──Sample -├ ├──Starfish.Sample.Blazor -├ ├──Starfish.Sample.MauiApp -├ ├──Starfish.Sample.Webapi ├──Source ├ ├──Starfish.Client ├ ├──Starfish.Common