123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/xunjiservice"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // XunjiService is the model entity for the XunjiService schema.
- type XunjiService 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"`
- // Status 1: normal 2: ban | 状态 1 正常 2 禁用
- Status uint8 `json:"status,omitempty"`
- // Delete Time | 删除日期
- DeletedAt time.Time `json:"deleted_at,omitempty"`
- // Xunji表ID
- XunjiID uint64 `json:"xunji_id,omitempty"`
- // 智能体ID
- AgentID uint64 `json:"agent_id,omitempty"`
- // organization_id | 租户ID
- OrganizationID uint64 `json:"organization_id,omitempty"`
- // 微信ID
- Wxid string `json:"wxid,omitempty"`
- // 大模型服务地址
- APIBase string `json:"api_base,omitempty"`
- // 大模型服务密钥
- APIKey string `json:"api_key,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the XunjiServiceQuery when eager-loading is set.
- Edges XunjiServiceEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // XunjiServiceEdges holds the relations/edges for other nodes in the graph.
- type XunjiServiceEdges struct {
- // Agent holds the value of the agent edge.
- Agent *Agent `json:"agent,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
- }
- // AgentOrErr returns the Agent value or an error if the edge
- // was not loaded in eager-loading, or loaded but was not found.
- func (e XunjiServiceEdges) AgentOrErr() (*Agent, error) {
- if e.Agent != nil {
- return e.Agent, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: agent.Label}
- }
- return nil, &NotLoadedError{edge: "agent"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*XunjiService) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case xunjiservice.FieldID, xunjiservice.FieldStatus, xunjiservice.FieldXunjiID, xunjiservice.FieldAgentID, xunjiservice.FieldOrganizationID:
- values[i] = new(sql.NullInt64)
- case xunjiservice.FieldWxid, xunjiservice.FieldAPIBase, xunjiservice.FieldAPIKey:
- values[i] = new(sql.NullString)
- case xunjiservice.FieldCreatedAt, xunjiservice.FieldUpdatedAt, xunjiservice.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 XunjiService fields.
- func (xs *XunjiService) 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 xunjiservice.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- xs.ID = uint64(value.Int64)
- case xunjiservice.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 {
- xs.CreatedAt = value.Time
- }
- case xunjiservice.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 {
- xs.UpdatedAt = value.Time
- }
- case xunjiservice.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- xs.Status = uint8(value.Int64)
- }
- case xunjiservice.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 {
- xs.DeletedAt = value.Time
- }
- case xunjiservice.FieldXunjiID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field xunji_id", values[i])
- } else if value.Valid {
- xs.XunjiID = uint64(value.Int64)
- }
- case xunjiservice.FieldAgentID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field agent_id", values[i])
- } else if value.Valid {
- xs.AgentID = uint64(value.Int64)
- }
- case xunjiservice.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 {
- xs.OrganizationID = uint64(value.Int64)
- }
- case xunjiservice.FieldWxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field wxid", values[i])
- } else if value.Valid {
- xs.Wxid = value.String
- }
- case xunjiservice.FieldAPIBase:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field api_base", values[i])
- } else if value.Valid {
- xs.APIBase = value.String
- }
- case xunjiservice.FieldAPIKey:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field api_key", values[i])
- } else if value.Valid {
- xs.APIKey = value.String
- }
- default:
- xs.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the XunjiService.
- // This includes values selected through modifiers, order, etc.
- func (xs *XunjiService) Value(name string) (ent.Value, error) {
- return xs.selectValues.Get(name)
- }
- // QueryAgent queries the "agent" edge of the XunjiService entity.
- func (xs *XunjiService) QueryAgent() *AgentQuery {
- return NewXunjiServiceClient(xs.config).QueryAgent(xs)
- }
- // Update returns a builder for updating this XunjiService.
- // Note that you need to call XunjiService.Unwrap() before calling this method if this XunjiService
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (xs *XunjiService) Update() *XunjiServiceUpdateOne {
- return NewXunjiServiceClient(xs.config).UpdateOne(xs)
- }
- // Unwrap unwraps the XunjiService 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 (xs *XunjiService) Unwrap() *XunjiService {
- _tx, ok := xs.config.driver.(*txDriver)
- if !ok {
- panic("ent: XunjiService is not a transactional entity")
- }
- xs.config.driver = _tx.drv
- return xs
- }
- // String implements the fmt.Stringer.
- func (xs *XunjiService) String() string {
- var builder strings.Builder
- builder.WriteString("XunjiService(")
- builder.WriteString(fmt.Sprintf("id=%v, ", xs.ID))
- builder.WriteString("created_at=")
- builder.WriteString(xs.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(xs.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", xs.Status))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(xs.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("xunji_id=")
- builder.WriteString(fmt.Sprintf("%v", xs.XunjiID))
- builder.WriteString(", ")
- builder.WriteString("agent_id=")
- builder.WriteString(fmt.Sprintf("%v", xs.AgentID))
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", xs.OrganizationID))
- builder.WriteString(", ")
- builder.WriteString("wxid=")
- builder.WriteString(xs.Wxid)
- builder.WriteString(", ")
- builder.WriteString("api_base=")
- builder.WriteString(xs.APIBase)
- builder.WriteString(", ")
- builder.WriteString("api_key=")
- builder.WriteString(xs.APIKey)
- builder.WriteByte(')')
- return builder.String()
- }
- // XunjiServices is a parsable slice of XunjiService.
- type XunjiServices []*XunjiService
|