feat(operations): add auditable source provider maintenance
This commit is contained in:
@@ -93,6 +93,8 @@ func (s *Service) UpdateVehicleSourcePolicy(ctx context.Context, vin string, upd
|
||||
}
|
||||
vin = strings.ToUpper(strings.TrimSpace(vin))
|
||||
update.SourceRef = strings.ToLower(strings.TrimSpace(update.SourceRef))
|
||||
update.ProviderName = strings.TrimSpace(update.ProviderName)
|
||||
update.ProviderEvidence = strings.TrimSpace(update.ProviderEvidence)
|
||||
update.Remark = strings.TrimSpace(update.Remark)
|
||||
if vin == "" {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "VEHICLE_VIN_REQUIRED", Message: "车辆 VIN 不能为空"}
|
||||
@@ -112,6 +114,12 @@ func (s *Service) UpdateVehicleSourcePolicy(ctx context.Context, vin string, upd
|
||||
if len([]rune(update.Remark)) > 200 {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "SOURCE_REMARK_TOO_LONG", Message: "策略备注不能超过 200 个字符"}
|
||||
}
|
||||
if len([]rune(update.ProviderName)) > 128 {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "SOURCE_PROVIDER_TOO_LONG", Message: "提供方名称不能超过 128 个字符"}
|
||||
}
|
||||
if len([]rune(update.ProviderEvidence)) > 255 {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "SOURCE_PROVIDER_EVIDENCE_TOO_LONG", Message: "提供方核验依据不能超过 255 个字符"}
|
||||
}
|
||||
update.Actor = strings.TrimSpace(update.Actor)
|
||||
if update.Actor == "" {
|
||||
update.Actor = ActorFromContext(ctx)
|
||||
@@ -135,6 +143,10 @@ func (s *Service) UpdateVehicleSourcePolicy(ctx context.Context, vin string, upd
|
||||
if selected == nil || selected.sourceKey == "" {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "SOURCE_NOT_FOUND", Message: "当前车辆不存在该来源,请刷新后重试"}
|
||||
}
|
||||
providerChanged := strings.TrimSpace(selected.ProviderOverride) != update.ProviderName
|
||||
if providerChanged && update.ProviderEvidence == "" {
|
||||
return VehicleSourceDiagnostic{}, clientError{Code: "SOURCE_PROVIDER_REASON_REQUIRED", Message: "维护提供方时必须填写权威资料来源或核验说明"}
|
||||
}
|
||||
store, ok := s.store.(vehicleSourcePolicyStore)
|
||||
if !ok {
|
||||
return VehicleSourceDiagnostic{}, errors.New("vehicle source policy store is not configured")
|
||||
@@ -147,6 +159,8 @@ func (s *Service) UpdateVehicleSourcePolicy(ctx context.Context, vin string, upd
|
||||
SourceLabel: selected.SourceLabel,
|
||||
CurrentEnabled: selected.Enabled,
|
||||
CurrentPriority: selected.Priority,
|
||||
CurrentRemark: selected.PolicyRemark,
|
||||
CurrentProvider: selected.ProviderOverride,
|
||||
}); err != nil {
|
||||
return VehicleSourceDiagnostic{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user