package imagegen import ( "context" "fmt" "github.com/gogf/gf/v2/frame/g" ) // ImageGenClient 效果图生成客户端 type ImageGenClient interface { // Generate 生成单张效果图,返回图片 URL Generate(ctx context.Context, req *GenerateReq) (string, error) } // GenerateReq 生成请求 type GenerateReq struct { BaseImageURL string // 用户全身照 Prompt string // 方案描述 Angle string // 正面/侧面/背面 Seed int64 } // NewClient 按供应商创建客户端(config 未配置 Key 时强制 mock) func NewClient(supplier string) ImageGenClient { if supplier == "wanx" { key := g.Cfg().MustGet(context.Background(), "imagegen.wanx_api_key", "").String() if key != "" { return &wanxClient{ apiKey: key, model: g.Cfg().MustGet(context.Background(), "imagegen.wanx_model", "wanx-v2").String(), base: "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis", } } } return &mockClient{} } // buildPrompt 组装方案描述 prompt func buildPrompt(planDesc, hairstyle, hairColor, angle string) string { return fmt.Sprintf("时尚穿搭效果图,%s;发型:%s(发色 %s);角度:%s;人物写实、高清、全身、纯色背景", planDesc, hairstyle, hairColor, angle) }