
import os
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent


SECRET_KEY = 'django-insecure-6lnki%2*#2a6t=!#@tt9k75v05mp(6gba)0hegycf_u_hriu8s'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'backend.apps.BackendConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'corsheaders'

]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    # 'backend.middleware.Authorization',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware'
]

CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
    'VIEW',
)


CORS_ALLOWED_ORIGINS = [
    'http://127.0.0.1',
    'http://localhost',
    'http://120.46.190.49',
]
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
ROOT_URLCONF = 'DCbackend.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'DCbackend.wsgi.application'

#49数据库配置
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'ql_data',
        'USER': 'root',
        'PASSWORD': 'Gd8XCWEef72GerxE',
        'HOST': '120.46.190.49',
        'PORT': '3306',
    }
}


AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]



LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_TZ = True



STATIC_URL = 'static/'



DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# 文件上传部分配置
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
ALLOWED_FILE_TYPES = ['jpg', 'jpeg', 'png', 'gif', 'pdf']
MAX_UPLOAD_SIZE = 104857600  # 10MB
# 增加最大上传大小到 10MB (或者你需要的大小)
DATA_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024  # 10 MB

# 如果你还想增加最大上传文件大小，也可以设置这个
FILE_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024  # 10 MB

# 填写自己的 access信息
oss_key_id = 'LTAI5tESB5tEYccrrUjkG7c5'
oss_key_secret = 'l9CZU6pkWDdQVGbHxwZGdx9mu9cv2U'
oss_bucket = ' leaseraycos'
oss_endPoint = 'oss-cn-shanghai.aliyuncs.com'
oss_url = "https://leaseraycos.oss-cn-shanghai.aliyuncs.com"
region_id = "cn-shanghai"
SignName = "上海瑞赢旷视科技"

EMAIL_ACCOUNT = "smtpdm.aliyun.com"

# MinIO 配置
MINIO_ENDPOINT = "58.246.234.210:9000"
MINIO_ACCESS_KEY = "minioadmin"
MINIO_SECRET_KEY = "minioadmin"
MINIO_SECURE = False


#正式知识库redis
REDIS_HOST = 'docapi.shqlsy.com'  # 或者你的 Redis 服务器地址
REDIS_PORT = 6379
REDIS_PASSWORD = 'infini_rag_flow'  # 替换为你的实际 Redis 密码
REDIS_DB = 0

#49服务器 redis
RAYCOS_REDIS_HOST = '120.46.190.49'  # 或者你的 Redis 服务器地址
RAYCOS_REDIS_PORT = 6379
RAYCOS_REDIS_PASSWORD = 'Iayq@742295'  # 替换为你的实际 Redis 密码
RAYCOS_REDIS_DB = 0


# 49缓存配置
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": f"redis://{RAYCOS_REDIS_HOST}:{RAYCOS_REDIS_PORT}/{RAYCOS_REDIS_DB}",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PASSWORD": RAYCOS_REDIS_PASSWORD,
        }
    }
}

# 正式缓存配置
# CACHES = {
#     "default": {
#         "BACKEND": "django_redis.cache.RedisCache",
#         "LOCATION": f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB}",
#         "OPTIONS": {
#             "CLIENT_CLASS": "django_redis.client.DefaultClient",
#             "PASSWORD": REDIS_PASSWORD,
#         }
#     }
# }


# Milvus 配置
MILVUS_HOST = "58.246.234.210"
MILVUS_PORT = "19530"
MILVUS_USER =""
MILVUS_PASSWORD =""
VECTOR_DIMENSION = 768

#微信参数
WECHAT_APPID = "wxa874c6c38e498eb4"
WECHAT_SECRET = "ebb128f45ad2069b736ef0312b5e656f"

