123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/label"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // Label is the model entity for the Label schema.
- type Label 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"`
- // 标签类型:1好友,2群组,3公众号,4企业微信联系人
- Type int `json:"type,omitempty"`
- // 标签名称
- Name string `json:"name,omitempty"`
- // 标签来源:1后台创建 2个微同步
- From int `json:"from,omitempty"`
- // 标签模式:1动态 2静态
- Mode int `json:"mode,omitempty"`
- // 标签的触达条件
- Conditions string `json:"conditions,omitempty"`
- // 机构 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 LabelQuery when eager-loading is set.
- Edges LabelEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // LabelEdges holds the relations/edges for other nodes in the graph.
- type LabelEdges struct {
- // LabelRelationships holds the value of the label_relationships edge.
- LabelRelationships []*LabelRelationship `json:"label_relationships,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
- }
- // LabelRelationshipsOrErr returns the LabelRelationships value or an error if the edge
- // was not loaded in eager-loading.
- func (e LabelEdges) LabelRelationshipsOrErr() ([]*LabelRelationship, error) {
- if e.loadedTypes[0] {
- return e.LabelRelationships, nil
- }
- return nil, &NotLoadedError{edge: "label_relationships"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*Label) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case label.FieldID, label.FieldStatus, label.FieldType, label.FieldFrom, label.FieldMode, label.FieldOrganizationID:
- values[i] = new(sql.NullInt64)
- case label.FieldName, label.FieldConditions:
- values[i] = new(sql.NullString)
- case label.FieldCreatedAt, label.FieldUpdatedAt:
- 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 Label fields.
- func (l *Label) 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 label.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- l.ID = uint64(value.Int64)
- case label.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 {
- l.CreatedAt = value.Time
- }
- case label.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 {
- l.UpdatedAt = value.Time
- }
- case label.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- l.Status = uint8(value.Int64)
- }
- case label.FieldType:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field type", values[i])
- } else if value.Valid {
- l.Type = int(value.Int64)
- }
- case label.FieldName:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field name", values[i])
- } else if value.Valid {
- l.Name = value.String
- }
- case label.FieldFrom:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field from", values[i])
- } else if value.Valid {
- l.From = int(value.Int64)
- }
- case label.FieldMode:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field mode", values[i])
- } else if value.Valid {
- l.Mode = int(value.Int64)
- }
- case label.FieldConditions:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field conditions", values[i])
- } else if value.Valid {
- l.Conditions = value.String
- }
- case label.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 {
- l.OrganizationID = uint64(value.Int64)
- }
- default:
- l.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the Label.
- // This includes values selected through modifiers, order, etc.
- func (l *Label) Value(name string) (ent.Value, error) {
- return l.selectValues.Get(name)
- }
- // QueryLabelRelationships queries the "label_relationships" edge of the Label entity.
- func (l *Label) QueryLabelRelationships() *LabelRelationshipQuery {
- return NewLabelClient(l.config).QueryLabelRelationships(l)
- }
- // Update returns a builder for updating this Label.
- // Note that you need to call Label.Unwrap() before calling this method if this Label
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (l *Label) Update() *LabelUpdateOne {
- return NewLabelClient(l.config).UpdateOne(l)
- }
- // Unwrap unwraps the Label 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 (l *Label) Unwrap() *Label {
- _tx, ok := l.config.driver.(*txDriver)
- if !ok {
- panic("ent: Label is not a transactional entity")
- }
- l.config.driver = _tx.drv
- return l
- }
- // String implements the fmt.Stringer.
- func (l *Label) String() string {
- var builder strings.Builder
- builder.WriteString("Label(")
- builder.WriteString(fmt.Sprintf("id=%v, ", l.ID))
- builder.WriteString("created_at=")
- builder.WriteString(l.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(l.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", l.Status))
- builder.WriteString(", ")
- builder.WriteString("type=")
- builder.WriteString(fmt.Sprintf("%v", l.Type))
- builder.WriteString(", ")
- builder.WriteString("name=")
- builder.WriteString(l.Name)
- builder.WriteString(", ")
- builder.WriteString("from=")
- builder.WriteString(fmt.Sprintf("%v", l.From))
- builder.WriteString(", ")
- builder.WriteString("mode=")
- builder.WriteString(fmt.Sprintf("%v", l.Mode))
- builder.WriteString(", ")
- builder.WriteString("conditions=")
- builder.WriteString(l.Conditions)
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", l.OrganizationID))
- builder.WriteByte(')')
- return builder.String()
- }
- // Labels is a parsable slice of Label.
- type Labels []*Label
|