// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "wechat-api/ent/employee" "wechat-api/ent/tutorial" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // Tutorial is the model entity for the Tutorial schema. type Tutorial struct { config `json:"-"` // ID of the ent. ID uint64 `json:"id,omitempty"` // Create Time | 创建日期 CreatedAt time.Time `json:"created_at,omitempty"` // Update Time | 修改日期 UpdatedAt time.Time `json:"updated_at,omitempty"` // Delete Time | 删除日期 DeletedAt time.Time `json:"deleted_at,omitempty"` // employee_id | 员工ID EmployeeID uint64 `json:"employee_id,omitempty"` // index | 序号 Index int `json:"index,omitempty"` // title | 标题 Title string `json:"title,omitempty"` // content | 内容 Content string `json:"content,omitempty"` // organization_id | 租户ID OrganizationID uint64 `json:"organization_id,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TutorialQuery when eager-loading is set. Edges TutorialEdges `json:"edges"` selectValues sql.SelectValues } // TutorialEdges holds the relations/edges for other nodes in the graph. type TutorialEdges struct { // Employee holds the value of the employee edge. Employee *Employee `json:"employee,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // EmployeeOrErr returns the Employee value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e TutorialEdges) EmployeeOrErr() (*Employee, error) { if e.Employee != nil { return e.Employee, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: employee.Label} } return nil, &NotLoadedError{edge: "employee"} } // scanValues returns the types for scanning values from sql.Rows. func (*Tutorial) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case tutorial.FieldID, tutorial.FieldEmployeeID, tutorial.FieldIndex, tutorial.FieldOrganizationID: values[i] = new(sql.NullInt64) case tutorial.FieldTitle, tutorial.FieldContent: values[i] = new(sql.NullString) case tutorial.FieldCreatedAt, tutorial.FieldUpdatedAt, tutorial.FieldDeletedAt: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Tutorial fields. func (t *Tutorial) 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 tutorial.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } t.ID = uint64(value.Int64) case tutorial.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { t.CreatedAt = value.Time } case tutorial.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { t.UpdatedAt = value.Time } case tutorial.FieldDeletedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) } else if value.Valid { t.DeletedAt = value.Time } case tutorial.FieldEmployeeID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field employee_id", values[i]) } else if value.Valid { t.EmployeeID = uint64(value.Int64) } case tutorial.FieldIndex: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field index", values[i]) } else if value.Valid { t.Index = int(value.Int64) } case tutorial.FieldTitle: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field title", values[i]) } else if value.Valid { t.Title = value.String } case tutorial.FieldContent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field content", values[i]) } else if value.Valid { t.Content = value.String } case tutorial.FieldOrganizationID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field organization_id", values[i]) } else if value.Valid { t.OrganizationID = uint64(value.Int64) } default: t.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Tutorial. // This includes values selected through modifiers, order, etc. func (t *Tutorial) Value(name string) (ent.Value, error) { return t.selectValues.Get(name) } // QueryEmployee queries the "employee" edge of the Tutorial entity. func (t *Tutorial) QueryEmployee() *EmployeeQuery { return NewTutorialClient(t.config).QueryEmployee(t) } // Update returns a builder for updating this Tutorial. // Note that you need to call Tutorial.Unwrap() before calling this method if this Tutorial // was returned from a transaction, and the transaction was committed or rolled back. func (t *Tutorial) Update() *TutorialUpdateOne { return NewTutorialClient(t.config).UpdateOne(t) } // Unwrap unwraps the Tutorial 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 (t *Tutorial) Unwrap() *Tutorial { _tx, ok := t.config.driver.(*txDriver) if !ok { panic("ent: Tutorial is not a transactional entity") } t.config.driver = _tx.drv return t } // String implements the fmt.Stringer. func (t *Tutorial) String() string { var builder strings.Builder builder.WriteString("Tutorial(") builder.WriteString(fmt.Sprintf("id=%v, ", t.ID)) builder.WriteString("created_at=") builder.WriteString(t.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(t.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("deleted_at=") builder.WriteString(t.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("employee_id=") builder.WriteString(fmt.Sprintf("%v", t.EmployeeID)) builder.WriteString(", ") builder.WriteString("index=") builder.WriteString(fmt.Sprintf("%v", t.Index)) builder.WriteString(", ") builder.WriteString("title=") builder.WriteString(t.Title) builder.WriteString(", ") builder.WriteString("content=") builder.WriteString(t.Content) builder.WriteString(", ") builder.WriteString("organization_id=") builder.WriteString(fmt.Sprintf("%v", t.OrganizationID)) builder.WriteByte(')') return builder.String() } // Tutorials is a parsable slice of Tutorial. type Tutorials []*Tutorial