123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/apikey"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // ApiKey is the model entity for the ApiKey schema.
- type ApiKey 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"`
- // Title
- Title string `json:"title,omitempty"`
- // Key
- Key string `json:"key,omitempty"`
- // 租户ID
- OrganizationID uint64 `json:"organization_id,omitempty"`
- // 智能体ID
- AgentID uint64 `json:"agent_id,omitempty"`
- // 定制agent服务地址
- CustomAgentBase string `json:"custom_agent_base,omitempty"`
- // 定制agent服务密钥
- CustomAgentKey string `json:"custom_agent_key,omitempty"`
- // 大模型服务地址
- OpenaiBase string `json:"openai_base,omitempty"`
- // 大模型服务密钥
- OpenaiKey string `json:"openai_key,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ApiKeyQuery when eager-loading is set.
- Edges ApiKeyEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // ApiKeyEdges holds the relations/edges for other nodes in the graph.
- type ApiKeyEdges 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 ApiKeyEdges) 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 (*ApiKey) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case apikey.FieldID, apikey.FieldOrganizationID, apikey.FieldAgentID:
- values[i] = new(sql.NullInt64)
- case apikey.FieldTitle, apikey.FieldKey, apikey.FieldCustomAgentBase, apikey.FieldCustomAgentKey, apikey.FieldOpenaiBase, apikey.FieldOpenaiKey:
- values[i] = new(sql.NullString)
- case apikey.FieldCreatedAt, apikey.FieldUpdatedAt, apikey.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 ApiKey fields.
- func (ak *ApiKey) 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 apikey.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- ak.ID = uint64(value.Int64)
- case apikey.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 {
- ak.CreatedAt = value.Time
- }
- case apikey.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 {
- ak.UpdatedAt = value.Time
- }
- case apikey.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 {
- ak.DeletedAt = value.Time
- }
- case apikey.FieldTitle:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field title", values[i])
- } else if value.Valid {
- ak.Title = value.String
- }
- case apikey.FieldKey:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field key", values[i])
- } else if value.Valid {
- ak.Key = value.String
- }
- case apikey.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 {
- ak.OrganizationID = uint64(value.Int64)
- }
- case apikey.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 {
- ak.AgentID = uint64(value.Int64)
- }
- case apikey.FieldCustomAgentBase:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field custom_agent_base", values[i])
- } else if value.Valid {
- ak.CustomAgentBase = value.String
- }
- case apikey.FieldCustomAgentKey:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field custom_agent_key", values[i])
- } else if value.Valid {
- ak.CustomAgentKey = value.String
- }
- case apikey.FieldOpenaiBase:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field openai_base", values[i])
- } else if value.Valid {
- ak.OpenaiBase = value.String
- }
- case apikey.FieldOpenaiKey:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field openai_key", values[i])
- } else if value.Valid {
- ak.OpenaiKey = value.String
- }
- default:
- ak.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the ApiKey.
- // This includes values selected through modifiers, order, etc.
- func (ak *ApiKey) Value(name string) (ent.Value, error) {
- return ak.selectValues.Get(name)
- }
- // QueryAgent queries the "agent" edge of the ApiKey entity.
- func (ak *ApiKey) QueryAgent() *AgentQuery {
- return NewApiKeyClient(ak.config).QueryAgent(ak)
- }
- // Update returns a builder for updating this ApiKey.
- // Note that you need to call ApiKey.Unwrap() before calling this method if this ApiKey
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (ak *ApiKey) Update() *ApiKeyUpdateOne {
- return NewApiKeyClient(ak.config).UpdateOne(ak)
- }
- // Unwrap unwraps the ApiKey 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 (ak *ApiKey) Unwrap() *ApiKey {
- _tx, ok := ak.config.driver.(*txDriver)
- if !ok {
- panic("ent: ApiKey is not a transactional entity")
- }
- ak.config.driver = _tx.drv
- return ak
- }
- // String implements the fmt.Stringer.
- func (ak *ApiKey) String() string {
- var builder strings.Builder
- builder.WriteString("ApiKey(")
- builder.WriteString(fmt.Sprintf("id=%v, ", ak.ID))
- builder.WriteString("created_at=")
- builder.WriteString(ak.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(ak.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(ak.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("title=")
- builder.WriteString(ak.Title)
- builder.WriteString(", ")
- builder.WriteString("key=")
- builder.WriteString(ak.Key)
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", ak.OrganizationID))
- builder.WriteString(", ")
- builder.WriteString("agent_id=")
- builder.WriteString(fmt.Sprintf("%v", ak.AgentID))
- builder.WriteString(", ")
- builder.WriteString("custom_agent_base=")
- builder.WriteString(ak.CustomAgentBase)
- builder.WriteString(", ")
- builder.WriteString("custom_agent_key=")
- builder.WriteString(ak.CustomAgentKey)
- builder.WriteString(", ")
- builder.WriteString("openai_base=")
- builder.WriteString(ak.OpenaiBase)
- builder.WriteString(", ")
- builder.WriteString("openai_key=")
- builder.WriteString(ak.OpenaiKey)
- builder.WriteByte(')')
- return builder.String()
- }
- // ApiKeys is a parsable slice of ApiKey.
- type ApiKeys []*ApiKey
|