261 lines
9.1 KiB
Go
261 lines
9.1 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/hibp"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// HIBP is the model entity for the HIBP schema.
|
|
type HIBP struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Domain holds the value of the "domain" field.
|
|
Domain string `json:"domain,omitempty"`
|
|
// BreachDate holds the value of the "breach_date" field.
|
|
BreachDate time.Time `json:"breach_date,omitempty"`
|
|
// AddedDate holds the value of the "added_date" field.
|
|
AddedDate time.Time `json:"added_date,omitempty"`
|
|
// ModifiedDate holds the value of the "modified_date" field.
|
|
ModifiedDate time.Time `json:"modified_date,omitempty"`
|
|
// PwnCount holds the value of the "pwn_count" field.
|
|
PwnCount int `json:"pwn_count,omitempty"`
|
|
// May contain HTML markup
|
|
Description string `json:"description,omitempty"`
|
|
// Dataclasses holds the value of the "dataclasses" field.
|
|
Dataclasses []string `json:"dataclasses,omitempty"`
|
|
// IsVerified holds the value of the "is_verified" field.
|
|
IsVerified bool `json:"is_verified,omitempty"`
|
|
// IsFabricated holds the value of the "is_fabricated" field.
|
|
IsFabricated bool `json:"is_fabricated,omitempty"`
|
|
// IsSensitive holds the value of the "is_sensitive" field.
|
|
IsSensitive bool `json:"is_sensitive,omitempty"`
|
|
// IsRetired holds the value of the "is_retired" field.
|
|
IsRetired bool `json:"is_retired,omitempty"`
|
|
// IsSpamList holds the value of the "is_spamList" field.
|
|
IsSpamList bool `json:"is_spamList,omitempty"`
|
|
// IsMalware holds the value of the "is_malware" field.
|
|
IsMalware bool `json:"is_malware,omitempty"`
|
|
// Always in PNG format
|
|
Logo string `json:"logo,omitempty"`
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*HIBP) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case hibp.FieldDataclasses:
|
|
values[i] = new([]byte)
|
|
case hibp.FieldIsVerified, hibp.FieldIsFabricated, hibp.FieldIsSensitive, hibp.FieldIsRetired, hibp.FieldIsSpamList, hibp.FieldIsMalware:
|
|
values[i] = new(sql.NullBool)
|
|
case hibp.FieldPwnCount:
|
|
values[i] = new(sql.NullInt64)
|
|
case hibp.FieldName, hibp.FieldDomain, hibp.FieldDescription, hibp.FieldLogo:
|
|
values[i] = new(sql.NullString)
|
|
case hibp.FieldBreachDate, hibp.FieldAddedDate, hibp.FieldModifiedDate:
|
|
values[i] = new(sql.NullTime)
|
|
case hibp.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
return nil, fmt.Errorf("unexpected column %q for type HIBP", columns[i])
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the HIBP fields.
|
|
func (h *HIBP) 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 hibp.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
h.ID = *value
|
|
}
|
|
case hibp.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
h.Name = value.String
|
|
}
|
|
case hibp.FieldDomain:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field domain", values[i])
|
|
} else if value.Valid {
|
|
h.Domain = value.String
|
|
}
|
|
case hibp.FieldBreachDate:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field breach_date", values[i])
|
|
} else if value.Valid {
|
|
h.BreachDate = value.Time
|
|
}
|
|
case hibp.FieldAddedDate:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field added_date", values[i])
|
|
} else if value.Valid {
|
|
h.AddedDate = value.Time
|
|
}
|
|
case hibp.FieldModifiedDate:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field modified_date", values[i])
|
|
} else if value.Valid {
|
|
h.ModifiedDate = value.Time
|
|
}
|
|
case hibp.FieldPwnCount:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field pwn_count", values[i])
|
|
} else if value.Valid {
|
|
h.PwnCount = int(value.Int64)
|
|
}
|
|
case hibp.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
h.Description = value.String
|
|
}
|
|
case hibp.FieldDataclasses:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field dataclasses", values[i])
|
|
} else if value != nil && len(*value) > 0 {
|
|
if err := json.Unmarshal(*value, &h.Dataclasses); err != nil {
|
|
return fmt.Errorf("unmarshal field dataclasses: %w", err)
|
|
}
|
|
}
|
|
case hibp.FieldIsVerified:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_verified", values[i])
|
|
} else if value.Valid {
|
|
h.IsVerified = value.Bool
|
|
}
|
|
case hibp.FieldIsFabricated:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_fabricated", values[i])
|
|
} else if value.Valid {
|
|
h.IsFabricated = value.Bool
|
|
}
|
|
case hibp.FieldIsSensitive:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_sensitive", values[i])
|
|
} else if value.Valid {
|
|
h.IsSensitive = value.Bool
|
|
}
|
|
case hibp.FieldIsRetired:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_retired", values[i])
|
|
} else if value.Valid {
|
|
h.IsRetired = value.Bool
|
|
}
|
|
case hibp.FieldIsSpamList:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_spamList", values[i])
|
|
} else if value.Valid {
|
|
h.IsSpamList = value.Bool
|
|
}
|
|
case hibp.FieldIsMalware:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_malware", values[i])
|
|
} else if value.Valid {
|
|
h.IsMalware = value.Bool
|
|
}
|
|
case hibp.FieldLogo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field logo", values[i])
|
|
} else if value.Valid {
|
|
h.Logo = value.String
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Update returns a builder for updating this HIBP.
|
|
// Note that you need to call HIBP.Unwrap() before calling this method if this HIBP
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (h *HIBP) Update() *HIBPUpdateOne {
|
|
return NewHIBPClient(h.config).UpdateOne(h)
|
|
}
|
|
|
|
// Unwrap unwraps the HIBP 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 (h *HIBP) Unwrap() *HIBP {
|
|
_tx, ok := h.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: HIBP is not a transactional entity")
|
|
}
|
|
h.config.driver = _tx.drv
|
|
return h
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (h *HIBP) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("HIBP(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", h.ID))
|
|
builder.WriteString("name=")
|
|
builder.WriteString(h.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("domain=")
|
|
builder.WriteString(h.Domain)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("breach_date=")
|
|
builder.WriteString(h.BreachDate.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("added_date=")
|
|
builder.WriteString(h.AddedDate.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("modified_date=")
|
|
builder.WriteString(h.ModifiedDate.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("pwn_count=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.PwnCount))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(h.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("dataclasses=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.Dataclasses))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_verified=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsVerified))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_fabricated=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsFabricated))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_sensitive=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsSensitive))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_retired=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsRetired))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_spamList=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsSpamList))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_malware=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IsMalware))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("logo=")
|
|
builder.WriteString(h.Logo)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// HIBPs is a parsable slice of HIBP.
|
|
type HIBPs []*HIBP
|