| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- from pathlib import Path
- from typing import Dict, List
- from enum import Enum
- import json
- class Settings:
- BASE_PATH = Path(__file__).parent.parent.parent.absolute()
- # --- MinIO 配置 ---
- MINIO_ENDPOINT = "192.168.77.249:9000"
- MINIO_ACCESS_KEY = "pZEwCGnpNN05KPnmC2Yh"
- MINIO_SECRET_KEY = "KfJRuWiv9pVxhIMcFqbkv8hZT9SnNTZ6LPx592D4" # 替换为你的 Secret Key
- MINIO_SECURE = False # 是否使用 https
- MINIO_BUCKET = "grading"
- MINIO_BASE_PREFIX = "score_server_data"
- # DATA_HOST_URL 现在直接指向 MinIO 的前缀路径
- # (注意: 需要在 MinIO 后台将 grading 存储桶的访问权限配置为 Public 或开启特定读策略)
- DATA_HOST_URL = f"http://{MINIO_ENDPOINT}/{MINIO_BUCKET}/{MINIO_BASE_PREFIX}"
- CONFIG_PATH = BASE_PATH / 'Config.json'
- API_PREFIX: str = "/api" # 通用前缀
- SCORE_CONFIG_PATH = BASE_PATH / "app/core/scoring_config.json"
- # 分数计算接口url
- SCORE_UPDATE_SERVER_URL = "http://127.0.0.1:7754"
- SCORE_RECALCULATE_ENDPOINT = f"{SCORE_UPDATE_SERVER_URL}/api/card_score/score_recalculate"
- # 分数计算配置接口
- SCORE_SERVER_CONFIG_URL = f"{SCORE_UPDATE_SERVER_URL}/api/config/scoring_config"
- # 评级后台接口url
- RATING_SERVER_URL = "http://192.168.77.89:8090"
- RATING_REPORT_SAVE_API = f"{RATING_SERVER_URL}/rating/card/ratingReport/save"
- # --- 数据库配置 ---
- DB_NAME = 'card_score_gray_database'
- DB_CARD_TABLE_NAME = 'cards'
- DB_IMAGE_TABLE_NAME = 'card_images'
- DB_GRAY_IMAGE_TABLE_NAME = 'card_gray_images' # 灰度图表名
- RATING_REPORT_HISTORY_TABLE_NAME = "rating_report_history"
- DATABASE_CONFIG: Dict[str, str] = {
- 'user': 'root',
- 'password': '123456',
- 'host': '127.0.0.1',
- }
- # 连接到指定数据库的配置
- DATABASE_CONFIG_WITH_DB: Dict[str, str] = {
- **DATABASE_CONFIG,
- 'database': DB_NAME
- }
- def set_config(self):
- with open(self.CONFIG_PATH, 'r') as f:
- config_json = json.load(f)
- self.DATABASE_CONFIG = config_json["mysql_config"]
- self.DB_NAME = config_json["database_name"]
- def get_full_url(self, path: str) -> str:
- """将相对路径转换为可以直接打开的 MinIO 绝对 URL"""
- if not path:
- return path
- if str(path).startswith("http"):
- return path
- # 移除开头的斜杠防止双斜杠 (如: /Data/xxx -> Data/xxx)
- clean_path = str(path).lstrip("/\\")
- return f"{self.DATA_HOST_URL}/{clean_path}"
- settings = Settings()
|