package entities import ( "time" "gorm.io/gorm" ) // Enterprise 企业信息实体 // 存储企业认证的核心信息,包括企业四要素和验证状态 // 与认证申请是一对一关系,每个认证申请对应一个企业信息 type Enterprise struct { // 基础标识 ID string `gorm:"primaryKey;type:varchar(36)" json:"id" comment:"企业信息唯一标识"` CertificationID string `gorm:"type:varchar(36);not null;index" json:"certification_id" comment:"关联的认证申请ID"` // 企业四要素 - 企业认证的核心信息 CompanyName string `gorm:"type:varchar(255);not null" json:"company_name" comment:"企业名称"` UnifiedSocialCode string `gorm:"type:varchar(50);not null;index" json:"unified_social_code" comment:"统一社会信用代码"` LegalPersonName string `gorm:"type:varchar(100);not null" json:"legal_person_name" comment:"法定代表人姓名"` LegalPersonID string `gorm:"type:varchar(50);not null" json:"legal_person_id" comment:"法定代表人身份证号"` // 关联的营业执照上传记录 LicenseUploadRecordID string `gorm:"type:varchar(36);not null;index" json:"license_upload_record_id" comment:"关联的营业执照上传记录ID"` // OCR识别结果 - 从营业执照中自动识别的信息 OCRRawData string `gorm:"type:text" json:"ocr_raw_data,omitempty" comment:"OCR原始返回数据(JSON格式)"` OCRConfidence float64 `gorm:"type:decimal(5,2)" json:"ocr_confidence,omitempty" comment:"OCR识别置信度(0-1)"` // 验证状态 - 各环节的验证结果 IsOCRVerified bool `gorm:"default:false" json:"is_ocr_verified" comment:"OCR验证是否通过"` IsFaceVerified bool `gorm:"default:false" json:"is_face_verified" comment:"人脸识别是否通过"` VerificationData string `gorm:"type:text" json:"verification_data,omitempty" comment:"验证数据(JSON格式)"` // 时间戳字段 CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" comment:"创建时间"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" comment:"更新时间"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-" comment:"软删除时间"` // 关联关系 Certification *Certification `gorm:"foreignKey:CertificationID" json:"certification,omitempty" comment:"关联的认证申请"` LicenseUploadRecord *LicenseUploadRecord `gorm:"foreignKey:LicenseUploadRecordID" json:"license_upload_record,omitempty" comment:"关联的营业执照上传记录"` } // TableName 指定数据库表名 func (Enterprise) TableName() string { return "enterprises" } // IsComplete 检查企业四要素是否完整 // 验证企业名称、统一社会信用代码、法定代表人姓名、身份证号是否都已填写 func (e *Enterprise) IsComplete() bool { return e.CompanyName != "" && e.UnifiedSocialCode != "" && e.LegalPersonName != "" && e.LegalPersonID != "" } // Validate 验证企业信息是否有效 // 这里可以添加企业信息的业务验证逻辑 // 比如统一社会信用代码格式验证、身份证号格式验证等 func (e *Enterprise) Validate() error { // 这里可以添加企业信息的业务验证逻辑 // 比如统一社会信用代码格式验证、身份证号格式验证等 return nil }