f
This commit is contained in:
@@ -92,6 +92,7 @@ type HuiboConfig struct {
|
||||
ProductCode string
|
||||
BaseURL2 string // CallAPI2 使用的 URL
|
||||
AppCode2 string // CallAPI2 使用的 AppCode
|
||||
AuthPDFStorageDir string // 授权 PDF 本地留存目录
|
||||
}
|
||||
|
||||
type HuiboService struct {
|
||||
@@ -378,7 +379,12 @@ func (s *HuiboService) SaveAuthPDFLocally(ctx context.Context, apiCode, authPDFB
|
||||
transactionID = strings.TrimSpace(v)
|
||||
}
|
||||
|
||||
dir := filepath.Join(defaultAuthPDFStorageDir, strings.TrimSpace(apiCode))
|
||||
baseDir := s.authPDFStorageDir()
|
||||
if absDir, absErr := filepath.Abs(baseDir); absErr == nil {
|
||||
baseDir = absDir
|
||||
}
|
||||
|
||||
dir := filepath.Join(baseDir, strings.TrimSpace(apiCode))
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return "", fmt.Errorf("创建授权PDF存储目录失败: %w", err)
|
||||
}
|
||||
@@ -399,12 +405,20 @@ func (s *HuiboService) SaveAuthPDFLocally(ctx context.Context, apiCode, authPDFB
|
||||
zap.String("api_code", apiCode),
|
||||
zap.String("transaction_id", transactionID),
|
||||
zap.String("path", fullPath),
|
||||
zap.String("storage_dir", baseDir),
|
||||
zap.Int("size_bytes", len(pdfBytes)),
|
||||
)
|
||||
}
|
||||
return fullPath, nil
|
||||
}
|
||||
|
||||
func (s *HuiboService) authPDFStorageDir() string {
|
||||
if dir := strings.TrimSpace(s.config.AuthPDFStorageDir); dir != "" {
|
||||
return dir
|
||||
}
|
||||
return defaultAuthPDFStorageDir
|
||||
}
|
||||
|
||||
func sanitizeAuthPDFFilenamePart(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
if s == "" {
|
||||
|
||||
Reference in New Issue
Block a user