// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/district" ) // 系统地区表(中国) type District struct { config `json:"-"` // ID of the ent. // ID | 主键 ID int64 `json:"id,omitempty"` // Create Time | 创建时间 CreatedAt time.Time `json:"created_at,omitempty"` // Update Time | 更新时间 UpdatedAt time.Time `json:"updated_at,omitempty"` // Region Name | 地区名称 Name string `json:"name,omitempty"` // Region ShortName | 地区缩写,省级 ShortName string `json:"short_name,omitempty"` // Region Code | 地区行政编号 Code string `json:"code,omitempty"` // Province Code | 省级行政编号,表示该地区归属 Province string `json:"province,omitempty"` // City Code | 地级行政编号,表示该地区归属 City string `json:"city,omitempty"` // Area Code | 县级行政编号,表示该地区归属 Area string `json:"area,omitempty"` // Street Code | 乡级行政编号,表示该地区归属 Street string `json:"street,omitempty"` // Region Level | 地区级别 1-省、自治区、直辖市 2-地级市、地区、自治州、盟 3-市辖区、县级市、县 4-乡镇 Level uint32 `json:"level,omitempty"` // Latitude | 纬度 Latitude float64 `json:"latitude,omitempty"` // Longitude | 经度 Longitude float64 `json:"longitude,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*District) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case district.FieldLatitude, district.FieldLongitude: values[i] = new(sql.NullFloat64) case district.FieldID, district.FieldLevel: values[i] = new(sql.NullInt64) case district.FieldName, district.FieldShortName, district.FieldCode, district.FieldProvince, district.FieldCity, district.FieldArea, district.FieldStreet: values[i] = new(sql.NullString) case district.FieldCreatedAt, district.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 District fields. func (d *District) 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 district.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } d.ID = int64(value.Int64) case district.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 { d.CreatedAt = value.Time } case district.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 { d.UpdatedAt = value.Time } case district.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { d.Name = value.String } case district.FieldShortName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field short_name", values[i]) } else if value.Valid { d.ShortName = value.String } case district.FieldCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field code", values[i]) } else if value.Valid { d.Code = value.String } case district.FieldProvince: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field province", values[i]) } else if value.Valid { d.Province = value.String } case district.FieldCity: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field city", values[i]) } else if value.Valid { d.City = value.String } case district.FieldArea: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field area", values[i]) } else if value.Valid { d.Area = value.String } case district.FieldStreet: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field street", values[i]) } else if value.Valid { d.Street = value.String } case district.FieldLevel: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field level", values[i]) } else if value.Valid { d.Level = uint32(value.Int64) } case district.FieldLatitude: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field latitude", values[i]) } else if value.Valid { d.Latitude = value.Float64 } case district.FieldLongitude: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field longitude", values[i]) } else if value.Valid { d.Longitude = value.Float64 } default: d.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the District. // This includes values selected through modifiers, order, etc. func (d *District) Value(name string) (ent.Value, error) { return d.selectValues.Get(name) } // Update returns a builder for updating this District. // Note that you need to call District.Unwrap() before calling this method if this District // was returned from a transaction, and the transaction was committed or rolled back. func (d *District) Update() *DistrictUpdateOne { return NewDistrictClient(d.config).UpdateOne(d) } // Unwrap unwraps the District 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 (d *District) Unwrap() *District { _tx, ok := d.config.driver.(*txDriver) if !ok { panic("ent: District is not a transactional entity") } d.config.driver = _tx.drv return d } // String implements the fmt.Stringer. func (d *District) String() string { var builder strings.Builder builder.WriteString("District(") builder.WriteString(fmt.Sprintf("id=%v, ", d.ID)) builder.WriteString("created_at=") builder.WriteString(d.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(d.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(d.Name) builder.WriteString(", ") builder.WriteString("short_name=") builder.WriteString(d.ShortName) builder.WriteString(", ") builder.WriteString("code=") builder.WriteString(d.Code) builder.WriteString(", ") builder.WriteString("province=") builder.WriteString(d.Province) builder.WriteString(", ") builder.WriteString("city=") builder.WriteString(d.City) builder.WriteString(", ") builder.WriteString("area=") builder.WriteString(d.Area) builder.WriteString(", ") builder.WriteString("street=") builder.WriteString(d.Street) builder.WriteString(", ") builder.WriteString("level=") builder.WriteString(fmt.Sprintf("%v", d.Level)) builder.WriteString(", ") builder.WriteString("latitude=") builder.WriteString(fmt.Sprintf("%v", d.Latitude)) builder.WriteString(", ") builder.WriteString("longitude=") builder.WriteString(fmt.Sprintf("%v", d.Longitude)) builder.WriteByte(')') return builder.String() } // Districts is a parsable slice of District. type Districts []*District