from middleware import *


def success(data):
    """
    成功
    """
    return {
        "code": 0,
        "msg": "请求成功",
        "data": data,
    }


def failed(msg):
    """
    失败
    """
    return {
        "code": -1,
        "msg": msg,
    }


class CheckSelectImages(BaseModel):
    # 检查目录
    path_type: int = Field(default=0, description="地址类型;0图像;1目录")
    path: str = Field(default=None, description="目录地址")
    image_list: list[str] = Field(default=[], description="图像地址")


class SegmentImages(BaseModel):
    # 抠图
    token: str = Field(default=None, description="hlm token信息")
    image_type: int = Field(default=0, description="图像类型;0非服装;1服装")
    segment_type: int = Field(default=0, description="抠图精细度;0普通;1精细")
    output_type: int = Field(default=0, description="抠图精细度;0透明;1白底")
    need_cutout_images: list = Field(default=None, description="图像地址集合")


class RequestHlm(BaseModel):
    # 抠图
    token: str = Field(default=None, description="hlm token信息")

class ModelFormModel(BaseModel):
    '''人台抠图参数'''
    token: str = Field(default=None, description="hlm token信息")
    out_width: int = Field(default=1024, description="宽度;默认1024(仅在尺寸模式为【指定大小】时生效)")
    out_height: int = Field(default=1024, description="高度;默认1024(仅在尺寸模式为【指定大小】时生效)")
    size_mode: int = Field(default=0, description="尺寸模式;0=>指定大小;1=>最小边框")
    output_mode: int = Field(default=0, description="输出模式；0=>透明底;1=>白底图")
    need_cutout_images: list = Field(default=None, description="图像地址集合")

class SearchProgress(BaseModel):
    '''进度查询'''
    token: str = Field(default=None, description="hlm token信息")
    generate_ids:list[int] = Field(default=[], description="生成记录ID数组")
    type: str = Field(default="aigc_pro", description="进度类型")
    result: list = Field(default=None, description="图像地址集合")
    save_root_path: str = Field(default="", description="保存图像地址")
