| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/Wei-Shaw/sub2api/ent/group"
- "github.com/Wei-Shaw/sub2api/ent/securitypolicykeyword"
- )
- // SecurityPolicyKeyword is the model entity for the SecurityPolicyKeyword schema.
- type SecurityPolicyKeyword struct {
- config `json:"-"`
- // ID of the ent.
- ID int64 `json:"id,omitempty"`
- // CreatedAt holds the value of the "created_at" field.
- CreatedAt time.Time `json:"created_at,omitempty"`
- // UpdatedAt holds the value of the "updated_at" field.
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // DeletedAt holds the value of the "deleted_at" field.
- DeletedAt *time.Time `json:"deleted_at,omitempty"`
- // GroupID holds the value of the "group_id" field.
- GroupID *int64 `json:"group_id,omitempty"`
- // 关键词原文,匹配时大小写不敏感
- Keyword string `json:"keyword,omitempty"`
- // 分类:crack/reverse/pentest/privesc/evasion/custom
- Category string `json:"category,omitempty"`
- // 是否参与匹配
- Enabled bool `json:"enabled,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the SecurityPolicyKeywordQuery when eager-loading is set.
- Edges SecurityPolicyKeywordEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // SecurityPolicyKeywordEdges holds the relations/edges for other nodes in the graph.
- type SecurityPolicyKeywordEdges struct {
- // Group holds the value of the group edge.
- Group *Group `json:"group,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
- }
- // GroupOrErr returns the Group value or an error if the edge
- // was not loaded in eager-loading, or loaded but was not found.
- func (e SecurityPolicyKeywordEdges) GroupOrErr() (*Group, error) {
- if e.Group != nil {
- return e.Group, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: group.Label}
- }
- return nil, &NotLoadedError{edge: "group"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*SecurityPolicyKeyword) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case securitypolicykeyword.FieldEnabled:
- values[i] = new(sql.NullBool)
- case securitypolicykeyword.FieldID, securitypolicykeyword.FieldGroupID:
- values[i] = new(sql.NullInt64)
- case securitypolicykeyword.FieldKeyword, securitypolicykeyword.FieldCategory:
- values[i] = new(sql.NullString)
- case securitypolicykeyword.FieldCreatedAt, securitypolicykeyword.FieldUpdatedAt, securitypolicykeyword.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 SecurityPolicyKeyword fields.
- func (_m *SecurityPolicyKeyword) 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 securitypolicykeyword.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- _m.ID = int64(value.Int64)
- case securitypolicykeyword.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 {
- _m.CreatedAt = value.Time
- }
- case securitypolicykeyword.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 {
- _m.UpdatedAt = value.Time
- }
- case securitypolicykeyword.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 {
- _m.DeletedAt = new(time.Time)
- *_m.DeletedAt = value.Time
- }
- case securitypolicykeyword.FieldGroupID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field group_id", values[i])
- } else if value.Valid {
- _m.GroupID = new(int64)
- *_m.GroupID = value.Int64
- }
- case securitypolicykeyword.FieldKeyword:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field keyword", values[i])
- } else if value.Valid {
- _m.Keyword = value.String
- }
- case securitypolicykeyword.FieldCategory:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field category", values[i])
- } else if value.Valid {
- _m.Category = value.String
- }
- case securitypolicykeyword.FieldEnabled:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field enabled", values[i])
- } else if value.Valid {
- _m.Enabled = value.Bool
- }
- default:
- _m.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the SecurityPolicyKeyword.
- // This includes values selected through modifiers, order, etc.
- func (_m *SecurityPolicyKeyword) Value(name string) (ent.Value, error) {
- return _m.selectValues.Get(name)
- }
- // QueryGroup queries the "group" edge of the SecurityPolicyKeyword entity.
- func (_m *SecurityPolicyKeyword) QueryGroup() *GroupQuery {
- return NewSecurityPolicyKeywordClient(_m.config).QueryGroup(_m)
- }
- // Update returns a builder for updating this SecurityPolicyKeyword.
- // Note that you need to call SecurityPolicyKeyword.Unwrap() before calling this method if this SecurityPolicyKeyword
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (_m *SecurityPolicyKeyword) Update() *SecurityPolicyKeywordUpdateOne {
- return NewSecurityPolicyKeywordClient(_m.config).UpdateOne(_m)
- }
- // Unwrap unwraps the SecurityPolicyKeyword 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 (_m *SecurityPolicyKeyword) Unwrap() *SecurityPolicyKeyword {
- _tx, ok := _m.config.driver.(*txDriver)
- if !ok {
- panic("ent: SecurityPolicyKeyword is not a transactional entity")
- }
- _m.config.driver = _tx.drv
- return _m
- }
- // String implements the fmt.Stringer.
- func (_m *SecurityPolicyKeyword) String() string {
- var builder strings.Builder
- builder.WriteString("SecurityPolicyKeyword(")
- builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
- builder.WriteString("created_at=")
- builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- if v := _m.DeletedAt; v != nil {
- builder.WriteString("deleted_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- if v := _m.GroupID; v != nil {
- builder.WriteString("group_id=")
- builder.WriteString(fmt.Sprintf("%v", *v))
- }
- builder.WriteString(", ")
- builder.WriteString("keyword=")
- builder.WriteString(_m.Keyword)
- builder.WriteString(", ")
- builder.WriteString("category=")
- builder.WriteString(_m.Category)
- builder.WriteString(", ")
- builder.WriteString("enabled=")
- builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
- builder.WriteByte(')')
- return builder.String()
- }
- // SecurityPolicyKeywords is a parsable slice of SecurityPolicyKeyword.
- type SecurityPolicyKeywords []*SecurityPolicyKeyword
|