-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from fluentcms/112-refactor-project-architect…
…ure-based-on-tech-meeting Refactor project architecture based on tech meeting
- Loading branch information
Showing
74 changed files
with
926 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace FluentCMS.Application.Dtos; | ||
public class PagingRequest | ||
{ | ||
public int PageIndex { get; set; } | ||
public int PageSize { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace FluentCMS.Application.Dtos; | ||
public class PagingResponse<TData> | ||
{ | ||
public IEnumerable<TData> Data { get; set; } = new List<TData>(); | ||
public long Total { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Sites; | ||
|
||
public class AddSiteUrlRequest | ||
{ | ||
public Guid SiteId { get; set; } | ||
public string NewUrl { get; set; } = ""; | ||
} | ||
|
||
public class AddSiteUrlRequestValidator : AbstractValidator<AddSiteUrlRequest> | ||
{ | ||
public AddSiteUrlRequestValidator() | ||
{ | ||
RuleFor(x => x.SiteId).NotEmpty(); | ||
RuleFor(x => x.NewUrl).NotEmpty().MaximumLength(50); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Sites; | ||
|
||
public class CreateSiteRequest | ||
{ | ||
public string Name { get; set; } = ""; | ||
public string Description { get; set; } = ""; | ||
public string[] URLs { get; set; } = []; | ||
public Guid RoleId { get; set; } | ||
} | ||
|
||
public class CreateSiteRequestValidator : AbstractValidator<CreateSiteRequest> | ||
{ | ||
public CreateSiteRequestValidator() | ||
{ | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(64); | ||
RuleFor(x => x.Description).MaximumLength(100).When(x => string.IsNullOrWhiteSpace(x.Description) == false); | ||
RuleFor(x => x.URLs).NotNull().Must(x => x.Any()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Sites; | ||
|
||
public class DeleteSiteRequest | ||
{ | ||
public Guid Id { get; set; } | ||
} | ||
|
||
public class DeleteSiteRequestValidator : AbstractValidator<DeleteSiteRequest> | ||
{ | ||
public DeleteSiteRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Sites; | ||
|
||
public class EditSiteRequest | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } = ""; | ||
public string Description { get; set; } = ""; | ||
public Guid RoleId { get; set; } | ||
public ICollection<string> URLs { get; set; } = new List<string>(); | ||
} | ||
|
||
public class EditSiteRequestValidator : AbstractValidator<EditSiteRequest> | ||
{ | ||
public EditSiteRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(64); | ||
RuleFor(x => x.Description).MaximumLength(100).When(x => string.IsNullOrWhiteSpace(x.Description) == false); | ||
RuleFor(x => x.URLs).NotNull().Must(x => x.Any()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/FluentCMS.Application/Dtos/Sites/RemoveSiteUrlRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Sites; | ||
|
||
public class RemoveSiteUrlRequest | ||
{ | ||
public Guid SiteId { get; set; } | ||
public string Url { get; set; } = ""; | ||
} | ||
|
||
public class RemoveSiteUrlRequestValidator : AbstractValidator<RemoveSiteUrlRequest> | ||
{ | ||
public RemoveSiteUrlRequestValidator() | ||
{ | ||
RuleFor(x => x.SiteId).NotEmpty(); | ||
RuleFor(x => x.Url).NotEmpty().MaximumLength(50); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace FluentCMS.Application.Dtos.Sites; | ||
public class SearchSiteRequest : PagingRequest | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace FluentCMS.Application.Dtos.Sites; | ||
public class SearchSiteResponse : PagingResponse<SiteDto> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace FluentCMS.Application.Dtos.Sites; | ||
public class SiteDto | ||
{ | ||
public Guid Id { get; set; } | ||
public string CreatedBy { get; set; } = ""; | ||
public DateTime CreatedAt { get; set; } = default; | ||
public string LastUpdatedBy { get; set; } = ""; | ||
public DateTime LastUpdatedAt { get; set; } = default; | ||
public string Name { get; set; } = ""; | ||
public string Description { get; set; } = ""; | ||
public List<string> Urls { get; set; } = []; | ||
public Guid RoleId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class CreateRoleRequest | ||
{ | ||
public string Name { get; set; } = string.Empty; | ||
public string? Description { get; set; } | ||
public bool AutoAssigned { get; set; } | ||
public Guid? SiteId { get; set; } | ||
} | ||
|
||
public class CreateRoleRequestValidator : AbstractValidator<CreateRoleRequest> | ||
{ | ||
public CreateRoleRequestValidator() | ||
{ | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(50); | ||
RuleFor(x => x.Description).MaximumLength(100).When(x => string.IsNullOrWhiteSpace(x.Description) == false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class CreateUserRequest | ||
{ | ||
public string Name { get; set; } = string.Empty; | ||
public string Username { get; set; } = string.Empty; | ||
public string Password { get; set; } = string.Empty; | ||
public ICollection<Guid> Roles { get; set; } = new List<Guid>(); | ||
} | ||
|
||
public class CreateUserRequestValidator : AbstractValidator<CreateUserRequest> | ||
{ | ||
public CreateUserRequestValidator() | ||
{ | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(64); | ||
RuleFor(x => x.Username).NotEmpty().MinimumLength(3).MaximumLength(50); | ||
RuleFor(x => x.Password).NotEmpty().MinimumLength(3).MaximumLength(50); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class DeleteRoleRequest | ||
{ | ||
public required Guid Id { get; set; } | ||
} | ||
|
||
public class DeleteRoleRequestValidator : AbstractValidator<DeleteRoleRequest> | ||
{ | ||
public DeleteRoleRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class DeleteUserRequest | ||
{ | ||
public Guid Id { get; set; } | ||
} | ||
|
||
public class DeleteUserRequestValidator : AbstractValidator<DeleteUserRequest> | ||
{ | ||
public DeleteUserRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class EditRoleRequest | ||
{ | ||
public required Guid Id { get; set; } | ||
public required string Name { get; set; } | ||
public string? Description { get; set; } | ||
public required bool AutoAssigned { get; set; } | ||
public Guid? SiteId { get; set; } | ||
} | ||
|
||
public class EditRoleRequestValidator : AbstractValidator<EditRoleRequest> | ||
{ | ||
public EditRoleRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(50); | ||
RuleFor(x => x.Description).MaximumLength(100).When(x => string.IsNullOrWhiteSpace(x.Description) == false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using FluentValidation; | ||
|
||
namespace FluentCMS.Application.Dtos.Users; | ||
|
||
public class EditUserRequest | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } = string.Empty; | ||
public string Username { get; set; } = string.Empty; | ||
public string Password { get; set; } = string.Empty; | ||
public ICollection<Guid> Roles { get; set; } = new List<Guid>(); | ||
} | ||
|
||
public class EditUserRequestValidator : AbstractValidator<EditUserRequest> | ||
{ | ||
public EditUserRequestValidator() | ||
{ | ||
RuleFor(x => x.Id).NotEmpty(); | ||
RuleFor(x => x.Name).NotEmpty().MaximumLength(50); | ||
RuleFor(x => x.Username).NotEmpty().MinimumLength(3).MaximumLength(50); | ||
RuleFor(x => x.Password).MinimumLength(3).MaximumLength(50) | ||
.When(x => string.IsNullOrWhiteSpace(x.Password) == false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class RoleDto | ||
{ | ||
public required Guid Id { get; set; } | ||
public required string CreatedBy { get; set; } | ||
public required DateTime CreatedAt { get; set; } | ||
public required string LastUpdatedBy { get; set; } | ||
public required DateTime LastUpdatedAt { get; set; } | ||
|
||
public required string Name { get; set; } | ||
public string? Description { get; set; } | ||
public required bool AutoAssigned { get; set; } | ||
|
||
public Guid? SiteId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class SearchRoleRequest : PagingRequest | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class SearchRoleResponse : PagingResponse<RoleDto> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class SearchUserRequest : PagingRequest | ||
{ | ||
public string? Name { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class SearchUserResponse : PagingResponse<UserDto> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace FluentCMS.Application.Dtos.Users; | ||
public class UserDto | ||
{ | ||
public required Guid Id { get; set; } | ||
public required string CreatedBy { get; set; } | ||
public required DateTime CreatedAt { get; set; } | ||
public required string LastUpdatedBy { get; set; } | ||
public required DateTime LastUpdatedAt { get; set; } | ||
|
||
public string Name { get; set; } = string.Empty; | ||
public string Username { get; set; } = string.Empty; | ||
|
||
public virtual IEnumerable<Guid> UserRoles { get; set; } = Enumerable.Empty<Guid>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using AutoMapper; | ||
using FluentCMS.Application.Dtos.Sites; | ||
using FluentCMS.Entities.Sites; | ||
|
||
namespace FluentCMS.Application.Mappings; | ||
internal class SiteMappings : Profile | ||
{ | ||
public SiteMappings() | ||
{ | ||
CreateMap<Site, SiteDto>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using AutoMapper; | ||
using FluentCMS.Application.Dtos.Users; | ||
using FluentCMS.Entities.Users; | ||
|
||
namespace FluentCMS.Application.Mappings; | ||
internal class UserMappingProfile : Profile | ||
{ | ||
public UserMappingProfile() | ||
{ | ||
CreateMap<User, UserDto>() | ||
.ForMember(x => x.UserRoles, cfg => cfg.MapFrom(y => y.UserRoles.Select(z => z.RoleId.ToString()))); | ||
|
||
CreateMap<Role, RoleDto>(); | ||
} | ||
} |
Oops, something went wrong.