f
This commit is contained in:
@@ -702,6 +702,7 @@ huibo:
|
|||||||
product_code: "22089"
|
product_code: "22089"
|
||||||
baseUrl2: "https://napi.zhixin.net:9000/api/data"
|
baseUrl2: "https://napi.zhixin.net:9000/api/data"
|
||||||
app_code2: "1508795945301708800"
|
app_code2: "1508795945301708800"
|
||||||
|
auth_pdf_storage_dir: "storage/huibo-auth-pdf"
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ services:
|
|||||||
- ./resources:/app/resources
|
- ./resources:/app/resources
|
||||||
# 持久化PDF缓存目录,确保生成的PDF在容器重启后仍然存在
|
# 持久化PDF缓存目录,确保生成的PDF在容器重启后仍然存在
|
||||||
- ./storage/pdfg-cache:/app/storage/pdfg-cache
|
- ./storage/pdfg-cache:/app/storage/pdfg-cache
|
||||||
|
# 汇博授权PDF本地留存目录(FLXGHB4F/QYGLBH7Y 等)
|
||||||
|
- ./storage/huibo-auth-pdf:/app/storage/huibo-auth-pdf
|
||||||
# user: "1001:1001" # 注释掉,使用root权限运行
|
# user: "1001:1001" # 注释掉,使用root权限运行
|
||||||
networks:
|
networks:
|
||||||
- hyapi-network
|
- hyapi-network
|
||||||
|
|||||||
@@ -720,8 +720,9 @@ type HuiboConfig struct {
|
|||||||
AESKey string `mapstructure:"aes_key"`
|
AESKey string `mapstructure:"aes_key"`
|
||||||
WorkOrderCode string `mapstructure:"work_order_code"`
|
WorkOrderCode string `mapstructure:"work_order_code"`
|
||||||
ProductCode string `mapstructure:"product_code"`
|
ProductCode string `mapstructure:"product_code"`
|
||||||
BaseURL2 string `mapstructure:"baseUrl2"`
|
BaseURL2 string `mapstructure:"baseUrl2"`
|
||||||
AppCode2 string `mapstructure:"app_code2"`
|
AppCode2 string `mapstructure:"app_code2"`
|
||||||
|
AuthPDFStorageDir string `mapstructure:"auth_pdf_storage_dir"`
|
||||||
|
|
||||||
Logging HuiboLoggingConfig `mapstructure:"logging"`
|
Logging HuiboLoggingConfig `mapstructure:"logging"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ func NewHuiboServiceWithConfig(cfg *config.Config) (*HuiboService, error) {
|
|||||||
AESKey: cfg.Huibo.AESKey,
|
AESKey: cfg.Huibo.AESKey,
|
||||||
WorkOrderCode: cfg.Huibo.WorkOrderCode,
|
WorkOrderCode: cfg.Huibo.WorkOrderCode,
|
||||||
ProductCode: cfg.Huibo.ProductCode,
|
ProductCode: cfg.Huibo.ProductCode,
|
||||||
BaseURL2: cfg.Huibo.BaseURL2,
|
BaseURL2: cfg.Huibo.BaseURL2,
|
||||||
AppCode2: cfg.Huibo.AppCode2,
|
AppCode2: cfg.Huibo.AppCode2,
|
||||||
|
AuthPDFStorageDir: cfg.Huibo.AuthPDFStorageDir,
|
||||||
}, logger)
|
}, logger)
|
||||||
|
|
||||||
return service, nil
|
return service, nil
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ type HuiboConfig struct {
|
|||||||
ProductCode string
|
ProductCode string
|
||||||
BaseURL2 string // CallAPI2 使用的 URL
|
BaseURL2 string // CallAPI2 使用的 URL
|
||||||
AppCode2 string // CallAPI2 使用的 AppCode
|
AppCode2 string // CallAPI2 使用的 AppCode
|
||||||
|
AuthPDFStorageDir string // 授权 PDF 本地留存目录
|
||||||
}
|
}
|
||||||
|
|
||||||
type HuiboService struct {
|
type HuiboService struct {
|
||||||
@@ -378,7 +379,12 @@ func (s *HuiboService) SaveAuthPDFLocally(ctx context.Context, apiCode, authPDFB
|
|||||||
transactionID = strings.TrimSpace(v)
|
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 {
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||||
return "", fmt.Errorf("创建授权PDF存储目录失败: %w", err)
|
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("api_code", apiCode),
|
||||||
zap.String("transaction_id", transactionID),
|
zap.String("transaction_id", transactionID),
|
||||||
zap.String("path", fullPath),
|
zap.String("path", fullPath),
|
||||||
|
zap.String("storage_dir", baseDir),
|
||||||
zap.Int("size_bytes", len(pdfBytes)),
|
zap.Int("size_bytes", len(pdfBytes)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return fullPath, nil
|
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 {
|
func sanitizeAuthPDFFilenamePart(s string) string {
|
||||||
s = strings.TrimSpace(s)
|
s = strings.TrimSpace(s)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
|
|||||||
0
storage/huibo-auth-pdf/.gitkeep
Normal file
0
storage/huibo-auth-pdf/.gitkeep
Normal file
Reference in New Issue
Block a user