f
This commit is contained in:
@@ -119,6 +119,58 @@ func NewContractInfo(enterpriseInfoID, userID, contractName string, contractType
|
||||
return contractInfo, nil
|
||||
}
|
||||
|
||||
// NewContractInfoWithContractCode 使用指定合同编号创建合同信息(与认证阶段生成的编号一致)
|
||||
func NewContractInfoWithContractCode(enterpriseInfoID, userID, contractName string, contractType ContractType, contractFileID, contractFileURL, contractCode string) (*ContractInfo, error) {
|
||||
if enterpriseInfoID == "" {
|
||||
return nil, fmt.Errorf("企业信息ID不能为空")
|
||||
}
|
||||
if userID == "" {
|
||||
return nil, fmt.Errorf("用户ID不能为空")
|
||||
}
|
||||
if contractName == "" {
|
||||
return nil, fmt.Errorf("合同名称不能为空")
|
||||
}
|
||||
if contractType == "" {
|
||||
return nil, fmt.Errorf("合同类型不能为空")
|
||||
}
|
||||
if contractFileID == "" {
|
||||
return nil, fmt.Errorf("合同文件ID不能为空")
|
||||
}
|
||||
if contractFileURL == "" {
|
||||
return nil, fmt.Errorf("合同文件URL不能为空")
|
||||
}
|
||||
if contractCode == "" {
|
||||
return nil, fmt.Errorf("合同编号不能为空")
|
||||
}
|
||||
if !isValidContractType(contractType) {
|
||||
return nil, fmt.Errorf("无效的合同类型: %s", contractType)
|
||||
}
|
||||
|
||||
contractInfo := &ContractInfo{
|
||||
ID: uuid.New().String(),
|
||||
EnterpriseInfoID: enterpriseInfoID,
|
||||
UserID: userID,
|
||||
ContractCode: contractCode,
|
||||
ContractName: contractName,
|
||||
ContractType: contractType,
|
||||
ContractFileID: contractFileID,
|
||||
ContractFileURL: contractFileURL,
|
||||
domainEvents: make([]interface{}, 0),
|
||||
}
|
||||
|
||||
contractInfo.addDomainEvent(&ContractInfoCreatedEvent{
|
||||
ContractInfoID: contractInfo.ID,
|
||||
EnterpriseInfoID: enterpriseInfoID,
|
||||
UserID: userID,
|
||||
ContractCode: contractCode,
|
||||
ContractName: contractName,
|
||||
ContractType: string(contractType),
|
||||
CreatedAt: time.Now(),
|
||||
})
|
||||
|
||||
return contractInfo, nil
|
||||
}
|
||||
|
||||
// ================ 聚合根核心方法 ================
|
||||
|
||||
// UpdateContractInfo 更新合同信息
|
||||
|
||||
Reference in New Issue
Block a user