f
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package certification
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hyapi-server/internal/application/certification/dto/commands"
|
||||
"hyapi-server/internal/application/certification/dto/queries"
|
||||
"hyapi-server/internal/application/certification/dto/responses"
|
||||
)
|
||||
|
||||
// CertificationApplicationService 认证应用服务接口
|
||||
// 负责用例协调,提供精简的应用层接口
|
||||
type CertificationApplicationService interface {
|
||||
// ================ 用户操作用例 ================
|
||||
// 提交企业信息
|
||||
SubmitEnterpriseInfo(ctx context.Context, cmd *commands.SubmitEnterpriseInfoCommand) (*responses.CertificationResponse, error)
|
||||
// 确认状态
|
||||
ConfirmAuth(ctx context.Context, cmd *queries.ConfirmAuthCommand) (*responses.ConfirmAuthResponse, error)
|
||||
// 确认签署
|
||||
ConfirmSign(ctx context.Context, cmd *queries.ConfirmSignCommand) (*responses.ConfirmSignResponse, error)
|
||||
// 申请合同签署
|
||||
ApplyContract(ctx context.Context, cmd *commands.ApplyContractCommand) (*responses.ContractSignUrlResponse, error)
|
||||
|
||||
// OCR营业执照识别
|
||||
RecognizeBusinessLicense(ctx context.Context, imageBytes []byte) (*responses.BusinessLicenseResult, error)
|
||||
|
||||
// ================ 查询用例 ================
|
||||
|
||||
// 获取认证详情
|
||||
GetCertification(ctx context.Context, query *queries.GetCertificationQuery) (*responses.CertificationResponse, error)
|
||||
|
||||
// 获取认证列表(管理员)
|
||||
ListCertifications(ctx context.Context, query *queries.ListCertificationsQuery) (*responses.CertificationListResponse, error)
|
||||
|
||||
// ================ 管理员后台操作用例 ================
|
||||
|
||||
// AdminCompleteCertificationWithoutContract 管理员代用户完成认证(暂不关联合同)
|
||||
AdminCompleteCertificationWithoutContract(ctx context.Context, cmd *commands.AdminCompleteCertificationCommand) (*responses.CertificationResponse, error)
|
||||
|
||||
// AdminListSubmitRecords 管理端分页查询企业信息提交记录
|
||||
AdminListSubmitRecords(ctx context.Context, query *queries.AdminListSubmitRecordsQuery) (*responses.AdminSubmitRecordsListResponse, error)
|
||||
// AdminGetSubmitRecordByID 管理端获取单条提交记录详情
|
||||
AdminGetSubmitRecordByID(ctx context.Context, recordID string) (*responses.AdminSubmitRecordDetail, error)
|
||||
// AdminApproveSubmitRecord 管理端审核通过(按提交记录 ID)
|
||||
AdminApproveSubmitRecord(ctx context.Context, recordID, adminID, remark string) error
|
||||
// AdminRejectSubmitRecord 管理端审核拒绝(按提交记录 ID)
|
||||
AdminRejectSubmitRecord(ctx context.Context, recordID, adminID, remark string) error
|
||||
// AdminTransitionCertificationStatus 管理端按用户变更认证状态(以状态机为准:info_submitted=通过 / info_rejected=拒绝)
|
||||
AdminTransitionCertificationStatus(ctx context.Context, cmd *commands.AdminTransitionCertificationStatusCommand) error
|
||||
|
||||
// ================ e签宝回调处理 ================
|
||||
|
||||
// 处理e签宝回调
|
||||
HandleEsignCallback(ctx context.Context, cmd *commands.EsignCallbackCommand) error
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,130 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"hyapi-server/internal/domains/certification/enums"
|
||||
)
|
||||
|
||||
// CreateCertificationCommand 创建认证申请命令
|
||||
type CreateCertificationCommand struct {
|
||||
UserID string `json:"-"`
|
||||
}
|
||||
|
||||
// ApplyContractCommand 申请合同命令
|
||||
type ApplyContractCommand struct {
|
||||
UserID string `json:"user_id" validate:"required"`
|
||||
}
|
||||
|
||||
// RetryOperationCommand 重试操作命令
|
||||
type RetryOperationCommand struct {
|
||||
CertificationID string `json:"certification_id" validate:"required"`
|
||||
UserID string `json:"user_id" validate:"required"`
|
||||
Operation string `json:"operation" validate:"required,oneof=enterprise_verification contract_application"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// EsignCallbackCommand e签宝回调命令
|
||||
type EsignCallbackCommand struct {
|
||||
Data *EsignCallbackData `json:"data"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
QueryParams map[string]string `json:"query_params"`
|
||||
}
|
||||
|
||||
// EsignCallbackData e签宝回调数据结构
|
||||
type EsignCallbackData struct {
|
||||
Action string `json:"action"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
AuthFlowId string `json:"authFlowId,omitempty"`
|
||||
SignFlowId string `json:"signFlowId,omitempty"`
|
||||
CustomBizNum string `json:"customBizNum,omitempty"`
|
||||
SignOrder int `json:"signOrder,omitempty"`
|
||||
OperateTime int64 `json:"operateTime,omitempty"`
|
||||
SignResult int `json:"signResult,omitempty"`
|
||||
ResultDescription string `json:"resultDescription,omitempty"`
|
||||
AuthType string `json:"authType,omitempty"`
|
||||
SignFlowStatus string `json:"signFlowStatus,omitempty"`
|
||||
Operator *EsignOperator `json:"operator,omitempty"`
|
||||
PsnInfo *EsignPsnInfo `json:"psnInfo,omitempty"`
|
||||
Organization *EsignOrganization `json:"organization,omitempty"`
|
||||
}
|
||||
|
||||
// EsignOperator 签署人信息
|
||||
type EsignOperator struct {
|
||||
PsnId string `json:"psnId"`
|
||||
PsnAccount *EsignPsnAccount `json:"psnAccount"`
|
||||
}
|
||||
|
||||
// EsignPsnInfo 个人认证信息
|
||||
type EsignPsnInfo struct {
|
||||
PsnId string `json:"psnId"`
|
||||
PsnAccount *EsignPsnAccount `json:"psnAccount"`
|
||||
}
|
||||
|
||||
// EsignPsnAccount 个人账户信息
|
||||
type EsignPsnAccount struct {
|
||||
AccountMobile string `json:"accountMobile"`
|
||||
AccountEmail string `json:"accountEmail"`
|
||||
}
|
||||
|
||||
// EsignOrganization 企业信息
|
||||
type EsignOrganization struct {
|
||||
OrgName string `json:"orgName"`
|
||||
// 可以根据需要添加更多企业信息字段
|
||||
}
|
||||
|
||||
// AdminCompleteCertificationCommand 管理员代用户完成认证命令(可不关联合同)
|
||||
type AdminCompleteCertificationCommand struct {
|
||||
// AdminID 从JWT中获取,不从请求体传递,因此不做必填校验
|
||||
AdminID string `json:"-"`
|
||||
UserID string `json:"user_id" validate:"required"`
|
||||
CompanyName string `json:"company_name" validate:"required,min=2,max=100"`
|
||||
UnifiedSocialCode string `json:"unified_social_code" validate:"required"`
|
||||
LegalPersonName string `json:"legal_person_name" validate:"required,min=2,max=20"`
|
||||
LegalPersonID string `json:"legal_person_id" validate:"required"`
|
||||
LegalPersonPhone string `json:"legal_person_phone" validate:"required"`
|
||||
EnterpriseAddress string `json:"enterprise_address" validate:"required"`
|
||||
// 备注信息,用于记录后台操作原因
|
||||
Reason string `json:"reason" validate:"required"`
|
||||
}
|
||||
// ForceTransitionStatusCommand 强制状态转换命令(管理员)
|
||||
type ForceTransitionStatusCommand struct {
|
||||
CertificationID string `json:"certification_id" validate:"required"`
|
||||
AdminID string `json:"admin_id" validate:"required"`
|
||||
TargetStatus enums.CertificationStatus `json:"target_status" validate:"required"`
|
||||
Reason string `json:"reason" validate:"required"`
|
||||
Force bool `json:"force,omitempty"` // 是否强制执行,跳过业务规则验证
|
||||
}
|
||||
|
||||
// AdminTransitionCertificationStatusCommand 管理端变更认证状态(以状态机为准,用于审核通过/拒绝等)
|
||||
type AdminTransitionCertificationStatusCommand struct {
|
||||
AdminID string `json:"-"`
|
||||
UserID string `json:"user_id" validate:"required"`
|
||||
TargetStatus string `json:"target_status" validate:"required,oneof=info_submitted info_rejected"` // 审核通过 -> info_submitted;审核拒绝 -> info_rejected
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// SubmitEnterpriseInfoCommand 提交企业信息命令
|
||||
type SubmitEnterpriseInfoCommand struct {
|
||||
UserID string `json:"-" comment:"用户唯一标识,从JWT token获取,不在JSON中暴露"`
|
||||
CompanyName string `json:"company_name" binding:"required,min=2,max=100" comment:"企业名称,如:北京科技有限公司"`
|
||||
UnifiedSocialCode string `json:"unified_social_code" binding:"required,social_credit_code" comment:"统一社会信用代码,18位企业唯一标识,如:91110000123456789X"`
|
||||
LegalPersonName string `json:"legal_person_name" binding:"required,min=2,max=20" comment:"法定代表人姓名,如:张三"`
|
||||
LegalPersonID string `json:"legal_person_id" binding:"required,id_card" comment:"法定代表人身份证号码,18位,如:110101199001011234"`
|
||||
LegalPersonPhone string `json:"legal_person_phone" binding:"required,phone" comment:"法定代表人手机号,11位,如:13800138000"`
|
||||
EnterpriseAddress string `json:"enterprise_address" binding:"required,enterprise_address" comment:"企业地址,如:北京市海淀区"`
|
||||
VerificationCode string `json:"verification_code" binding:"required,len=6" comment:"验证码"`
|
||||
|
||||
// 营业执照图片 URL(单张)
|
||||
BusinessLicenseImageURL string `json:"business_license_image_url" binding:"omitempty,url" comment:"营业执照图片URL"`
|
||||
// 办公场地图片 URL 列表(前端传 string 数组)
|
||||
OfficePlaceImageURLs []string `json:"office_place_image_urls" binding:"omitempty,dive,url" comment:"办公场地图片URL列表"`
|
||||
|
||||
// 授权代表信息(与前端 authorized_rep_* 及表字段一致)
|
||||
AuthorizedRepName string `json:"authorized_rep_name" binding:"omitempty,min=2,max=20" comment:"授权代表姓名"`
|
||||
AuthorizedRepID string `json:"authorized_rep_id" binding:"omitempty,id_card" comment:"授权代表身份证号"`
|
||||
AuthorizedRepPhone string `json:"authorized_rep_phone" binding:"omitempty,phone" comment:"授权代表手机号"`
|
||||
AuthorizedRepIDImageURLs []string `json:"authorized_rep_id_image_urls" binding:"omitempty,dive,url" comment:"授权代表身份证正反面图片URL"`
|
||||
|
||||
// 应用场景
|
||||
APIUsage string `json:"api_usage" binding:"omitempty,min=5,max=500" comment:"接口用途及业务场景说明"`
|
||||
ScenarioAttachmentURLs []string `json:"scenario_attachment_urls" binding:"omitempty,dive,url" comment:"场景附件图片URL列表"`
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package commands
|
||||
|
||||
// GetContractSignURLCommand 获取合同签署链接命令
|
||||
type GetContractSignURLCommand struct {
|
||||
UserID string `json:"user_id" binding:"required,uuid" comment:"用户ID"`
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package queries
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"hyapi-server/internal/domains/certification/enums"
|
||||
domainQueries "hyapi-server/internal/domains/certification/repositories/queries"
|
||||
)
|
||||
|
||||
// GetCertificationQuery 获取认证详情查询
|
||||
type GetCertificationQuery struct {
|
||||
UserID string `json:"user_id,omitempty"` // 用于权限验证
|
||||
}
|
||||
|
||||
// ConfirmAuthCommand 确认认证状态命令
|
||||
type ConfirmAuthCommand struct {
|
||||
UserID string `json:"-"`
|
||||
}
|
||||
|
||||
// ConfirmSignCommand 确认签署状态命令
|
||||
type ConfirmSignCommand struct {
|
||||
UserID string `json:"-"`
|
||||
}
|
||||
|
||||
// GetUserCertificationsQuery 获取用户认证列表查询
|
||||
type GetUserCertificationsQuery struct {
|
||||
UserID string `json:"user_id" validate:"required"`
|
||||
Status enums.CertificationStatus `json:"status,omitempty"`
|
||||
IncludeCompleted bool `json:"include_completed,omitempty"`
|
||||
IncludeFailed bool `json:"include_failed,omitempty"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// ToDomainQuery 转换为领域查询对象
|
||||
func (q *GetUserCertificationsQuery) ToDomainQuery() *domainQueries.UserCertificationsQuery {
|
||||
domainQuery := &domainQueries.UserCertificationsQuery{
|
||||
UserID: q.UserID,
|
||||
Status: q.Status,
|
||||
IncludeCompleted: q.IncludeCompleted,
|
||||
IncludeFailed: q.IncludeFailed,
|
||||
Page: q.Page,
|
||||
PageSize: q.PageSize,
|
||||
}
|
||||
domainQuery.DefaultValues()
|
||||
return domainQuery
|
||||
}
|
||||
|
||||
// ListCertificationsQuery 认证列表查询(管理员)
|
||||
type ListCertificationsQuery struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
Status enums.CertificationStatus `json:"status,omitempty"`
|
||||
Statuses []enums.CertificationStatus `json:"statuses,omitempty"`
|
||||
FailureReason enums.FailureReason `json:"failure_reason,omitempty"`
|
||||
CreatedAfter *time.Time `json:"created_after,omitempty"`
|
||||
CreatedBefore *time.Time `json:"created_before,omitempty"`
|
||||
CompanyName string `json:"company_name,omitempty"`
|
||||
LegalPersonName string `json:"legal_person_name,omitempty"`
|
||||
SearchKeyword string `json:"search_keyword,omitempty"`
|
||||
}
|
||||
|
||||
// ToDomainQuery 转换为领域查询对象
|
||||
func (q *ListCertificationsQuery) ToDomainQuery() *domainQueries.ListCertificationsQuery {
|
||||
domainQuery := &domainQueries.ListCertificationsQuery{
|
||||
Page: q.Page,
|
||||
PageSize: q.PageSize,
|
||||
SortBy: q.SortBy,
|
||||
SortOrder: q.SortOrder,
|
||||
UserID: q.UserID,
|
||||
Status: q.Status,
|
||||
Statuses: q.Statuses,
|
||||
FailureReason: q.FailureReason,
|
||||
CreatedAfter: q.CreatedAfter,
|
||||
CreatedBefore: q.CreatedBefore,
|
||||
CompanyName: q.CompanyName,
|
||||
LegalPersonName: q.LegalPersonName,
|
||||
SearchKeyword: q.SearchKeyword,
|
||||
}
|
||||
domainQuery.DefaultValues()
|
||||
return domainQuery
|
||||
}
|
||||
|
||||
// SearchCertificationsQuery 搜索认证查询
|
||||
type SearchCertificationsQuery struct {
|
||||
Keyword string `json:"keyword" validate:"required,min=2"`
|
||||
SearchFields []string `json:"search_fields,omitempty"`
|
||||
Statuses []enums.CertificationStatus `json:"statuses,omitempty"`
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
SortBy string `json:"sort_by"`
|
||||
SortOrder string `json:"sort_order"`
|
||||
ExactMatch bool `json:"exact_match,omitempty"`
|
||||
}
|
||||
|
||||
// ToDomainQuery 转换为领域查询对象
|
||||
func (q *SearchCertificationsQuery) ToDomainQuery() *domainQueries.SearchCertificationsQuery {
|
||||
domainQuery := &domainQueries.SearchCertificationsQuery{
|
||||
Keyword: q.Keyword,
|
||||
SearchFields: q.SearchFields,
|
||||
Statuses: q.Statuses,
|
||||
UserID: q.UserID,
|
||||
Page: q.Page,
|
||||
PageSize: q.PageSize,
|
||||
SortBy: q.SortBy,
|
||||
SortOrder: q.SortOrder,
|
||||
ExactMatch: q.ExactMatch,
|
||||
}
|
||||
domainQuery.DefaultValues()
|
||||
return domainQuery
|
||||
}
|
||||
|
||||
// GetCertificationStatisticsQuery 认证统计查询
|
||||
type GetCertificationStatisticsQuery struct {
|
||||
StartDate time.Time `json:"start_date" validate:"required"`
|
||||
EndDate time.Time `json:"end_date" validate:"required"`
|
||||
Period string `json:"period" validate:"oneof=daily weekly monthly yearly"`
|
||||
GroupBy []string `json:"group_by,omitempty"`
|
||||
UserIDs []string `json:"user_ids,omitempty"`
|
||||
Statuses []enums.CertificationStatus `json:"statuses,omitempty"`
|
||||
IncludeProgressStats bool `json:"include_progress_stats,omitempty"`
|
||||
IncludeRetryStats bool `json:"include_retry_stats,omitempty"`
|
||||
IncludeTimeStats bool `json:"include_time_stats,omitempty"`
|
||||
}
|
||||
|
||||
// ToDomainQuery 转换为领域查询对象
|
||||
func (q *GetCertificationStatisticsQuery) ToDomainQuery() *domainQueries.CertificationStatisticsQuery {
|
||||
return &domainQueries.CertificationStatisticsQuery{
|
||||
StartDate: q.StartDate,
|
||||
EndDate: q.EndDate,
|
||||
Period: q.Period,
|
||||
GroupBy: q.GroupBy,
|
||||
UserIDs: q.UserIDs,
|
||||
Statuses: q.Statuses,
|
||||
IncludeProgressStats: q.IncludeProgressStats,
|
||||
IncludeRetryStats: q.IncludeRetryStats,
|
||||
IncludeTimeStats: q.IncludeTimeStats,
|
||||
}
|
||||
}
|
||||
|
||||
// GetSystemMonitoringQuery 系统监控查询
|
||||
type GetSystemMonitoringQuery struct {
|
||||
TimeRange string `json:"time_range" validate:"oneof=1h 6h 24h 7d 30d"`
|
||||
Metrics []string `json:"metrics,omitempty"` // 指定要获取的指标类型
|
||||
}
|
||||
|
||||
// GetAvailableMetrics 获取可用的监控指标
|
||||
func (q *GetSystemMonitoringQuery) GetAvailableMetrics() []string {
|
||||
return []string{
|
||||
"certification_count",
|
||||
"success_rate",
|
||||
"failure_rate",
|
||||
"avg_processing_time",
|
||||
"status_distribution",
|
||||
"retry_count",
|
||||
"esign_callback_success_rate",
|
||||
}
|
||||
}
|
||||
|
||||
// GetTimeRangeDuration 获取时间范围对应的持续时间
|
||||
func (q *GetSystemMonitoringQuery) GetTimeRangeDuration() time.Duration {
|
||||
switch q.TimeRange {
|
||||
case "1h":
|
||||
return time.Hour
|
||||
case "6h":
|
||||
return 6 * time.Hour
|
||||
case "24h":
|
||||
return 24 * time.Hour
|
||||
case "7d":
|
||||
return 7 * 24 * time.Hour
|
||||
case "30d":
|
||||
return 30 * 24 * time.Hour
|
||||
default:
|
||||
return 24 * time.Hour // 默认24小时
|
||||
}
|
||||
}
|
||||
|
||||
// ShouldIncludeMetric 检查是否应该包含指定指标
|
||||
func (q *GetSystemMonitoringQuery) ShouldIncludeMetric(metric string) bool {
|
||||
if len(q.Metrics) == 0 {
|
||||
return true // 如果没有指定,包含所有指标
|
||||
}
|
||||
|
||||
for _, m := range q.Metrics {
|
||||
if m == metric {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AdminListSubmitRecordsQuery 管理端企业信息提交记录列表查询(以状态机 certification_status 为准,不做审核状态筛选)
|
||||
type AdminListSubmitRecordsQuery struct {
|
||||
Page int `json:"page" form:"page"`
|
||||
PageSize int `json:"page_size" form:"page_size"`
|
||||
CertificationStatus string `json:"certification_status" form:"certification_status"` // 按认证状态筛选,如 info_pending_review / info_submitted / info_rejected,空为全部
|
||||
CompanyName string `json:"company_name" form:"company_name"` // 企业名称(模糊搜索)
|
||||
LegalPersonPhone string `json:"legal_person_phone" form:"legal_person_phone"` // 法人手机号
|
||||
LegalPersonName string `json:"legal_person_name" form:"legal_person_name"` // 法人姓名(模糊搜索)
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package responses
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"hyapi-server/internal/domains/certification/entities/value_objects"
|
||||
"hyapi-server/internal/domains/certification/enums"
|
||||
)
|
||||
|
||||
// CertificationResponse 认证响应
|
||||
type CertificationResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Status enums.CertificationStatus `json:"status"`
|
||||
StatusName string `json:"status_name"`
|
||||
Progress int `json:"progress"`
|
||||
|
||||
// 企业信息
|
||||
EnterpriseInfo *value_objects.EnterpriseInfo `json:"enterprise_info,omitempty"`
|
||||
|
||||
// 合同信息
|
||||
ContractInfo *value_objects.ContractInfo `json:"contract_info,omitempty"`
|
||||
|
||||
// 时间戳
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
InfoSubmittedAt *time.Time `json:"info_submitted_at,omitempty"`
|
||||
EnterpriseVerifiedAt *time.Time `json:"enterprise_verified_at,omitempty"`
|
||||
ContractAppliedAt *time.Time `json:"contract_applied_at,omitempty"`
|
||||
ContractSignedAt *time.Time `json:"contract_signed_at,omitempty"`
|
||||
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
||||
|
||||
// 业务状态
|
||||
IsCompleted bool `json:"is_completed"`
|
||||
IsFailed bool `json:"is_failed"`
|
||||
IsUserActionRequired bool `json:"is_user_action_required"`
|
||||
|
||||
// 失败信息
|
||||
FailureReason enums.FailureReason `json:"failure_reason,omitempty"`
|
||||
FailureReasonName string `json:"failure_reason_name,omitempty"`
|
||||
FailureMessage string `json:"failure_message,omitempty"`
|
||||
CanRetry bool `json:"can_retry,omitempty"`
|
||||
RetryCount int `json:"retry_count,omitempty"`
|
||||
|
||||
// 用户操作提示
|
||||
NextAction string `json:"next_action,omitempty"`
|
||||
AvailableActions []string `json:"available_actions,omitempty"`
|
||||
|
||||
// 元数据
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// ConfirmAuthResponse 确认认证状态响应
|
||||
type ConfirmAuthResponse struct {
|
||||
Status enums.CertificationStatus `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// ConfirmSignResponse 确认签署状态响应
|
||||
type ConfirmSignResponse struct {
|
||||
Status enums.CertificationStatus `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// CertificationListResponse 认证列表响应
|
||||
type CertificationListResponse struct {
|
||||
Items []*CertificationResponse `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
// ContractSignUrlResponse 合同签署URL响应
|
||||
type ContractSignUrlResponse struct {
|
||||
CertificationID string `json:"certification_id"`
|
||||
ContractSignURL string `json:"contract_sign_url"`
|
||||
ContractURL string `json:"contract_url,omitempty"`
|
||||
ExpireAt *time.Time `json:"expire_at,omitempty"`
|
||||
NextAction string `json:"next_action"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// SystemMonitoringResponse 系统监控响应
|
||||
type SystemMonitoringResponse struct {
|
||||
TimeRange string `json:"time_range"`
|
||||
Metrics map[string]interface{} `json:"metrics"`
|
||||
Alerts []SystemAlert `json:"alerts,omitempty"`
|
||||
SystemHealth SystemHealthStatus `json:"system_health"`
|
||||
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||
}
|
||||
|
||||
// SystemAlert 系统警告
|
||||
type SystemAlert struct {
|
||||
Level string `json:"level"` // info, warning, error, critical
|
||||
Type string `json:"type"` // 警告类型
|
||||
Message string `json:"message"` // 警告消息
|
||||
Metric string `json:"metric"` // 相关指标
|
||||
Value interface{} `json:"value"` // 当前值
|
||||
Threshold interface{} `json:"threshold"` // 阈值
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// SystemHealthStatus 系统健康状态
|
||||
type SystemHealthStatus struct {
|
||||
Overall string `json:"overall"` // healthy, warning, critical
|
||||
Components map[string]string `json:"components"` // 各组件状态
|
||||
LastCheck time.Time `json:"last_check"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
// AdminSubmitRecordItem 管理端提交记录列表项
|
||||
type AdminSubmitRecordItem struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
CompanyName string `json:"company_name"`
|
||||
UnifiedSocialCode string `json:"unified_social_code"`
|
||||
LegalPersonName string `json:"legal_person_name"`
|
||||
SubmitAt time.Time `json:"submit_at"`
|
||||
Status string `json:"status"`
|
||||
CertificationStatus string `json:"certification_status,omitempty"` // 以状态机为准:info_pending_review/info_submitted/info_rejected 等
|
||||
}
|
||||
|
||||
// AdminSubmitRecordDetail 管理端提交记录详情(含完整信息与图片 URL)
|
||||
type AdminSubmitRecordDetail struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
CompanyName string `json:"company_name"`
|
||||
UnifiedSocialCode string `json:"unified_social_code"`
|
||||
LegalPersonName string `json:"legal_person_name"`
|
||||
LegalPersonID string `json:"legal_person_id"`
|
||||
LegalPersonPhone string `json:"legal_person_phone"`
|
||||
EnterpriseAddress string `json:"enterprise_address"`
|
||||
AuthorizedRepName string `json:"authorized_rep_name"`
|
||||
AuthorizedRepID string `json:"authorized_rep_id"`
|
||||
AuthorizedRepPhone string `json:"authorized_rep_phone"`
|
||||
AuthorizedRepIDImageURLs string `json:"authorized_rep_id_image_urls"` // JSON 字符串或解析后数组
|
||||
BusinessLicenseImageURL string `json:"business_license_image_url"`
|
||||
OfficePlaceImageURLs string `json:"office_place_image_urls"` // JSON 数组字符串
|
||||
APIUsage string `json:"api_usage"`
|
||||
ScenarioAttachmentURLs string `json:"scenario_attachment_urls"`
|
||||
Status string `json:"status"`
|
||||
SubmitAt time.Time `json:"submit_at"`
|
||||
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
||||
FailedAt *time.Time `json:"failed_at,omitempty"`
|
||||
FailureReason string `json:"failure_reason,omitempty"`
|
||||
CertificationStatus string `json:"certification_status,omitempty"` // 以状态机为准
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AdminSubmitRecordsListResponse 管理端提交记录列表响应
|
||||
type AdminSubmitRecordsListResponse struct {
|
||||
Items []*AdminSubmitRecordItem `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
// ================ 响应构建辅助方法 ================
|
||||
|
||||
// NewCertificationListResponse 创建认证列表响应
|
||||
func NewCertificationListResponse(items []*CertificationResponse, total int64, page, pageSize int) *CertificationListResponse {
|
||||
totalPages := int((total + int64(pageSize) - 1) / int64(pageSize))
|
||||
if totalPages == 0 {
|
||||
totalPages = 1
|
||||
}
|
||||
|
||||
return &CertificationListResponse{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
TotalPages: totalPages,
|
||||
}
|
||||
}
|
||||
|
||||
// NewContractSignUrlResponse 创建合同签署URL响应
|
||||
func NewContractSignUrlResponse(certificationID, signURL, contractURL, nextAction, message string) *ContractSignUrlResponse {
|
||||
response := &ContractSignUrlResponse{
|
||||
CertificationID: certificationID,
|
||||
ContractSignURL: signURL,
|
||||
ContractURL: contractURL,
|
||||
NextAction: nextAction,
|
||||
Message: message,
|
||||
}
|
||||
|
||||
// 设置过期时间(默认24小时)
|
||||
expireAt := time.Now().Add(24 * time.Hour)
|
||||
response.ExpireAt = &expireAt
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// NewSystemAlert 创建系统警告
|
||||
func NewSystemAlert(level, alertType, message, metric string, value, threshold interface{}) *SystemAlert {
|
||||
return &SystemAlert{
|
||||
Level: level,
|
||||
Type: alertType,
|
||||
Message: message,
|
||||
Metric: metric,
|
||||
Value: value,
|
||||
Threshold: threshold,
|
||||
CreatedAt: time.Now(),
|
||||
Metadata: make(map[string]interface{}),
|
||||
}
|
||||
}
|
||||
|
||||
// IsHealthy 检查系统是否健康
|
||||
func (r *SystemMonitoringResponse) IsHealthy() bool {
|
||||
return r.SystemHealth.Overall == "healthy"
|
||||
}
|
||||
|
||||
// GetCriticalAlerts 获取严重警告
|
||||
func (r *SystemMonitoringResponse) GetCriticalAlerts() []*SystemAlert {
|
||||
var criticalAlerts []*SystemAlert
|
||||
for i := range r.Alerts {
|
||||
if r.Alerts[i].Level == "critical" {
|
||||
criticalAlerts = append(criticalAlerts, &r.Alerts[i])
|
||||
}
|
||||
}
|
||||
return criticalAlerts
|
||||
}
|
||||
|
||||
// HasAlerts 检查是否有警告
|
||||
func (r *SystemMonitoringResponse) HasAlerts() bool {
|
||||
return len(r.Alerts) > 0
|
||||
}
|
||||
|
||||
// GetMetricValue 获取指标值
|
||||
func (r *SystemMonitoringResponse) GetMetricValue(metric string) (interface{}, bool) {
|
||||
value, exists := r.Metrics[metric]
|
||||
return value, exists
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package responses
|
||||
|
||||
// ContractSignURLResponse 合同签署链接响应
|
||||
type ContractSignURLResponse struct {
|
||||
SignURL string `json:"sign_url"` // 签署链接
|
||||
ShortURL string `json:"short_url"` // 短链接
|
||||
SignFlowID string `json:"sign_flow_id"` // 签署流程ID
|
||||
ExpireAt string `json:"expire_at"` // 过期时间
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package responses
|
||||
|
||||
import "time"
|
||||
|
||||
// BusinessLicenseResult 营业执照识别结果
|
||||
type BusinessLicenseResult struct {
|
||||
CompanyName string `json:"company_name"` // 企业名称
|
||||
UnifiedSocialCode string `json:"unified_social_code"` // 统一社会信用代码
|
||||
LegalPersonName string `json:"legal_person_name"` // 法定代表人姓名
|
||||
LegalPersonID string `json:"legal_person_id"` // 法定代表人身份证号
|
||||
RegisteredCapital string `json:"registered_capital"` // 注册资本
|
||||
BusinessScope string `json:"business_scope"` // 经营范围
|
||||
Address string `json:"address"` // 企业地址
|
||||
IssueDate string `json:"issue_date"` // 发证日期
|
||||
ValidPeriod string `json:"valid_period"` // 有效期
|
||||
Confidence float64 `json:"confidence"` // 识别置信度
|
||||
ProcessedAt time.Time `json:"processed_at"` // 处理时间
|
||||
}
|
||||
|
||||
// IDCardResult 身份证识别结果
|
||||
type IDCardResult struct {
|
||||
Name string `json:"name"` // 姓名
|
||||
IDCardNumber string `json:"id_card_number"` // 身份证号
|
||||
Gender string `json:"gender"` // 性别
|
||||
Nation string `json:"nation"` // 民族
|
||||
Birthday string `json:"birthday"` // 出生日期
|
||||
Address string `json:"address"` // 住址
|
||||
IssuingAgency string `json:"issuing_agency"` // 签发机关
|
||||
ValidPeriod string `json:"valid_period"` // 有效期限
|
||||
Side string `json:"side"` // 身份证面(front/back)
|
||||
Confidence float64 `json:"confidence"` // 识别置信度
|
||||
ProcessedAt time.Time `json:"processed_at"` // 处理时间
|
||||
}
|
||||
|
||||
// GeneralTextResult 通用文字识别结果
|
||||
type GeneralTextResult struct {
|
||||
Words []TextLine `json:"words"` // 识别的文字行
|
||||
Confidence float64 `json:"confidence"` // 整体置信度
|
||||
ProcessedAt time.Time `json:"processed_at"` // 处理时间
|
||||
}
|
||||
|
||||
// TextLine 文字行
|
||||
type TextLine struct {
|
||||
Text string `json:"text"` // 文字内容
|
||||
Confidence float64 `json:"confidence"` // 置信度
|
||||
Position Position `json:"position"` // 位置信息
|
||||
}
|
||||
|
||||
// Position 位置信息
|
||||
type Position struct {
|
||||
X int `json:"x"` // X坐标
|
||||
Y int `json:"y"` // Y坐标
|
||||
Width int `json:"width"` // 宽度
|
||||
Height int `json:"height"` // 高度
|
||||
}
|
||||
Reference in New Issue
Block a user