#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
模块名称：dingtalk_config.py
模块描述：系统管理 钉钉对接配置 Pydantic 数据模型

作者：czj
创建日期：2026-08-13
"""

from typing import Optional
from pydantic import BaseModel, Field


class DingTalkConfigResponse(BaseModel):
    """钉钉配置响应"""
    app_key: str = Field("", description="钉钉AppKey")
    app_secret: str = Field("", description="钉钉AppSecret")
    agent_id: int = Field(0, description="钉钉AgentId")
    target_url: str = Field("", description="被测系统URL")


class DingTalkConfigUpdateRequest(BaseModel):
    """钉钉配置更新请求"""
    app_key: Optional[str] = Field(None, description="钉钉AppKey")
    app_secret: Optional[str] = Field(None, description="钉钉AppSecret")
    agent_id: Optional[int] = Field(None, description="钉钉AgentId")
    target_url: Optional[str] = Field(None, description="被测系统URL")


class SutConfigResponse(BaseModel):
    """被测系统配置响应"""
    url: str = Field("", description="被测系统访问 URL")
    source: str = Field("env", description="来源: db(数据库)/env(环境变量默认)")
    login_path: str = Field("/platform/api/auth/login", description="登录接口路径")
    captcha_path: str = Field("/platform/api/code", description="验证码接口路径")


class SutConfigUpdateRequest(BaseModel):
    """被测系统配置更新请求"""
    url: str = Field(..., description="被测系统访问 URL，须以 http:// 或 https:// 开头")
    login_path: Optional[str] = Field(
        None, description="登录接口路径，默认 /platform/api/auth/login"
    )
    captcha_path: Optional[str] = Field(
        None, description="验证码接口路径，默认 /platform/api/code"
    )