add qygl23t7
This commit is contained in:
@@ -24,8 +24,6 @@ type EnterpriseInfo struct {
|
||||
LegalPersonID string `gorm:"type:varchar(50);not null" json:"legal_person_id" comment:"法定代表人身份证号"`
|
||||
LegalPersonPhone string `gorm:"type:varchar(50);not null" json:"legal_person_phone" comment:"法定代表人手机号"`
|
||||
EnterpriseAddress string `json:"enterprise_address" gorm:"type:varchar(200);not null" comment:"企业地址"`
|
||||
EnterpriseEmail string `json:"enterprise_email" gorm:"type:varchar(100);not null" comment:"企业邮箱"`
|
||||
|
||||
// 时间戳字段
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" comment:"创建时间"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" comment:"更新时间"`
|
||||
@@ -54,7 +52,7 @@ func (e *EnterpriseInfo) BeforeCreate(tx *gorm.DB) error {
|
||||
// ================ 工厂方法 ================
|
||||
|
||||
// NewEnterpriseInfo 创建新的企业信息
|
||||
func NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone,enterpriseAddress, enterpriseEmail string) (*EnterpriseInfo, error) {
|
||||
func NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone,enterpriseAddress string) (*EnterpriseInfo, error) {
|
||||
if userID == "" {
|
||||
return nil, fmt.Errorf("用户ID不能为空")
|
||||
}
|
||||
@@ -76,9 +74,6 @@ func NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName,
|
||||
if enterpriseAddress == "" {
|
||||
return nil, fmt.Errorf("企业地址不能为空")
|
||||
}
|
||||
if enterpriseEmail == "" {
|
||||
return nil, fmt.Errorf("企业邮箱不能为空")
|
||||
}
|
||||
|
||||
enterpriseInfo := &EnterpriseInfo{
|
||||
ID: uuid.New().String(),
|
||||
@@ -89,7 +84,6 @@ func NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName,
|
||||
LegalPersonID: legalPersonID,
|
||||
LegalPersonPhone: legalPersonPhone,
|
||||
EnterpriseAddress: enterpriseAddress,
|
||||
EnterpriseEmail: enterpriseEmail,
|
||||
domainEvents: make([]interface{}, 0),
|
||||
}
|
||||
|
||||
@@ -108,7 +102,7 @@ func NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName,
|
||||
// ================ 聚合根核心方法 ================
|
||||
|
||||
// UpdateEnterpriseInfo 更新企业信息
|
||||
func (e *EnterpriseInfo) UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error {
|
||||
func (e *EnterpriseInfo) UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error {
|
||||
// 验证输入参数
|
||||
if companyName == "" {
|
||||
return fmt.Errorf("企业名称不能为空")
|
||||
@@ -128,9 +122,6 @@ func (e *EnterpriseInfo) UpdateEnterpriseInfo(companyName, unifiedSocialCode, le
|
||||
if enterpriseAddress == "" {
|
||||
return fmt.Errorf("企业地址不能为空")
|
||||
}
|
||||
if enterpriseEmail == "" {
|
||||
return fmt.Errorf("企业邮箱不能为空")
|
||||
}
|
||||
|
||||
// 记录原始值用于事件
|
||||
oldCompanyName := e.CompanyName
|
||||
@@ -143,7 +134,6 @@ func (e *EnterpriseInfo) UpdateEnterpriseInfo(companyName, unifiedSocialCode, le
|
||||
e.LegalPersonID = legalPersonID
|
||||
e.LegalPersonPhone = legalPersonPhone
|
||||
e.EnterpriseAddress = enterpriseAddress
|
||||
e.EnterpriseEmail = enterpriseEmail
|
||||
|
||||
// 添加领域事件
|
||||
e.addDomainEvent(&EnterpriseInfoUpdatedEvent{
|
||||
@@ -198,10 +188,6 @@ func (e *EnterpriseInfo) validateBasicFields() error {
|
||||
if e.LegalPersonPhone == "" {
|
||||
return fmt.Errorf("法定代表人手机号不能为空")
|
||||
}
|
||||
if e.EnterpriseEmail == "" {
|
||||
return fmt.Errorf("企业邮箱不能为空")
|
||||
}
|
||||
|
||||
// 统一社会信用代码格式验证
|
||||
if !e.isValidUnifiedSocialCode(e.UnifiedSocialCode) {
|
||||
return fmt.Errorf("统一社会信用代码格式无效")
|
||||
@@ -217,11 +203,6 @@ func (e *EnterpriseInfo) validateBasicFields() error {
|
||||
return fmt.Errorf("法定代表人手机号格式无效")
|
||||
}
|
||||
|
||||
// 邮箱格式验证 (简单示例,实际应更严格)
|
||||
if !e.isValidEmail(e.EnterpriseEmail) {
|
||||
return fmt.Errorf("企业邮箱格式无效")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -237,11 +218,6 @@ func (e *EnterpriseInfo) validateBusinessLogic() error {
|
||||
return fmt.Errorf("法定代表人姓名长度不能超过100个字符")
|
||||
}
|
||||
|
||||
// 企业邮箱格式验证 (简单示例,实际应更严格)
|
||||
if !e.isValidEmail(e.EnterpriseEmail) {
|
||||
return fmt.Errorf("企业邮箱格式无效")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -255,8 +231,7 @@ func (e *EnterpriseInfo) IsComplete() bool {
|
||||
e.UnifiedSocialCode != "" &&
|
||||
e.LegalPersonName != "" &&
|
||||
e.LegalPersonID != "" &&
|
||||
e.LegalPersonPhone != "" &&
|
||||
e.EnterpriseEmail != ""
|
||||
e.LegalPersonPhone != ""
|
||||
}
|
||||
|
||||
// GetCertificationProgress 获取认证进度
|
||||
|
||||
Reference in New Issue
Block a user