创建批次时插入一条记录
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// PigBatchService 接口定义保持不变,继续作为应用层对外的契约。
|
||||
type PigBatchService interface {
|
||||
CreatePigBatch(dto *dto.PigBatchCreateDTO) (*dto.PigBatchResponseDTO, error)
|
||||
CreatePigBatch(operatorID uint, dto *dto.PigBatchCreateDTO) (*dto.PigBatchResponseDTO, error)
|
||||
GetPigBatch(id uint) (*dto.PigBatchResponseDTO, error)
|
||||
UpdatePigBatch(id uint, dto *dto.PigBatchUpdateDTO) (*dto.PigBatchResponseDTO, error)
|
||||
DeletePigBatch(id uint) error
|
||||
@@ -51,7 +51,7 @@ func (s *pigBatchService) toPigBatchResponseDTO(batch *models.PigBatch) *dto.Pig
|
||||
}
|
||||
|
||||
// CreatePigBatch 现在将请求委托给领域服务处理。
|
||||
func (s *pigBatchService) CreatePigBatch(dto *dto.PigBatchCreateDTO) (*dto.PigBatchResponseDTO, error) {
|
||||
func (s *pigBatchService) CreatePigBatch(operatorID uint, dto *dto.PigBatchCreateDTO) (*dto.PigBatchResponseDTO, error) {
|
||||
// 1. DTO -> 领域模型
|
||||
batch := &models.PigBatch{
|
||||
BatchNumber: dto.BatchNumber,
|
||||
@@ -62,7 +62,7 @@ func (s *pigBatchService) CreatePigBatch(dto *dto.PigBatchCreateDTO) (*dto.PigBa
|
||||
}
|
||||
|
||||
// 2. 调用领域服务
|
||||
createdBatch, err := s.domainService.CreatePigBatch(batch)
|
||||
createdBatch, err := s.domainService.CreatePigBatch(operatorID, batch)
|
||||
if err != nil {
|
||||
s.logger.Errorf("应用层: 创建猪批次失败: %v", err)
|
||||
return nil, mapDomainError(err)
|
||||
|
||||
Reference in New Issue
Block a user