Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
日本語の概要は準備中です。原文の説明を表示しています。
ABP Framework domain layer patterns including entities, aggregates, repositories, domain services, and data seeding. Use when: (1) creating entities with proper base classes, (2) implementing custom repositories, (3) writing domain services, (4) seeding data.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Domain layer patterns for ABP Framework following DDD principles.
Domain.Shared → Constants, enums, shared types
Domain → Entities, repositories, domain services, domain events
Application.Contracts → DTOs, application service interfaces
Application → Application services, mapper profiles
EntityFrameworkCore → DbContext, repository implementations
HttpApi → Controllers
HttpApi.Host → Startup, configuration
Key principle: Dependencies flow downward. Application depends on Domain, but Domain never depends on Application.
| Base Class | Use When |
|---|---|
Entity<TKey> | Simple entity, no auditing |
AuditedEntity<TKey> | Need creation/modification tracking |
FullAuditedEntity<TKey> | Need soft delete + full audit |
AggregateRoot<TKey> | Root entity of an aggregate |
FullAuditedAggregateRoot<TKey> | Most common - full features |
public class Patient : FullAuditedAggregateRoot<Guid>
{
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string Email { get; private set; }
public DateTime DateOfBirth { get; private set; }
public bool IsActive { get; private set; }
// Required for EF Core
protected Patient() { }
// Constructor with validation
public Patient(
Guid id,
string firstName,
string lastName,
string email,
DateTime dateOfBirth)
: base(id)
{
SetName(firstName, lastName);
SetEmail(email);
DateOfBirth = dateOfBirth;
IsActive = true;
}
// Domain methods with validation
public void SetName(string firstName, string lastName)
{
FirstName = Check.NotNullOrWhiteSpace(firstName, nameof(firstName), maxLength: 100);
LastName = Check.NotNullOrWhiteSpace(lastName, nameof(lastName), maxLength: 100);
}
public void SetEmail(string email)
{
Email = Check.NotNullOrWhiteSpace(email, nameof(email), maxLength: 256);
}
public void Activate() => IsActive = true;
public void Deactivate() => IsActive = false;
}
public class Patient : FullAuditedAggregateRoot<Guid>, ISoftDelete
{
public bool IsDeleted { get; set; }
// ABP automatically filters out soft-deleted entities
}
public class Patient : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
// ABP automatically filters by current tenant
}
FullAuditedAggregateRoot<Guid> provides:
CreationTime, CreatorIdLastModificationTime, LastModifierIdIsDeleted, DeletionTime, DeleterIdpublic class PatientAppService : ApplicationService
{
private readonly IRepository<Patient, Guid> _patientRepository;
public PatientAppService(IRepository<Patient, Guid> patientRepository)
{
_patientRepository = patientRepository;
}
public async Task<PatientDto> GetAsync(Guid id)
{
var patient = await _patientRepository.GetAsync(id);
return ObjectMapper.Map<Patient, PatientDto>(patient);
}
public async Task<PagedResultDto<PatientDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
var totalCount = await _patientRepository.GetCountAsync();
var queryable = await _patientRepository.GetQueryableAsync();
var patients = await AsyncExecuter.ToListAsync(
queryable
.OrderBy(input.Sorting ?? nameof(Patient.FirstName))
.PageBy(input.SkipCount, input.MaxResultCount));
return new PagedResultDto<PatientDto>(
totalCount,
ObjectMapper.Map<List<Patient>, List<PatientDto>>(patients));
}
}
Define interface in Domain layer:
public interface IPatientRepository : IRepository<Patient, Guid>
{
Task<List<Patient>> GetActivePatientsByDoctorAsync(Guid doctorId);
Task<Patient?> FindByEmailAsync(string email);
}
Implement in EntityFrameworkCore layer:
public class PatientRepository : EfCoreRepository<ClinicDbContext, Patient, Guid>, IPatientRepository
{
public PatientRepository(IDbContextProvider<ClinicDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async Task<List<Patient>> GetActivePatientsByDoctorAsync(Guid doctorId)
{
var dbSet = await GetDbSetAsync();
return await dbSet
.Where(p => p.PrimaryDoctorId == doctorId && p.IsActive)
.Include(p => p.Appointments)
.ToListAsync();
}
public async Task<Patient?> FindByEmailAsync(string email)
{
var dbSet = await GetDbSetAsync();
return await dbSet.FirstOrDefaultAsync(p => p.Email == email);
}
}
Use domain services when business logic involves multiple entities or external domain concepts.
public class AppointmentManager : DomainService
{
private readonly IRepository<Appointment, Guid> _appointmentRepository;
private readonly IRepository<DoctorSchedule, Guid> _scheduleRepository;
public AppointmentManager(
IRepository<Appointment, Guid> appointmentRepository,
IRepository<DoctorSchedule, Guid> scheduleRepository)
{
_appointmentRepository = appointmentRepository;
_scheduleRepository = scheduleRepository;
}
public async Task<Appointment> CreateAsync(
Guid patientId,
Guid doctorId,
DateTime appointmentDate,
string description)
{
// Business rule: Check if doctor is available
await CheckDoctorAvailabilityAsync(doctorId, appointmentDate);
// Business rule: Check for conflicts
await CheckAppointmentConflictsAsync(doctorId, appointmentDate);
var appointment = new Appointment(
GuidGenerator.Create(),
patientId,
doctorId,
appointmentDate,
description);
return await _appointmentRepository.InsertAsync(appointment);
}
private async Task CheckDoctorAvailabilityAsync(Guid doctorId, DateTime appointmentDate)
{
var schedule = await _scheduleRepository.FirstOrDefaultAsync(
s => s.DoctorId == doctorId && s.DayOfWeek == appointmentDate.DayOfWeek);
if (schedule == null)
throw new BusinessException("Doctor not available on this day");
var timeOfDay = appointmentDate.TimeOfDay;
if (timeOfDay < schedule.StartTime || timeOfDay > schedule.EndTime)
throw new BusinessException("Doctor not available at this time");
}
private async Task CheckAppointmentConflictsAsync(Guid doctorId, DateTime appointmentDate)
{
var hasConflict = await _appointmentRepository.AnyAsync(a =>
a.DoctorId == doctorId &&
a.AppointmentDate == appointmentDate &&
a.Status != AppointmentStatus.Cancelled);
if (hasConflict)
throw new BusinessException("Doctor already has an appointment at this time");
}
}
public class ClinicDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IRepository<Doctor, Guid> _doctorRepository;
private readonly IGuidGenerator _guidGenerator;
public ClinicDataSeedContributor(
IRepository<Doctor, Guid> doctorRepository,
IGuidGenerator guidGenerator)
{
_doctorRepository = doctorRepository;
_guidGenerator = guidGenerator;
}
public async Task SeedAsync(DataSeedContext context)
{
// Idempotent check
if (await _doctorRepository.GetCountAsync() > 0)
return;
var doctors = new List<Doctor>
{
new Doctor(_guidGenerator.Create(), "Dr. Smith", "Cardiology", "smith@clinic.com"),
new Doctor(_guidGenerator.Create(), "Dr. Jones", "Pediatrics", "jones@clinic.com"),
};
foreach (var doctor in doctors)
{
await _doctorRepository.InsertAsync(doctor);
}
}
}
public class ClinicTestDataSeedContributor : IDataSeedContributor, ITransientDependency
{
public static readonly Guid TestPatientId = Guid.Parse("2e701e62-0953-4dd3-910b-dc6cc93ccb0d");
public static readonly Guid TestDoctorId = Guid.Parse("3a801f73-1064-5ee4-a21c-ed7dd4ddc1e");
public async Task SeedAsync(DataSeedContext context)
{
await _patientRepository.InsertAsync(new Patient(
TestPatientId, "Test", "Patient", "test@example.com", DateTime.Now.AddYears(-30)));
await _doctorRepository.InsertAsync(new Doctor(
TestDoctorId, "Test Doctor", "General", "doctor@example.com"));
}
}
abp-service-patterns - Application layer patternsabp-infrastructure-patterns - Cross-cutting concernsefcore-patterns - Database configurationまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
日本語の概要は準備中です。原文の説明を表示しています。
在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。
日本語の概要は準備中です。原文の説明を表示しています。
Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.
日本語の概要は準備中です。原文の説明を表示しています。
Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.
日本語の概要は準備中です。原文の説明を表示しています。
Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.
日本語の概要は準備中です。原文の説明を表示しています。
[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.
日本語の概要は準備中です。原文の説明を表示しています。