template.go 935 字节
package core

import (
	"github.com/google/uuid"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
)

func NewDomainParagraph(item types.Paragraph) domain.Paragraph {
	id := item.ID
	if item.ID == "" {
		idGen, _ := uuid.NewUUID()
		id = idGen.String()
	}
	return domain.Paragraph{
		ID:       id,
		Title:    item.Title,
		Prompt:   item.Prompt,
		Required: item.Required,
		Type:     item.Type,
	}
}

func NewTypesParagraph(item domain.Paragraph) types.Paragraph {
	return types.Paragraph{
		ID:       item.ID,
		Title:    item.Title,
		Prompt:   item.Prompt,
		Required: item.Required,
		Type:     item.Type,
	}
}

func NewNoneTypesParagraph(item string) types.Paragraph {
	return types.Paragraph{
		ID:       "",
		Title:    "",
		Prompt:   "",
		Required: false,
		Type:     0,
		Text:     item,
	}
}