// Code generated by ent, DO NOT EDIT.

package ent

import (
	"fmt"
	"strings"
	"time"
	"wechat-api/ent/employeeconfig"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
)

// EmployeeConfig is the model entity for the EmployeeConfig schema.
type EmployeeConfig 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"`
	// 类型:scene-场景 switch_in-接入方式
	Stype string `json:"stype,omitempty"`
	// 标题
	Title string `json:"title,omitempty"`
	// 图片地址
	Photo string `json:"photo,omitempty"`
	// 机构 ID
	OrganizationID uint64 `json:"organization_id,omitempty"`
	selectValues   sql.SelectValues
}

// scanValues returns the types for scanning values from sql.Rows.
func (*EmployeeConfig) scanValues(columns []string) ([]any, error) {
	values := make([]any, len(columns))
	for i := range columns {
		switch columns[i] {
		case employeeconfig.FieldID, employeeconfig.FieldOrganizationID:
			values[i] = new(sql.NullInt64)
		case employeeconfig.FieldStype, employeeconfig.FieldTitle, employeeconfig.FieldPhoto:
			values[i] = new(sql.NullString)
		case employeeconfig.FieldCreatedAt, employeeconfig.FieldUpdatedAt, employeeconfig.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 EmployeeConfig fields.
func (ec *EmployeeConfig) 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 employeeconfig.FieldID:
			value, ok := values[i].(*sql.NullInt64)
			if !ok {
				return fmt.Errorf("unexpected type %T for field id", value)
			}
			ec.ID = uint64(value.Int64)
		case employeeconfig.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 {
				ec.CreatedAt = value.Time
			}
		case employeeconfig.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 {
				ec.UpdatedAt = value.Time
			}
		case employeeconfig.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 {
				ec.DeletedAt = value.Time
			}
		case employeeconfig.FieldStype:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field stype", values[i])
			} else if value.Valid {
				ec.Stype = value.String
			}
		case employeeconfig.FieldTitle:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field title", values[i])
			} else if value.Valid {
				ec.Title = value.String
			}
		case employeeconfig.FieldPhoto:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field photo", values[i])
			} else if value.Valid {
				ec.Photo = value.String
			}
		case employeeconfig.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 {
				ec.OrganizationID = uint64(value.Int64)
			}
		default:
			ec.selectValues.Set(columns[i], values[i])
		}
	}
	return nil
}

// Value returns the ent.Value that was dynamically selected and assigned to the EmployeeConfig.
// This includes values selected through modifiers, order, etc.
func (ec *EmployeeConfig) Value(name string) (ent.Value, error) {
	return ec.selectValues.Get(name)
}

// Update returns a builder for updating this EmployeeConfig.
// Note that you need to call EmployeeConfig.Unwrap() before calling this method if this EmployeeConfig
// was returned from a transaction, and the transaction was committed or rolled back.
func (ec *EmployeeConfig) Update() *EmployeeConfigUpdateOne {
	return NewEmployeeConfigClient(ec.config).UpdateOne(ec)
}

// Unwrap unwraps the EmployeeConfig 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 (ec *EmployeeConfig) Unwrap() *EmployeeConfig {
	_tx, ok := ec.config.driver.(*txDriver)
	if !ok {
		panic("ent: EmployeeConfig is not a transactional entity")
	}
	ec.config.driver = _tx.drv
	return ec
}

// String implements the fmt.Stringer.
func (ec *EmployeeConfig) String() string {
	var builder strings.Builder
	builder.WriteString("EmployeeConfig(")
	builder.WriteString(fmt.Sprintf("id=%v, ", ec.ID))
	builder.WriteString("created_at=")
	builder.WriteString(ec.CreatedAt.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("updated_at=")
	builder.WriteString(ec.UpdatedAt.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("deleted_at=")
	builder.WriteString(ec.DeletedAt.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("stype=")
	builder.WriteString(ec.Stype)
	builder.WriteString(", ")
	builder.WriteString("title=")
	builder.WriteString(ec.Title)
	builder.WriteString(", ")
	builder.WriteString("photo=")
	builder.WriteString(ec.Photo)
	builder.WriteString(", ")
	builder.WriteString("organization_id=")
	builder.WriteString(fmt.Sprintf("%v", ec.OrganizationID))
	builder.WriteByte(')')
	return builder.String()
}

// EmployeeConfigs is a parsable slice of EmployeeConfig.
type EmployeeConfigs []*EmployeeConfig