123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "encoding/json"
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/allocagent"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // AllocAgent is the model entity for the AllocAgent schema.
- type AllocAgent 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"`
- // user_id | 前台用户ID
- UserID string `json:"user_id,omitempty"`
- // organization_id | 租户ID
- OrganizationID uint64 `json:"organization_id,omitempty"`
- // agents | 分配的智能体IDs
- Agents []uint64 `json:"agents,omitempty"`
- // status | 状态 1-正常 2-禁用
- Status int `json:"status,omitempty"`
- selectValues sql.SelectValues
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*AllocAgent) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case allocagent.FieldAgents:
- values[i] = new([]byte)
- case allocagent.FieldID, allocagent.FieldOrganizationID, allocagent.FieldStatus:
- values[i] = new(sql.NullInt64)
- case allocagent.FieldUserID:
- values[i] = new(sql.NullString)
- case allocagent.FieldCreatedAt, allocagent.FieldUpdatedAt, allocagent.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 AllocAgent fields.
- func (aa *AllocAgent) 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 allocagent.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- aa.ID = uint64(value.Int64)
- case allocagent.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 {
- aa.CreatedAt = value.Time
- }
- case allocagent.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 {
- aa.UpdatedAt = value.Time
- }
- case allocagent.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 {
- aa.DeletedAt = value.Time
- }
- case allocagent.FieldUserID:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field user_id", values[i])
- } else if value.Valid {
- aa.UserID = value.String
- }
- case allocagent.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 {
- aa.OrganizationID = uint64(value.Int64)
- }
- case allocagent.FieldAgents:
- if value, ok := values[i].(*[]byte); !ok {
- return fmt.Errorf("unexpected type %T for field agents", values[i])
- } else if value != nil && len(*value) > 0 {
- if err := json.Unmarshal(*value, &aa.Agents); err != nil {
- return fmt.Errorf("unmarshal field agents: %w", err)
- }
- }
- case allocagent.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- aa.Status = int(value.Int64)
- }
- default:
- aa.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the AllocAgent.
- // This includes values selected through modifiers, order, etc.
- func (aa *AllocAgent) Value(name string) (ent.Value, error) {
- return aa.selectValues.Get(name)
- }
- // Update returns a builder for updating this AllocAgent.
- // Note that you need to call AllocAgent.Unwrap() before calling this method if this AllocAgent
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (aa *AllocAgent) Update() *AllocAgentUpdateOne {
- return NewAllocAgentClient(aa.config).UpdateOne(aa)
- }
- // Unwrap unwraps the AllocAgent 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 (aa *AllocAgent) Unwrap() *AllocAgent {
- _tx, ok := aa.config.driver.(*txDriver)
- if !ok {
- panic("ent: AllocAgent is not a transactional entity")
- }
- aa.config.driver = _tx.drv
- return aa
- }
- // String implements the fmt.Stringer.
- func (aa *AllocAgent) String() string {
- var builder strings.Builder
- builder.WriteString("AllocAgent(")
- builder.WriteString(fmt.Sprintf("id=%v, ", aa.ID))
- builder.WriteString("created_at=")
- builder.WriteString(aa.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(aa.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(aa.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("user_id=")
- builder.WriteString(aa.UserID)
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", aa.OrganizationID))
- builder.WriteString(", ")
- builder.WriteString("agents=")
- builder.WriteString(fmt.Sprintf("%v", aa.Agents))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", aa.Status))
- builder.WriteByte(')')
- return builder.String()
- }
- // AllocAgents is a parsable slice of AllocAgent.
- type AllocAgents []*AllocAgent
|