我正在建设ParkingReservation在DDD,简而言之,人们可以邀请地点和当汽车进入相机识别模型和更新的地方的状态。
我将模型划分为三个有界的上下文:
第一个是保留上下文,它包括以下对象:
`public class Lot
{
public int ID { get; set; }
public string Name { get; set; }
public Address Address { get; set; }
public List<Place> Places { get; set; }
}
public class Place
{
public int ID { get; set; }
public int FloorNumber { get; set; }
public int RowNumber { get; set; }
public int ParkingNumber { get; set; }
}
public class Car
{
public int ID { get; set; }
public string Model { get; set; }
}
public class Driver
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public int Age { get; set; }
public Gender Gender { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public bool AcceptAdsToMail { get; set; }
public byte[] PictureData { get; set; }
public DateTime RegistrationTime { get; set; }
public DriverStatuses DriverStatuses { get; set; }
}
public class Reservation
{
public int ID { get; set; }
public Driver Driver { get; set; }
public Car Car { get; set; }
public Place Place { get; set; }
public DateTime OrderTime { get; set; }
public DateTime ParkingStartTime { get; set; }
public DateTime ParkingEndTime { get; set; }
public ParkingStatuses ParkingStatus { get; set; }
}
public class ParkingHistory
{
public int ID { get; set; }
public Place Place { get; set; }
public Driver Driver { get; set; }
public Car Car { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}`停车场有一系列的停车位。
司机通过申请预留位置。
保存在预订对象中的保存位置,当停车时间过去时,新的parkinghistory添加到属于司机和汽车的parkinghistories列表中,以便您可以查看每辆汽车或司机的历史记录。
关于保留的这一情况:
(1)将驱动程序和总根保留是否正确?也可能是很多吗?
(2)场所是实体还是价值客体?
谢谢
发布于 2017-09-04 03:08:13
用例的主要目标是调度。你需要考虑一下围绕这个想法的一致性边界。为了避免很多地方的时隙重叠,您需要为此目的创建一个新的抽象。"PlaceInLotReservations“听起来是一个很好的选项,可以作为一个值对象作为一个预订聚合的工厂。为了表示调度工作的实际情况,您应该在一天的上下文中为该集合提供数据,因此"PlaceInLotReservationsRepository“应该有一个"findByDate”方法,该方法收集给定日期时间中某个位置的所有保留。所以语义应该是这样的:
val placeInLotReservations = PlaceInLotReservationsRepository.findBy(datetime)
val reservation = placeInLotReservations.reserveFor(car, driver, startingTime, endingTime)
ReservationsRepository.save(reservation)如果在一个地方有很多预订,所以比赛条件,你甚至可以通过通过日宿舍,而不是一天的第一次查找,使VO更小。
顺便说一下,can和驱动程序是预订聚合上下文中的VOs (它们不是聚合体)。您也可以通过查询预订存储库来获得历史记录,您不需要ParkingHistory。
希望能帮上忙。
https://stackoverflow.com/questions/46021411
复制相似问题