refactor: templates api logic

This commit is contained in:
2024-11-29 23:52:19 +00:00
parent db03db3b83
commit ae8f62d77d
10 changed files with 561 additions and 428 deletions

View File

@@ -3,8 +3,12 @@ package template
import (
"github.com/google/uuid"
"github.com/uptrace/bun"
"regexp"
)
// templateNameRegex is a regex to test whether a given template name is valid
var templateNameRegex = regexp.MustCompile("^[\\w-]+$")
type template struct {
bun.BaseModel `bun:"table:templates,alias:template"`
@@ -27,7 +31,7 @@ type templateFile struct {
Content []byte `bun:"type:blob" json:"content"`
}
type TemplateImage struct {
type Image struct {
bun.BaseModel `bun:"table:template_images,alias:template_images"`
TemplateID uuid.UUID `bun:"type:uuid" json:"-"`