agiledon / eas-ddd Goto Github PK
View Code? Open in Web Editor NEWddd demo of eas
License: Apache License 2.0
ddd demo of eas
License: Apache License 2.0
组合任务,由LearningService
承担,分解的任务为:
该组合任务的两个原子任务都会访问数据库,由Repository完成,故而无需针对这两个原子任务进行测试驱动开发。
时序图脚本如下:
LearningService.beLearned(candidateId, trainingId) {
TrainingRepository.trainingOf(trainingId);
LearningRepository.isExist(candidateId, courseId);
}
为新员工生成一个唯一的员工号。员工号的生成规则为:
{入职日期}-{4位顺序号}
说明:
例如入职日期为2019年12月24日,最近入职员工的顺序号为0101,则新生成的员工号为:201912240102
作为一名HR,
我希望办理员工入职,
以便于提供更好的员工管理与服务。
任务分解为:
时序图伪代码为:
EmployeeAppService.onboarding(OnboardingRequest) {
OnboardingRequestAssembler.composeEmployee() {
OnboardingRequest.toEmployee();
EmployeeIdGenerator.generate() {
EmployeeRepository.latestEmployee();
employee.idFrom(sequenceCode);
}
}
EmployeeService.onboarding(employee) {
EmployeeRepository.isExist(idNumber, mobilePhone);
EmployeeRepository.save(employee);
}
}
**说明:**需求分析与领域模型参见本项目的Wiki
根据员工考勤记录、请假情况、假日设置确定员工的出勤状况。测试用例包括:
由IssueService
领域服务承担职责,其子任务包括:
伪代码:
IssueService.assign(issueId, owner) {
Issue issue = IssueRepository.issueOf(issueId);
issue.assignTo(ownerId);
IssueRepository.update(issue);
ChangeHistoryRepository.add(changeHistory);
}
对于Issue
的assignTo
方法,需要编写测试用例覆盖:
Resolved
或Closed
的Issue不能再分配作为一名人事管理专员,
我希望系统能够生成出勤记录,
以便于及时对员工进行考勤。
任务分解为:
时序图脚本为:
AttendanceAppService.generate(day) {
AttendancesGenerator.generate(day) {
List<String> eployeeIds = EmployeeClient.allEmployeeIds();
for (String empId : employeeIds) {
AttendanceGenerator.generate(empId, day) {
TimeCardGenerator.generate(empId, day) {
PunchedCardRepository.punchedCardsOf(empId, day);
TimeCard.createFrom(List<PunchedCard>);
}
WorktimeRule worktimeRule = WorktimeRuleRepository.worktimeRule();
boolean isHoliday = HolidayRepository.isHoliday(day);
Leave leave = LeaveRepository.leaveOf(empId, day);
Attendance.assureStatus(timeCard, worktimeRule, leave, isHoliday);
}
}
AttendanceRepository.saveAll(attendances);
}
}
**说明:**该Story的需求说明与领域模型参见本项目的Wiki页面
As 一名培训学员
I want to 签到
So that 记录我已正常出勤
场景1:学员签到
Given:拥有Confirmed状态的培训票的学员
And: 培训已经开始
When: 签到
Then: 记录学员的出勤信息
And: 培训票被设置为Closed状态
And: 记录学员的学习信息
时序图脚本:
TrainingAppService.checkIn(checkInRequest) {
CheckInService.checkIn(traineeId, trainingId) {
TicketRepository.ticketOf(traineeId, trainingId, ticketStatus);
Ticket.checkIn();
TicketRepository.update(ticket);
AttendanceRepository.add(attendance);
LearningService.append(trainee, trainingId) {
CourseRepository.courseOf(trainingId);
LearningRepository.add(learning);
}
}
}
组合任务,由TicketService
领域服务承担,任务分解为:
“提名”原子任务,由Ticket
聚合根实体承担。该任务的测试用例包括:
As 一名协调者
I want to 提名候选人参加培训
So that 部门的员工得到技能培训的机会
场景1:候选人获得提名
Given:从候选人名单中选择要提名的候选人
And: 选择要提名的培训票
When: 提名候选人
Then: 培训票被设置为WaitForConfirm状态
And: 该培训票不可再被提名
And: 候选人将收到培训提名的邮件通知
场景2:候选人参加过该课程
Given:从候选人名单中选择要提名的候选人
And: 该候选人已经参加过该培训要学习的课程
And: 选择要提名的培训票
When: 提名候选人
Then: 提示该候选人已经参加过该课程
And: 提名失败
And: 培训票仍然处于Available状态
时序图脚本为:
NominationAppService.nominate(nominationRequest) {
NominationService.nominate(ticketId, candidate) {
LearningService.beLearned(candidateId, trainingId) {
TrainingRepository.trainingOf(trainingId);
LearningRepository.isExist(candidateId, courseId);
}
TicketService.nominate(ticketId, candidate) {
TicketRepository.ticketOf(ticketId);
Ticket.nominate(candidate);
TicketRepository.update(ticket);
}
NotificationService.notifyNominee(ticket, nominee) {
MailTemplateRepository.templateOf(templateType);
MailTemplate.compose(ticket, nominee);
NotificationClient.notify(notificationRequest);
}
}
}
当Issue被分配给Owner后,需要发送通知给该Issue的Owner和Reporter。任务为:
伪代码:
NotificationService.notifyOwner(issue, owner) {
AssignmentNotification notification = AssignmentNotification.forOwner(issue, owner);
NotificationClient.notify(NotificationRequest.from(notification));
}
NotificationService.notifyReporter(issue) {
EmployeeResponse empResponse = EmployeeClient.employeeOf(reporterId);
AssignmentNotification notification = AssignmentNotification.forReporter(issue, empResponse.toReporter());
NotificationClient.notify(NotificationRequest.from(notification));
}
``
由领域服务AttendanceGenerator
承担,其子任务包括:
伪代码为:
AttendanceGenerator.generate(empId, day) {
TimeCard timeCard = TimeCardRepository.timeCardOf(empId, day);
Worktime worktime = Worktime.worktime();
boolean isHoliday = HolidayRepository.isHoliday(day);
Leave leave = LeaveRepository.leaveOf(empId, day);
Attendance.assureStatus(timeCard, worktime, leave, isHoliday);
}
组合任务,由NotificationService
领域服务履行职责。分解的任务为:
“组装提名通知内容”原子任务由MailTemplate
聚合履行,时序图脚本如下:
NotificationService.notifyNominee(ticket, nominee) {
MailTemplateRepository.templateOf(templateType);
MailTemplate.compose(ticket, nominee);
NotificationClient.notify(notificationRequest);
}
提名邮件的类型为MeetingRequest,邮件模板内容为:
Hi
We are glad to notify that you are nominated by
Here is the basic information of training:
Title:
Description:
Begin time: $dbeginTime$
End time:
Place:
Thanks! We're excited to have you in the training.
EAS Team
办理员工入职由EmployeeService
领域服务承担,子任务为:
伪代码:
EmployeeService.onboarding(employee) {
EmployeeRepository.isExist(idNumber, mobilePhone);
EmployeeRepository.save(employee);
}
验证的员工信息包括:
作为一名项目管理成员
我希望将问题分配给指定项目成员
以便于确定问题的负责人进行进度跟踪
分解的任务为:
领域场景的时序图伪代码为:
IssueAppService.assign(issueId, owner) {
IssueService.assign(issueId, owner) {
Issue issue = IssueRepository.issueOf(issueId);
issue.assignTo(ownerId);
IssueRepository.update(issue);
ChangeHistoryRepository.add(changeHistory);
NotificationService.notifyOwner(issue, owner) {
AssignmentNotification notification = AssignmentNotification.forOwner(issue, owner);
NotificationClient.notify(NotificationRequest.from(notification));
}
NotificationService.notifyReporter(issue) {
EmployeeResponse empResponse = EmployeeClient.employeeOf(reporterId);
AssignmentNotification notification = AssignmentNotification.forReporter(issue, empResponse.toReporter());
NotificationClient.notify(NotificationRequest.from(notification));
}
}
}
将应用服务接收的消息OnBoardingRequest
转换为Employee
领域对象,由OnboardingRequestAssembler
装配器承担。子任务包括:
Employee
对象伪代码为:
OnboardingRequestAssembler.composeEmployee() {
OnboardingRequest.toEmployee(employeeId);
EmployeeIdGenerator.generate() {
EmployeeRepository.latestEmployee();
employee.idFrom(sequenceCode);
}
}
生成员工号由领域服务EmployeeIdGenerator
承担,它的子任务为:
根据员工的打卡记录生成员工的工作时间(TimeCard)。需要考虑多种情况(这里规则做了一定程度简化):
根据trainingId查询培训信息。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.