[feature] migrate to monorepo
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s

This commit is contained in:
CDN 2025-02-21 00:49:20 +08:00
commit 05ddc1f783
Signed by: CDN
GPG key ID: 0C656827F9F80080
267 changed files with 75165 additions and 0 deletions

208
backend/ent/postcontent.go Normal file
View file

@ -0,0 +1,208 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"tss-rocks-be/ent/post"
"tss-rocks-be/ent/postcontent"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// PostContent is the model entity for the PostContent schema.
type PostContent struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// LanguageCode holds the value of the "language_code" field.
LanguageCode postcontent.LanguageCode `json:"language_code,omitempty"`
// Title holds the value of the "title" field.
Title string `json:"title,omitempty"`
// ContentMarkdown holds the value of the "content_markdown" field.
ContentMarkdown string `json:"content_markdown,omitempty"`
// Summary holds the value of the "summary" field.
Summary string `json:"summary,omitempty"`
// MetaKeywords holds the value of the "meta_keywords" field.
MetaKeywords string `json:"meta_keywords,omitempty"`
// MetaDescription holds the value of the "meta_description" field.
MetaDescription string `json:"meta_description,omitempty"`
// Slug holds the value of the "slug" field.
Slug string `json:"slug,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PostContentQuery when eager-loading is set.
Edges PostContentEdges `json:"edges"`
post_contents *int
selectValues sql.SelectValues
}
// PostContentEdges holds the relations/edges for other nodes in the graph.
type PostContentEdges struct {
// Post holds the value of the post edge.
Post *Post `json:"post,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// PostOrErr returns the Post value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e PostContentEdges) PostOrErr() (*Post, error) {
if e.Post != nil {
return e.Post, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: post.Label}
}
return nil, &NotLoadedError{edge: "post"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*PostContent) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case postcontent.FieldID:
values[i] = new(sql.NullInt64)
case postcontent.FieldLanguageCode, postcontent.FieldTitle, postcontent.FieldContentMarkdown, postcontent.FieldSummary, postcontent.FieldMetaKeywords, postcontent.FieldMetaDescription, postcontent.FieldSlug:
values[i] = new(sql.NullString)
case postcontent.ForeignKeys[0]: // post_contents
values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the PostContent fields.
func (pc *PostContent) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case postcontent.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
pc.ID = int(value.Int64)
case postcontent.FieldLanguageCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field language_code", values[i])
} else if value.Valid {
pc.LanguageCode = postcontent.LanguageCode(value.String)
}
case postcontent.FieldTitle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field title", values[i])
} else if value.Valid {
pc.Title = value.String
}
case postcontent.FieldContentMarkdown:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field content_markdown", values[i])
} else if value.Valid {
pc.ContentMarkdown = value.String
}
case postcontent.FieldSummary:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field summary", values[i])
} else if value.Valid {
pc.Summary = value.String
}
case postcontent.FieldMetaKeywords:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field meta_keywords", values[i])
} else if value.Valid {
pc.MetaKeywords = value.String
}
case postcontent.FieldMetaDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field meta_description", values[i])
} else if value.Valid {
pc.MetaDescription = value.String
}
case postcontent.FieldSlug:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field slug", values[i])
} else if value.Valid {
pc.Slug = value.String
}
case postcontent.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field post_contents", value)
} else if value.Valid {
pc.post_contents = new(int)
*pc.post_contents = int(value.Int64)
}
default:
pc.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the PostContent.
// This includes values selected through modifiers, order, etc.
func (pc *PostContent) Value(name string) (ent.Value, error) {
return pc.selectValues.Get(name)
}
// QueryPost queries the "post" edge of the PostContent entity.
func (pc *PostContent) QueryPost() *PostQuery {
return NewPostContentClient(pc.config).QueryPost(pc)
}
// Update returns a builder for updating this PostContent.
// Note that you need to call PostContent.Unwrap() before calling this method if this PostContent
// was returned from a transaction, and the transaction was committed or rolled back.
func (pc *PostContent) Update() *PostContentUpdateOne {
return NewPostContentClient(pc.config).UpdateOne(pc)
}
// Unwrap unwraps the PostContent entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (pc *PostContent) Unwrap() *PostContent {
_tx, ok := pc.config.driver.(*txDriver)
if !ok {
panic("ent: PostContent is not a transactional entity")
}
pc.config.driver = _tx.drv
return pc
}
// String implements the fmt.Stringer.
func (pc *PostContent) String() string {
var builder strings.Builder
builder.WriteString("PostContent(")
builder.WriteString(fmt.Sprintf("id=%v, ", pc.ID))
builder.WriteString("language_code=")
builder.WriteString(fmt.Sprintf("%v", pc.LanguageCode))
builder.WriteString(", ")
builder.WriteString("title=")
builder.WriteString(pc.Title)
builder.WriteString(", ")
builder.WriteString("content_markdown=")
builder.WriteString(pc.ContentMarkdown)
builder.WriteString(", ")
builder.WriteString("summary=")
builder.WriteString(pc.Summary)
builder.WriteString(", ")
builder.WriteString("meta_keywords=")
builder.WriteString(pc.MetaKeywords)
builder.WriteString(", ")
builder.WriteString("meta_description=")
builder.WriteString(pc.MetaDescription)
builder.WriteString(", ")
builder.WriteString("slug=")
builder.WriteString(pc.Slug)
builder.WriteByte(')')
return builder.String()
}
// PostContents is a parsable slice of PostContent.
type PostContents []*PostContent