package controller import ( "context" "slogan-agent/common" "slogan-agent/styleagent/model/dto" "slogan-agent/styleagent/service" "github.com/gogf/gf/v2/frame/g" ) type outfit struct{} var Outfit = new(outfit) // Generate 生成穿搭方案(异步任务) func (c *outfit) Generate(ctx context.Context, req *dto.OutfitGenerateReq) (res *dto.OutfitGenerateRes, err error) { taskId, err := service.OutfitService.Generate(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req) if err != nil { return nil, err } return &dto.OutfitGenerateRes{TaskId: taskId}, nil } // TaskStatus 查询生成任务状态 func (c *outfit) TaskStatus(ctx context.Context, req *dto.OutfitTaskStatusReq) (res *dto.OutfitTaskStatusRes, err error) { status, msg, err := service.OutfitService.GetTaskStatus(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.TaskId) if err != nil { return nil, err } return &dto.OutfitTaskStatusRes{Status: status, Error: msg}, nil } // PlanList 方案列表 func (c *outfit) PlanList(ctx context.Context, req *dto.OutfitPlanListReq) (res *dto.OutfitPlanListRes, err error) { list, err := service.OutfitService.ListPlans(ctx, common.GetUserId(g.RequestFromCtx(ctx))) if err != nil { return nil, err } return &dto.OutfitPlanListRes{List: list}, nil } // PlanDetail 方案详情(items + images + hairstyle) func (c *outfit) PlanDetail(ctx context.Context, req *dto.OutfitPlanDetailReq) (res *dto.OutfitPlanDetailRes, err error) { return service.OutfitService.GetPlanDetail(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.PlanId) } // SelectMain 选定主方案(触发效果图生成) func (c *outfit) SelectMain(ctx context.Context, req *dto.OutfitSelectMainReq) (res *struct{}, err error) { if err = service.OutfitService.SelectMain(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.PlanId); err != nil { return nil, err } return &struct{}{}, nil } // Review 方案反馈 func (c *outfit) Review(ctx context.Context, req *dto.OutfitReviewReq) (res *struct{}, err error) { if err = service.OutfitService.Review(ctx, common.GetUserId(g.RequestFromCtx(ctx)), req.PlanId, req.Action, req.Note); err != nil { return nil, err } return &struct{}{}, nil }