41 lines
991 B
Go
41 lines
991 B
Go
|
|
// Code scaffolded by goctl. Safe to edit.
|
||
|
|
// goctl 1.10.1
|
||
|
|
|
||
|
|
package logic
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"img_infinite_canvas/internal/svc"
|
||
|
|
"img_infinite_canvas/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type CreateProjectAsyncLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewCreateProjectAsyncLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProjectAsyncLogic {
|
||
|
|
return &CreateProjectAsyncLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *CreateProjectAsyncLogic) CreateProjectAsync(req *types.CreateProjectRequest) (resp *types.ProjectResponse, err error) {
|
||
|
|
if err := validateRequiredPrompt(req.Prompt, req.AllowEmptyPrompt); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
project, err := l.svcCtx.DesignService.CreateProjectAsync(l.ctx, req.Title, req.Prompt, req.ImageModel, req.ImageSize, req.EnableWebSearch)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return toProjectResponse(project), nil
|
||
|
|
}
|