From f1bfdf41fba237966623753759e9994803ba90d6 Mon Sep 17 00:00:00 2001 From: syui Date: Sat, 3 Feb 2024 15:48:28 +0900 Subject: [PATCH] update game ue --- ent/client.go | 164 +- ent/ent.go | 2 + ent/hook/hook.go | 12 + ent/migrate/schema.go | 42 +- ent/mutation.go | 2178 +++++++++++++- ent/ogent/oas_client_gen.go | 630 ++++ ent/ogent/oas_handlers_gen.go | 741 +++++ ent/ogent/oas_interfaces_gen.go | 28 + ent/ogent/oas_json_gen.go | 3752 +++++++++++++++++++++++- ent/ogent/oas_parameters_gen.go | 580 ++++ ent/ogent/oas_request_decoders_gen.go | 126 + ent/ogent/oas_request_encoders_gen.go | 28 + ent/ogent/oas_response_decoders_gen.go | 1200 ++++++++ ent/ogent/oas_response_encoders_gen.go | 451 +++ ent/ogent/oas_router_gen.go | 469 ++- ent/ogent/oas_schemas_gen.go | 2014 +++++++++++++ ent/ogent/oas_server_gen.go | 42 + ent/ogent/oas_unimplemented_gen.go | 63 + ent/ogent/oas_validators_gen.go | 12 + ent/ogent/ogent.go | 539 +++- ent/ogent/responses.go | 292 ++ ent/openapi.json | 1028 +++++++ ent/predicate/predicate.go | 3 + ent/runtime.go | 23 + ent/schema/ue.go | 95 + ent/schema/user.go | 2 + ent/tx.go | 3 + ent/ue.go | 335 +++ ent/ue/ue.go | 121 + ent/ue/where.go | 1160 ++++++++ ent/ue_create.go | 563 ++++ ent/ue_delete.go | 88 + ent/ue_query.go | 613 ++++ ent/ue_update.go | 1400 +++++++++ ent/user.go | 18 +- ent/user/user.go | 9 + ent/user/where.go | 27 + ent/user_create.go | 32 + ent/user_query.go | 77 +- ent/user_update.go | 163 + main.go | 2 +- tmp/game_account.zsh | 2 +- tmp/ogent/oas_response_encoders_gen.go | 451 +++ tmp/ogent/ogent.go | 539 +++- tmp/ue_add_test.zsh | 18 + tmp/user_json.zsh | 4 +- 46 files changed, 19827 insertions(+), 314 deletions(-) create mode 100644 ent/schema/ue.go create mode 100644 ent/ue.go create mode 100644 ent/ue/ue.go create mode 100644 ent/ue/where.go create mode 100644 ent/ue_create.go create mode 100644 ent/ue_delete.go create mode 100644 ent/ue_query.go create mode 100644 ent/ue_update.go create mode 100755 tmp/ue_add_test.zsh diff --git a/ent/client.go b/ent/client.go index 4c69383..8788c10 100644 --- a/ent/client.go +++ b/ent/client.go @@ -12,6 +12,7 @@ import ( "t/ent/card" "t/ent/group" + "t/ent/ue" "t/ent/user" "entgo.io/ent" @@ -29,6 +30,8 @@ type Client struct { Card *CardClient // Group is the client for interacting with the Group builders. Group *GroupClient + // Ue is the client for interacting with the Ue builders. + Ue *UeClient // User is the client for interacting with the User builders. User *UserClient } @@ -46,6 +49,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Card = NewCardClient(c.config) c.Group = NewGroupClient(c.config) + c.Ue = NewUeClient(c.config) c.User = NewUserClient(c.config) } @@ -131,6 +135,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, Card: NewCardClient(cfg), Group: NewGroupClient(cfg), + Ue: NewUeClient(cfg), User: NewUserClient(cfg), }, nil } @@ -153,6 +158,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, Card: NewCardClient(cfg), Group: NewGroupClient(cfg), + Ue: NewUeClient(cfg), User: NewUserClient(cfg), }, nil } @@ -184,6 +190,7 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { c.Card.Use(hooks...) c.Group.Use(hooks...) + c.Ue.Use(hooks...) c.User.Use(hooks...) } @@ -192,6 +199,7 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { c.Card.Intercept(interceptors...) c.Group.Intercept(interceptors...) + c.Ue.Intercept(interceptors...) c.User.Intercept(interceptors...) } @@ -202,6 +210,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Card.mutate(ctx, m) case *GroupMutation: return c.Group.mutate(ctx, m) + case *UeMutation: + return c.Ue.mutate(ctx, m) case *UserMutation: return c.User.mutate(ctx, m) default: @@ -477,6 +487,140 @@ func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, erro } } +// UeClient is a client for the Ue schema. +type UeClient struct { + config +} + +// NewUeClient returns a client for the Ue from the given config. +func NewUeClient(c config) *UeClient { + return &UeClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `ue.Hooks(f(g(h())))`. +func (c *UeClient) Use(hooks ...Hook) { + c.hooks.Ue = append(c.hooks.Ue, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `ue.Intercept(f(g(h())))`. +func (c *UeClient) Intercept(interceptors ...Interceptor) { + c.inters.Ue = append(c.inters.Ue, interceptors...) +} + +// Create returns a builder for creating a Ue entity. +func (c *UeClient) Create() *UeCreate { + mutation := newUeMutation(c.config, OpCreate) + return &UeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Ue entities. +func (c *UeClient) CreateBulk(builders ...*UeCreate) *UeCreateBulk { + return &UeCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Ue. +func (c *UeClient) Update() *UeUpdate { + mutation := newUeMutation(c.config, OpUpdate) + return &UeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UeClient) UpdateOne(u *Ue) *UeUpdateOne { + mutation := newUeMutation(c.config, OpUpdateOne, withUe(u)) + return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UeClient) UpdateOneID(id int) *UeUpdateOne { + mutation := newUeMutation(c.config, OpUpdateOne, withUeID(id)) + return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Ue. +func (c *UeClient) Delete() *UeDelete { + mutation := newUeMutation(c.config, OpDelete) + return &UeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UeClient) DeleteOne(u *Ue) *UeDeleteOne { + return c.DeleteOneID(u.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UeClient) DeleteOneID(id int) *UeDeleteOne { + builder := c.Delete().Where(ue.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UeDeleteOne{builder} +} + +// Query returns a query builder for Ue. +func (c *UeClient) Query() *UeQuery { + return &UeQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUe}, + inters: c.Interceptors(), + } +} + +// Get returns a Ue entity by its id. +func (c *UeClient) Get(ctx context.Context, id int) (*Ue, error) { + return c.Query().Where(ue.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UeClient) GetX(ctx context.Context, id int) *Ue { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryOwner queries the owner edge of a Ue. +func (c *UeClient) QueryOwner(u *Ue) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(ue.Table, ue.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UeClient) Hooks() []Hook { + return c.hooks.Ue +} + +// Interceptors returns the client interceptors. +func (c *UeClient) Interceptors() []Interceptor { + return c.inters.Ue +} + +func (c *UeClient) mutate(ctx context.Context, m *UeMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Ue mutation op: %q", m.Op()) + } +} + // UserClient is a client for the User schema. type UserClient struct { config @@ -586,6 +730,22 @@ func (c *UserClient) QueryCard(u *User) *CardQuery { return query } +// QueryUe queries the ue edge of a User. +func (c *UserClient) QueryUe(u *User) *UeQuery { + query := (&UeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(ue.Table, ue.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *UserClient) Hooks() []Hook { return c.hooks.User @@ -614,9 +774,9 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Card, Group, User []ent.Hook + Card, Group, Ue, User []ent.Hook } inters struct { - Card, Group, User []ent.Interceptor + Card, Group, Ue, User []ent.Interceptor } ) diff --git a/ent/ent.go b/ent/ent.go index a13f45a..ecd2707 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -9,6 +9,7 @@ import ( "reflect" "t/ent/card" "t/ent/group" + "t/ent/ue" "t/ent/user" "entgo.io/ent" @@ -69,6 +70,7 @@ func columnChecker(table string) func(string) error { checks := map[string]func(string) bool{ card.Table: card.ValidColumn, group.Table: group.ValidColumn, + ue.Table: ue.ValidColumn, user.Table: user.ValidColumn, } check, ok := checks[table] diff --git a/ent/hook/hook.go b/ent/hook/hook.go index f3f88fd..2da55e8 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -32,6 +32,18 @@ func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupMutation", m) } +// The UeFunc type is an adapter to allow the use of ordinary +// function as Ue mutator. +type UeFunc func(context.Context, *ent.UeMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UeMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UeMutation", m) +} + // The UserFunc type is an adapter to allow the use of ordinary // function as User mutator. type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index a45a99a..55420e6 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -56,6 +56,44 @@ var ( }, }, } + // UesColumns holds the columns for the "ues" table. + UesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "limit", Type: field.TypeBool, Nullable: true, Default: false}, + {Name: "limit_boss", Type: field.TypeBool, Nullable: true, Default: false}, + {Name: "limit_item", Type: field.TypeBool, Nullable: true, Default: false}, + {Name: "password", Type: field.TypeString}, + {Name: "lv", Type: field.TypeInt, Nullable: true}, + {Name: "lv_point", Type: field.TypeInt, Nullable: true}, + {Name: "model", Type: field.TypeInt, Nullable: true}, + {Name: "sword", Type: field.TypeInt, Nullable: true}, + {Name: "card", Type: field.TypeInt, Nullable: true}, + {Name: "mode", Type: field.TypeString, Nullable: true}, + {Name: "token", Type: field.TypeString, Nullable: true}, + {Name: "cp", Type: field.TypeInt, Nullable: true}, + {Name: "count", Type: field.TypeInt, Nullable: true}, + {Name: "location_x", Type: field.TypeInt, Nullable: true}, + {Name: "location_y", Type: field.TypeInt, Nullable: true}, + {Name: "location_z", Type: field.TypeInt, Nullable: true}, + {Name: "location_n", Type: field.TypeInt, Nullable: true}, + {Name: "author", Type: field.TypeString, Nullable: true}, + {Name: "created_at", Type: field.TypeTime, Nullable: true}, + {Name: "user_ue", Type: field.TypeInt}, + } + // UesTable holds the schema information for the "ues" table. + UesTable = &schema.Table{ + Name: "ues", + Columns: UesColumns, + PrimaryKey: []*schema.Column{UesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "ues_users_ue", + Columns: []*schema.Column{UesColumns[20]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -91,7 +129,7 @@ var ( {Name: "ten_post", Type: field.TypeString, Nullable: true}, {Name: "ten_get", Type: field.TypeString, Nullable: true}, {Name: "ten_at", Type: field.TypeTime, Nullable: true}, - {Name: "next", Type: field.TypeString, Nullable: true, Default: "20231231"}, + {Name: "next", Type: field.TypeString, Nullable: true, Default: "20240203"}, {Name: "room", Type: field.TypeInt, Nullable: true}, {Name: "model", Type: field.TypeBool, Nullable: true}, {Name: "model_at", Type: field.TypeTime, Nullable: true}, @@ -133,11 +171,13 @@ var ( Tables = []*schema.Table{ CardsTable, GroupsTable, + UesTable, UsersTable, } ) func init() { CardsTable.ForeignKeys[0].RefTable = UsersTable + UesTable.ForeignKeys[0].RefTable = UsersTable UsersTable.ForeignKeys[0].RefTable = GroupsTable } diff --git a/ent/mutation.go b/ent/mutation.go index 9c3db07..d6cb5a4 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -10,6 +10,7 @@ import ( "t/ent/card" "t/ent/group" "t/ent/predicate" + "t/ent/ue" "t/ent/user" "time" @@ -28,6 +29,7 @@ const ( // Node types. TypeCard = "Card" TypeGroup = "Group" + TypeUe = "Ue" TypeUser = "User" ) @@ -1662,6 +1664,2093 @@ func (m *GroupMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Group edge %s", name) } +// UeMutation represents an operation that mutates the Ue nodes in the graph. +type UeMutation struct { + config + op Op + typ string + id *int + _limit *bool + limit_boss *bool + limit_item *bool + password *string + lv *int + addlv *int + lv_point *int + addlv_point *int + model *int + addmodel *int + sword *int + addsword *int + card *int + addcard *int + mode *string + token *string + cp *int + addcp *int + count *int + addcount *int + location_x *int + addlocation_x *int + location_y *int + addlocation_y *int + location_z *int + addlocation_z *int + location_n *int + addlocation_n *int + author *string + created_at *time.Time + clearedFields map[string]struct{} + owner *int + clearedowner bool + done bool + oldValue func(context.Context) (*Ue, error) + predicates []predicate.Ue +} + +var _ ent.Mutation = (*UeMutation)(nil) + +// ueOption allows management of the mutation configuration using functional options. +type ueOption func(*UeMutation) + +// newUeMutation creates new mutation for the Ue entity. +func newUeMutation(c config, op Op, opts ...ueOption) *UeMutation { + m := &UeMutation{ + config: c, + op: op, + typ: TypeUe, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUeID sets the ID field of the mutation. +func withUeID(id int) ueOption { + return func(m *UeMutation) { + var ( + err error + once sync.Once + value *Ue + ) + m.oldValue = func(ctx context.Context) (*Ue, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Ue.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUe sets the old Ue of the mutation. +func withUe(node *Ue) ueOption { + return func(m *UeMutation) { + m.oldValue = func(context.Context) (*Ue, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UeMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UeMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UeMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UeMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Ue.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetLimit sets the "limit" field. +func (m *UeMutation) SetLimit(b bool) { + m._limit = &b +} + +// Limit returns the value of the "limit" field in the mutation. +func (m *UeMutation) Limit() (r bool, exists bool) { + v := m._limit + if v == nil { + return + } + return *v, true +} + +// OldLimit returns the old "limit" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLimit(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLimit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLimit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLimit: %w", err) + } + return oldValue.Limit, nil +} + +// ClearLimit clears the value of the "limit" field. +func (m *UeMutation) ClearLimit() { + m._limit = nil + m.clearedFields[ue.FieldLimit] = struct{}{} +} + +// LimitCleared returns if the "limit" field was cleared in this mutation. +func (m *UeMutation) LimitCleared() bool { + _, ok := m.clearedFields[ue.FieldLimit] + return ok +} + +// ResetLimit resets all changes to the "limit" field. +func (m *UeMutation) ResetLimit() { + m._limit = nil + delete(m.clearedFields, ue.FieldLimit) +} + +// SetLimitBoss sets the "limit_boss" field. +func (m *UeMutation) SetLimitBoss(b bool) { + m.limit_boss = &b +} + +// LimitBoss returns the value of the "limit_boss" field in the mutation. +func (m *UeMutation) LimitBoss() (r bool, exists bool) { + v := m.limit_boss + if v == nil { + return + } + return *v, true +} + +// OldLimitBoss returns the old "limit_boss" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLimitBoss(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLimitBoss is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLimitBoss requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLimitBoss: %w", err) + } + return oldValue.LimitBoss, nil +} + +// ClearLimitBoss clears the value of the "limit_boss" field. +func (m *UeMutation) ClearLimitBoss() { + m.limit_boss = nil + m.clearedFields[ue.FieldLimitBoss] = struct{}{} +} + +// LimitBossCleared returns if the "limit_boss" field was cleared in this mutation. +func (m *UeMutation) LimitBossCleared() bool { + _, ok := m.clearedFields[ue.FieldLimitBoss] + return ok +} + +// ResetLimitBoss resets all changes to the "limit_boss" field. +func (m *UeMutation) ResetLimitBoss() { + m.limit_boss = nil + delete(m.clearedFields, ue.FieldLimitBoss) +} + +// SetLimitItem sets the "limit_item" field. +func (m *UeMutation) SetLimitItem(b bool) { + m.limit_item = &b +} + +// LimitItem returns the value of the "limit_item" field in the mutation. +func (m *UeMutation) LimitItem() (r bool, exists bool) { + v := m.limit_item + if v == nil { + return + } + return *v, true +} + +// OldLimitItem returns the old "limit_item" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLimitItem(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLimitItem is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLimitItem requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLimitItem: %w", err) + } + return oldValue.LimitItem, nil +} + +// ClearLimitItem clears the value of the "limit_item" field. +func (m *UeMutation) ClearLimitItem() { + m.limit_item = nil + m.clearedFields[ue.FieldLimitItem] = struct{}{} +} + +// LimitItemCleared returns if the "limit_item" field was cleared in this mutation. +func (m *UeMutation) LimitItemCleared() bool { + _, ok := m.clearedFields[ue.FieldLimitItem] + return ok +} + +// ResetLimitItem resets all changes to the "limit_item" field. +func (m *UeMutation) ResetLimitItem() { + m.limit_item = nil + delete(m.clearedFields, ue.FieldLimitItem) +} + +// SetPassword sets the "password" field. +func (m *UeMutation) SetPassword(s string) { + m.password = &s +} + +// Password returns the value of the "password" field in the mutation. +func (m *UeMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ResetPassword resets all changes to the "password" field. +func (m *UeMutation) ResetPassword() { + m.password = nil +} + +// SetLv sets the "lv" field. +func (m *UeMutation) SetLv(i int) { + m.lv = &i + m.addlv = nil +} + +// Lv returns the value of the "lv" field in the mutation. +func (m *UeMutation) Lv() (r int, exists bool) { + v := m.lv + if v == nil { + return + } + return *v, true +} + +// OldLv returns the old "lv" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLv(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLv is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLv requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLv: %w", err) + } + return oldValue.Lv, nil +} + +// AddLv adds i to the "lv" field. +func (m *UeMutation) AddLv(i int) { + if m.addlv != nil { + *m.addlv += i + } else { + m.addlv = &i + } +} + +// AddedLv returns the value that was added to the "lv" field in this mutation. +func (m *UeMutation) AddedLv() (r int, exists bool) { + v := m.addlv + if v == nil { + return + } + return *v, true +} + +// ClearLv clears the value of the "lv" field. +func (m *UeMutation) ClearLv() { + m.lv = nil + m.addlv = nil + m.clearedFields[ue.FieldLv] = struct{}{} +} + +// LvCleared returns if the "lv" field was cleared in this mutation. +func (m *UeMutation) LvCleared() bool { + _, ok := m.clearedFields[ue.FieldLv] + return ok +} + +// ResetLv resets all changes to the "lv" field. +func (m *UeMutation) ResetLv() { + m.lv = nil + m.addlv = nil + delete(m.clearedFields, ue.FieldLv) +} + +// SetLvPoint sets the "lv_point" field. +func (m *UeMutation) SetLvPoint(i int) { + m.lv_point = &i + m.addlv_point = nil +} + +// LvPoint returns the value of the "lv_point" field in the mutation. +func (m *UeMutation) LvPoint() (r int, exists bool) { + v := m.lv_point + if v == nil { + return + } + return *v, true +} + +// OldLvPoint returns the old "lv_point" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLvPoint(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLvPoint is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLvPoint requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLvPoint: %w", err) + } + return oldValue.LvPoint, nil +} + +// AddLvPoint adds i to the "lv_point" field. +func (m *UeMutation) AddLvPoint(i int) { + if m.addlv_point != nil { + *m.addlv_point += i + } else { + m.addlv_point = &i + } +} + +// AddedLvPoint returns the value that was added to the "lv_point" field in this mutation. +func (m *UeMutation) AddedLvPoint() (r int, exists bool) { + v := m.addlv_point + if v == nil { + return + } + return *v, true +} + +// ClearLvPoint clears the value of the "lv_point" field. +func (m *UeMutation) ClearLvPoint() { + m.lv_point = nil + m.addlv_point = nil + m.clearedFields[ue.FieldLvPoint] = struct{}{} +} + +// LvPointCleared returns if the "lv_point" field was cleared in this mutation. +func (m *UeMutation) LvPointCleared() bool { + _, ok := m.clearedFields[ue.FieldLvPoint] + return ok +} + +// ResetLvPoint resets all changes to the "lv_point" field. +func (m *UeMutation) ResetLvPoint() { + m.lv_point = nil + m.addlv_point = nil + delete(m.clearedFields, ue.FieldLvPoint) +} + +// SetModel sets the "model" field. +func (m *UeMutation) SetModel(i int) { + m.model = &i + m.addmodel = nil +} + +// Model returns the value of the "model" field in the mutation. +func (m *UeMutation) Model() (r int, exists bool) { + v := m.model + if v == nil { + return + } + return *v, true +} + +// OldModel returns the old "model" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldModel(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModel: %w", err) + } + return oldValue.Model, nil +} + +// AddModel adds i to the "model" field. +func (m *UeMutation) AddModel(i int) { + if m.addmodel != nil { + *m.addmodel += i + } else { + m.addmodel = &i + } +} + +// AddedModel returns the value that was added to the "model" field in this mutation. +func (m *UeMutation) AddedModel() (r int, exists bool) { + v := m.addmodel + if v == nil { + return + } + return *v, true +} + +// ClearModel clears the value of the "model" field. +func (m *UeMutation) ClearModel() { + m.model = nil + m.addmodel = nil + m.clearedFields[ue.FieldModel] = struct{}{} +} + +// ModelCleared returns if the "model" field was cleared in this mutation. +func (m *UeMutation) ModelCleared() bool { + _, ok := m.clearedFields[ue.FieldModel] + return ok +} + +// ResetModel resets all changes to the "model" field. +func (m *UeMutation) ResetModel() { + m.model = nil + m.addmodel = nil + delete(m.clearedFields, ue.FieldModel) +} + +// SetSword sets the "sword" field. +func (m *UeMutation) SetSword(i int) { + m.sword = &i + m.addsword = nil +} + +// Sword returns the value of the "sword" field in the mutation. +func (m *UeMutation) Sword() (r int, exists bool) { + v := m.sword + if v == nil { + return + } + return *v, true +} + +// OldSword returns the old "sword" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldSword(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSword: %w", err) + } + return oldValue.Sword, nil +} + +// AddSword adds i to the "sword" field. +func (m *UeMutation) AddSword(i int) { + if m.addsword != nil { + *m.addsword += i + } else { + m.addsword = &i + } +} + +// AddedSword returns the value that was added to the "sword" field in this mutation. +func (m *UeMutation) AddedSword() (r int, exists bool) { + v := m.addsword + if v == nil { + return + } + return *v, true +} + +// ClearSword clears the value of the "sword" field. +func (m *UeMutation) ClearSword() { + m.sword = nil + m.addsword = nil + m.clearedFields[ue.FieldSword] = struct{}{} +} + +// SwordCleared returns if the "sword" field was cleared in this mutation. +func (m *UeMutation) SwordCleared() bool { + _, ok := m.clearedFields[ue.FieldSword] + return ok +} + +// ResetSword resets all changes to the "sword" field. +func (m *UeMutation) ResetSword() { + m.sword = nil + m.addsword = nil + delete(m.clearedFields, ue.FieldSword) +} + +// SetCard sets the "card" field. +func (m *UeMutation) SetCard(i int) { + m.card = &i + m.addcard = nil +} + +// Card returns the value of the "card" field in the mutation. +func (m *UeMutation) Card() (r int, exists bool) { + v := m.card + if v == nil { + return + } + return *v, true +} + +// OldCard returns the old "card" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldCard(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCard is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCard requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCard: %w", err) + } + return oldValue.Card, nil +} + +// AddCard adds i to the "card" field. +func (m *UeMutation) AddCard(i int) { + if m.addcard != nil { + *m.addcard += i + } else { + m.addcard = &i + } +} + +// AddedCard returns the value that was added to the "card" field in this mutation. +func (m *UeMutation) AddedCard() (r int, exists bool) { + v := m.addcard + if v == nil { + return + } + return *v, true +} + +// ClearCard clears the value of the "card" field. +func (m *UeMutation) ClearCard() { + m.card = nil + m.addcard = nil + m.clearedFields[ue.FieldCard] = struct{}{} +} + +// CardCleared returns if the "card" field was cleared in this mutation. +func (m *UeMutation) CardCleared() bool { + _, ok := m.clearedFields[ue.FieldCard] + return ok +} + +// ResetCard resets all changes to the "card" field. +func (m *UeMutation) ResetCard() { + m.card = nil + m.addcard = nil + delete(m.clearedFields, ue.FieldCard) +} + +// SetMode sets the "mode" field. +func (m *UeMutation) SetMode(s string) { + m.mode = &s +} + +// Mode returns the value of the "mode" field in the mutation. +func (m *UeMutation) Mode() (r string, exists bool) { + v := m.mode + if v == nil { + return + } + return *v, true +} + +// OldMode returns the old "mode" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldMode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMode: %w", err) + } + return oldValue.Mode, nil +} + +// ClearMode clears the value of the "mode" field. +func (m *UeMutation) ClearMode() { + m.mode = nil + m.clearedFields[ue.FieldMode] = struct{}{} +} + +// ModeCleared returns if the "mode" field was cleared in this mutation. +func (m *UeMutation) ModeCleared() bool { + _, ok := m.clearedFields[ue.FieldMode] + return ok +} + +// ResetMode resets all changes to the "mode" field. +func (m *UeMutation) ResetMode() { + m.mode = nil + delete(m.clearedFields, ue.FieldMode) +} + +// SetToken sets the "token" field. +func (m *UeMutation) SetToken(s string) { + m.token = &s +} + +// Token returns the value of the "token" field in the mutation. +func (m *UeMutation) Token() (r string, exists bool) { + v := m.token + if v == nil { + return + } + return *v, true +} + +// OldToken returns the old "token" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldToken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldToken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldToken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldToken: %w", err) + } + return oldValue.Token, nil +} + +// ClearToken clears the value of the "token" field. +func (m *UeMutation) ClearToken() { + m.token = nil + m.clearedFields[ue.FieldToken] = struct{}{} +} + +// TokenCleared returns if the "token" field was cleared in this mutation. +func (m *UeMutation) TokenCleared() bool { + _, ok := m.clearedFields[ue.FieldToken] + return ok +} + +// ResetToken resets all changes to the "token" field. +func (m *UeMutation) ResetToken() { + m.token = nil + delete(m.clearedFields, ue.FieldToken) +} + +// SetCp sets the "cp" field. +func (m *UeMutation) SetCp(i int) { + m.cp = &i + m.addcp = nil +} + +// Cp returns the value of the "cp" field in the mutation. +func (m *UeMutation) Cp() (r int, exists bool) { + v := m.cp + if v == nil { + return + } + return *v, true +} + +// OldCp returns the old "cp" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldCp(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCp: %w", err) + } + return oldValue.Cp, nil +} + +// AddCp adds i to the "cp" field. +func (m *UeMutation) AddCp(i int) { + if m.addcp != nil { + *m.addcp += i + } else { + m.addcp = &i + } +} + +// AddedCp returns the value that was added to the "cp" field in this mutation. +func (m *UeMutation) AddedCp() (r int, exists bool) { + v := m.addcp + if v == nil { + return + } + return *v, true +} + +// ClearCp clears the value of the "cp" field. +func (m *UeMutation) ClearCp() { + m.cp = nil + m.addcp = nil + m.clearedFields[ue.FieldCp] = struct{}{} +} + +// CpCleared returns if the "cp" field was cleared in this mutation. +func (m *UeMutation) CpCleared() bool { + _, ok := m.clearedFields[ue.FieldCp] + return ok +} + +// ResetCp resets all changes to the "cp" field. +func (m *UeMutation) ResetCp() { + m.cp = nil + m.addcp = nil + delete(m.clearedFields, ue.FieldCp) +} + +// SetCount sets the "count" field. +func (m *UeMutation) SetCount(i int) { + m.count = &i + m.addcount = nil +} + +// Count returns the value of the "count" field in the mutation. +func (m *UeMutation) Count() (r int, exists bool) { + v := m.count + if v == nil { + return + } + return *v, true +} + +// OldCount returns the old "count" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldCount(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCount: %w", err) + } + return oldValue.Count, nil +} + +// AddCount adds i to the "count" field. +func (m *UeMutation) AddCount(i int) { + if m.addcount != nil { + *m.addcount += i + } else { + m.addcount = &i + } +} + +// AddedCount returns the value that was added to the "count" field in this mutation. +func (m *UeMutation) AddedCount() (r int, exists bool) { + v := m.addcount + if v == nil { + return + } + return *v, true +} + +// ClearCount clears the value of the "count" field. +func (m *UeMutation) ClearCount() { + m.count = nil + m.addcount = nil + m.clearedFields[ue.FieldCount] = struct{}{} +} + +// CountCleared returns if the "count" field was cleared in this mutation. +func (m *UeMutation) CountCleared() bool { + _, ok := m.clearedFields[ue.FieldCount] + return ok +} + +// ResetCount resets all changes to the "count" field. +func (m *UeMutation) ResetCount() { + m.count = nil + m.addcount = nil + delete(m.clearedFields, ue.FieldCount) +} + +// SetLocationX sets the "location_x" field. +func (m *UeMutation) SetLocationX(i int) { + m.location_x = &i + m.addlocation_x = nil +} + +// LocationX returns the value of the "location_x" field in the mutation. +func (m *UeMutation) LocationX() (r int, exists bool) { + v := m.location_x + if v == nil { + return + } + return *v, true +} + +// OldLocationX returns the old "location_x" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLocationX(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocationX is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocationX requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocationX: %w", err) + } + return oldValue.LocationX, nil +} + +// AddLocationX adds i to the "location_x" field. +func (m *UeMutation) AddLocationX(i int) { + if m.addlocation_x != nil { + *m.addlocation_x += i + } else { + m.addlocation_x = &i + } +} + +// AddedLocationX returns the value that was added to the "location_x" field in this mutation. +func (m *UeMutation) AddedLocationX() (r int, exists bool) { + v := m.addlocation_x + if v == nil { + return + } + return *v, true +} + +// ClearLocationX clears the value of the "location_x" field. +func (m *UeMutation) ClearLocationX() { + m.location_x = nil + m.addlocation_x = nil + m.clearedFields[ue.FieldLocationX] = struct{}{} +} + +// LocationXCleared returns if the "location_x" field was cleared in this mutation. +func (m *UeMutation) LocationXCleared() bool { + _, ok := m.clearedFields[ue.FieldLocationX] + return ok +} + +// ResetLocationX resets all changes to the "location_x" field. +func (m *UeMutation) ResetLocationX() { + m.location_x = nil + m.addlocation_x = nil + delete(m.clearedFields, ue.FieldLocationX) +} + +// SetLocationY sets the "location_y" field. +func (m *UeMutation) SetLocationY(i int) { + m.location_y = &i + m.addlocation_y = nil +} + +// LocationY returns the value of the "location_y" field in the mutation. +func (m *UeMutation) LocationY() (r int, exists bool) { + v := m.location_y + if v == nil { + return + } + return *v, true +} + +// OldLocationY returns the old "location_y" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLocationY(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocationY is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocationY requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocationY: %w", err) + } + return oldValue.LocationY, nil +} + +// AddLocationY adds i to the "location_y" field. +func (m *UeMutation) AddLocationY(i int) { + if m.addlocation_y != nil { + *m.addlocation_y += i + } else { + m.addlocation_y = &i + } +} + +// AddedLocationY returns the value that was added to the "location_y" field in this mutation. +func (m *UeMutation) AddedLocationY() (r int, exists bool) { + v := m.addlocation_y + if v == nil { + return + } + return *v, true +} + +// ClearLocationY clears the value of the "location_y" field. +func (m *UeMutation) ClearLocationY() { + m.location_y = nil + m.addlocation_y = nil + m.clearedFields[ue.FieldLocationY] = struct{}{} +} + +// LocationYCleared returns if the "location_y" field was cleared in this mutation. +func (m *UeMutation) LocationYCleared() bool { + _, ok := m.clearedFields[ue.FieldLocationY] + return ok +} + +// ResetLocationY resets all changes to the "location_y" field. +func (m *UeMutation) ResetLocationY() { + m.location_y = nil + m.addlocation_y = nil + delete(m.clearedFields, ue.FieldLocationY) +} + +// SetLocationZ sets the "location_z" field. +func (m *UeMutation) SetLocationZ(i int) { + m.location_z = &i + m.addlocation_z = nil +} + +// LocationZ returns the value of the "location_z" field in the mutation. +func (m *UeMutation) LocationZ() (r int, exists bool) { + v := m.location_z + if v == nil { + return + } + return *v, true +} + +// OldLocationZ returns the old "location_z" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLocationZ(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocationZ is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocationZ requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocationZ: %w", err) + } + return oldValue.LocationZ, nil +} + +// AddLocationZ adds i to the "location_z" field. +func (m *UeMutation) AddLocationZ(i int) { + if m.addlocation_z != nil { + *m.addlocation_z += i + } else { + m.addlocation_z = &i + } +} + +// AddedLocationZ returns the value that was added to the "location_z" field in this mutation. +func (m *UeMutation) AddedLocationZ() (r int, exists bool) { + v := m.addlocation_z + if v == nil { + return + } + return *v, true +} + +// ClearLocationZ clears the value of the "location_z" field. +func (m *UeMutation) ClearLocationZ() { + m.location_z = nil + m.addlocation_z = nil + m.clearedFields[ue.FieldLocationZ] = struct{}{} +} + +// LocationZCleared returns if the "location_z" field was cleared in this mutation. +func (m *UeMutation) LocationZCleared() bool { + _, ok := m.clearedFields[ue.FieldLocationZ] + return ok +} + +// ResetLocationZ resets all changes to the "location_z" field. +func (m *UeMutation) ResetLocationZ() { + m.location_z = nil + m.addlocation_z = nil + delete(m.clearedFields, ue.FieldLocationZ) +} + +// SetLocationN sets the "location_n" field. +func (m *UeMutation) SetLocationN(i int) { + m.location_n = &i + m.addlocation_n = nil +} + +// LocationN returns the value of the "location_n" field in the mutation. +func (m *UeMutation) LocationN() (r int, exists bool) { + v := m.location_n + if v == nil { + return + } + return *v, true +} + +// OldLocationN returns the old "location_n" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldLocationN(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocationN is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocationN requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocationN: %w", err) + } + return oldValue.LocationN, nil +} + +// AddLocationN adds i to the "location_n" field. +func (m *UeMutation) AddLocationN(i int) { + if m.addlocation_n != nil { + *m.addlocation_n += i + } else { + m.addlocation_n = &i + } +} + +// AddedLocationN returns the value that was added to the "location_n" field in this mutation. +func (m *UeMutation) AddedLocationN() (r int, exists bool) { + v := m.addlocation_n + if v == nil { + return + } + return *v, true +} + +// ClearLocationN clears the value of the "location_n" field. +func (m *UeMutation) ClearLocationN() { + m.location_n = nil + m.addlocation_n = nil + m.clearedFields[ue.FieldLocationN] = struct{}{} +} + +// LocationNCleared returns if the "location_n" field was cleared in this mutation. +func (m *UeMutation) LocationNCleared() bool { + _, ok := m.clearedFields[ue.FieldLocationN] + return ok +} + +// ResetLocationN resets all changes to the "location_n" field. +func (m *UeMutation) ResetLocationN() { + m.location_n = nil + m.addlocation_n = nil + delete(m.clearedFields, ue.FieldLocationN) +} + +// SetAuthor sets the "author" field. +func (m *UeMutation) SetAuthor(s string) { + m.author = &s +} + +// Author returns the value of the "author" field in the mutation. +func (m *UeMutation) Author() (r string, exists bool) { + v := m.author + if v == nil { + return + } + return *v, true +} + +// OldAuthor returns the old "author" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldAuthor(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAuthor: %w", err) + } + return oldValue.Author, nil +} + +// ClearAuthor clears the value of the "author" field. +func (m *UeMutation) ClearAuthor() { + m.author = nil + m.clearedFields[ue.FieldAuthor] = struct{}{} +} + +// AuthorCleared returns if the "author" field was cleared in this mutation. +func (m *UeMutation) AuthorCleared() bool { + _, ok := m.clearedFields[ue.FieldAuthor] + return ok +} + +// ResetAuthor resets all changes to the "author" field. +func (m *UeMutation) ResetAuthor() { + m.author = nil + delete(m.clearedFields, ue.FieldAuthor) +} + +// SetCreatedAt sets the "created_at" field. +func (m *UeMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UeMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Ue entity. +// If the Ue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ClearCreatedAt clears the value of the "created_at" field. +func (m *UeMutation) ClearCreatedAt() { + m.created_at = nil + m.clearedFields[ue.FieldCreatedAt] = struct{}{} +} + +// CreatedAtCleared returns if the "created_at" field was cleared in this mutation. +func (m *UeMutation) CreatedAtCleared() bool { + _, ok := m.clearedFields[ue.FieldCreatedAt] + return ok +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *UeMutation) ResetCreatedAt() { + m.created_at = nil + delete(m.clearedFields, ue.FieldCreatedAt) +} + +// SetOwnerID sets the "owner" edge to the User entity by id. +func (m *UeMutation) SetOwnerID(id int) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the User entity. +func (m *UeMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the User entity was cleared. +func (m *UeMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *UeMutation) OwnerID() (id int, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *UeMutation) OwnerIDs() (ids []int) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOwner resets all changes to the "owner" edge. +func (m *UeMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false +} + +// Where appends a list predicates to the UeMutation builder. +func (m *UeMutation) Where(ps ...predicate.Ue) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UeMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UeMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Ue, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UeMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UeMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Ue). +func (m *UeMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UeMutation) Fields() []string { + fields := make([]string, 0, 19) + if m._limit != nil { + fields = append(fields, ue.FieldLimit) + } + if m.limit_boss != nil { + fields = append(fields, ue.FieldLimitBoss) + } + if m.limit_item != nil { + fields = append(fields, ue.FieldLimitItem) + } + if m.password != nil { + fields = append(fields, ue.FieldPassword) + } + if m.lv != nil { + fields = append(fields, ue.FieldLv) + } + if m.lv_point != nil { + fields = append(fields, ue.FieldLvPoint) + } + if m.model != nil { + fields = append(fields, ue.FieldModel) + } + if m.sword != nil { + fields = append(fields, ue.FieldSword) + } + if m.card != nil { + fields = append(fields, ue.FieldCard) + } + if m.mode != nil { + fields = append(fields, ue.FieldMode) + } + if m.token != nil { + fields = append(fields, ue.FieldToken) + } + if m.cp != nil { + fields = append(fields, ue.FieldCp) + } + if m.count != nil { + fields = append(fields, ue.FieldCount) + } + if m.location_x != nil { + fields = append(fields, ue.FieldLocationX) + } + if m.location_y != nil { + fields = append(fields, ue.FieldLocationY) + } + if m.location_z != nil { + fields = append(fields, ue.FieldLocationZ) + } + if m.location_n != nil { + fields = append(fields, ue.FieldLocationN) + } + if m.author != nil { + fields = append(fields, ue.FieldAuthor) + } + if m.created_at != nil { + fields = append(fields, ue.FieldCreatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UeMutation) Field(name string) (ent.Value, bool) { + switch name { + case ue.FieldLimit: + return m.Limit() + case ue.FieldLimitBoss: + return m.LimitBoss() + case ue.FieldLimitItem: + return m.LimitItem() + case ue.FieldPassword: + return m.Password() + case ue.FieldLv: + return m.Lv() + case ue.FieldLvPoint: + return m.LvPoint() + case ue.FieldModel: + return m.Model() + case ue.FieldSword: + return m.Sword() + case ue.FieldCard: + return m.Card() + case ue.FieldMode: + return m.Mode() + case ue.FieldToken: + return m.Token() + case ue.FieldCp: + return m.Cp() + case ue.FieldCount: + return m.Count() + case ue.FieldLocationX: + return m.LocationX() + case ue.FieldLocationY: + return m.LocationY() + case ue.FieldLocationZ: + return m.LocationZ() + case ue.FieldLocationN: + return m.LocationN() + case ue.FieldAuthor: + return m.Author() + case ue.FieldCreatedAt: + return m.CreatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case ue.FieldLimit: + return m.OldLimit(ctx) + case ue.FieldLimitBoss: + return m.OldLimitBoss(ctx) + case ue.FieldLimitItem: + return m.OldLimitItem(ctx) + case ue.FieldPassword: + return m.OldPassword(ctx) + case ue.FieldLv: + return m.OldLv(ctx) + case ue.FieldLvPoint: + return m.OldLvPoint(ctx) + case ue.FieldModel: + return m.OldModel(ctx) + case ue.FieldSword: + return m.OldSword(ctx) + case ue.FieldCard: + return m.OldCard(ctx) + case ue.FieldMode: + return m.OldMode(ctx) + case ue.FieldToken: + return m.OldToken(ctx) + case ue.FieldCp: + return m.OldCp(ctx) + case ue.FieldCount: + return m.OldCount(ctx) + case ue.FieldLocationX: + return m.OldLocationX(ctx) + case ue.FieldLocationY: + return m.OldLocationY(ctx) + case ue.FieldLocationZ: + return m.OldLocationZ(ctx) + case ue.FieldLocationN: + return m.OldLocationN(ctx) + case ue.FieldAuthor: + return m.OldAuthor(ctx) + case ue.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown Ue field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UeMutation) SetField(name string, value ent.Value) error { + switch name { + case ue.FieldLimit: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLimit(v) + return nil + case ue.FieldLimitBoss: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLimitBoss(v) + return nil + case ue.FieldLimitItem: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLimitItem(v) + return nil + case ue.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case ue.FieldLv: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLv(v) + return nil + case ue.FieldLvPoint: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLvPoint(v) + return nil + case ue.FieldModel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModel(v) + return nil + case ue.FieldSword: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSword(v) + return nil + case ue.FieldCard: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCard(v) + return nil + case ue.FieldMode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMode(v) + return nil + case ue.FieldToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetToken(v) + return nil + case ue.FieldCp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCp(v) + return nil + case ue.FieldCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCount(v) + return nil + case ue.FieldLocationX: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocationX(v) + return nil + case ue.FieldLocationY: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocationY(v) + return nil + case ue.FieldLocationZ: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocationZ(v) + return nil + case ue.FieldLocationN: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocationN(v) + return nil + case ue.FieldAuthor: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAuthor(v) + return nil + case ue.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown Ue field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UeMutation) AddedFields() []string { + var fields []string + if m.addlv != nil { + fields = append(fields, ue.FieldLv) + } + if m.addlv_point != nil { + fields = append(fields, ue.FieldLvPoint) + } + if m.addmodel != nil { + fields = append(fields, ue.FieldModel) + } + if m.addsword != nil { + fields = append(fields, ue.FieldSword) + } + if m.addcard != nil { + fields = append(fields, ue.FieldCard) + } + if m.addcp != nil { + fields = append(fields, ue.FieldCp) + } + if m.addcount != nil { + fields = append(fields, ue.FieldCount) + } + if m.addlocation_x != nil { + fields = append(fields, ue.FieldLocationX) + } + if m.addlocation_y != nil { + fields = append(fields, ue.FieldLocationY) + } + if m.addlocation_z != nil { + fields = append(fields, ue.FieldLocationZ) + } + if m.addlocation_n != nil { + fields = append(fields, ue.FieldLocationN) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UeMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case ue.FieldLv: + return m.AddedLv() + case ue.FieldLvPoint: + return m.AddedLvPoint() + case ue.FieldModel: + return m.AddedModel() + case ue.FieldSword: + return m.AddedSword() + case ue.FieldCard: + return m.AddedCard() + case ue.FieldCp: + return m.AddedCp() + case ue.FieldCount: + return m.AddedCount() + case ue.FieldLocationX: + return m.AddedLocationX() + case ue.FieldLocationY: + return m.AddedLocationY() + case ue.FieldLocationZ: + return m.AddedLocationZ() + case ue.FieldLocationN: + return m.AddedLocationN() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UeMutation) AddField(name string, value ent.Value) error { + switch name { + case ue.FieldLv: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLv(v) + return nil + case ue.FieldLvPoint: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLvPoint(v) + return nil + case ue.FieldModel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddModel(v) + return nil + case ue.FieldSword: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSword(v) + return nil + case ue.FieldCard: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCard(v) + return nil + case ue.FieldCp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCp(v) + return nil + case ue.FieldCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCount(v) + return nil + case ue.FieldLocationX: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLocationX(v) + return nil + case ue.FieldLocationY: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLocationY(v) + return nil + case ue.FieldLocationZ: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLocationZ(v) + return nil + case ue.FieldLocationN: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLocationN(v) + return nil + } + return fmt.Errorf("unknown Ue numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UeMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(ue.FieldLimit) { + fields = append(fields, ue.FieldLimit) + } + if m.FieldCleared(ue.FieldLimitBoss) { + fields = append(fields, ue.FieldLimitBoss) + } + if m.FieldCleared(ue.FieldLimitItem) { + fields = append(fields, ue.FieldLimitItem) + } + if m.FieldCleared(ue.FieldLv) { + fields = append(fields, ue.FieldLv) + } + if m.FieldCleared(ue.FieldLvPoint) { + fields = append(fields, ue.FieldLvPoint) + } + if m.FieldCleared(ue.FieldModel) { + fields = append(fields, ue.FieldModel) + } + if m.FieldCleared(ue.FieldSword) { + fields = append(fields, ue.FieldSword) + } + if m.FieldCleared(ue.FieldCard) { + fields = append(fields, ue.FieldCard) + } + if m.FieldCleared(ue.FieldMode) { + fields = append(fields, ue.FieldMode) + } + if m.FieldCleared(ue.FieldToken) { + fields = append(fields, ue.FieldToken) + } + if m.FieldCleared(ue.FieldCp) { + fields = append(fields, ue.FieldCp) + } + if m.FieldCleared(ue.FieldCount) { + fields = append(fields, ue.FieldCount) + } + if m.FieldCleared(ue.FieldLocationX) { + fields = append(fields, ue.FieldLocationX) + } + if m.FieldCleared(ue.FieldLocationY) { + fields = append(fields, ue.FieldLocationY) + } + if m.FieldCleared(ue.FieldLocationZ) { + fields = append(fields, ue.FieldLocationZ) + } + if m.FieldCleared(ue.FieldLocationN) { + fields = append(fields, ue.FieldLocationN) + } + if m.FieldCleared(ue.FieldAuthor) { + fields = append(fields, ue.FieldAuthor) + } + if m.FieldCleared(ue.FieldCreatedAt) { + fields = append(fields, ue.FieldCreatedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UeMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UeMutation) ClearField(name string) error { + switch name { + case ue.FieldLimit: + m.ClearLimit() + return nil + case ue.FieldLimitBoss: + m.ClearLimitBoss() + return nil + case ue.FieldLimitItem: + m.ClearLimitItem() + return nil + case ue.FieldLv: + m.ClearLv() + return nil + case ue.FieldLvPoint: + m.ClearLvPoint() + return nil + case ue.FieldModel: + m.ClearModel() + return nil + case ue.FieldSword: + m.ClearSword() + return nil + case ue.FieldCard: + m.ClearCard() + return nil + case ue.FieldMode: + m.ClearMode() + return nil + case ue.FieldToken: + m.ClearToken() + return nil + case ue.FieldCp: + m.ClearCp() + return nil + case ue.FieldCount: + m.ClearCount() + return nil + case ue.FieldLocationX: + m.ClearLocationX() + return nil + case ue.FieldLocationY: + m.ClearLocationY() + return nil + case ue.FieldLocationZ: + m.ClearLocationZ() + return nil + case ue.FieldLocationN: + m.ClearLocationN() + return nil + case ue.FieldAuthor: + m.ClearAuthor() + return nil + case ue.FieldCreatedAt: + m.ClearCreatedAt() + return nil + } + return fmt.Errorf("unknown Ue nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UeMutation) ResetField(name string) error { + switch name { + case ue.FieldLimit: + m.ResetLimit() + return nil + case ue.FieldLimitBoss: + m.ResetLimitBoss() + return nil + case ue.FieldLimitItem: + m.ResetLimitItem() + return nil + case ue.FieldPassword: + m.ResetPassword() + return nil + case ue.FieldLv: + m.ResetLv() + return nil + case ue.FieldLvPoint: + m.ResetLvPoint() + return nil + case ue.FieldModel: + m.ResetModel() + return nil + case ue.FieldSword: + m.ResetSword() + return nil + case ue.FieldCard: + m.ResetCard() + return nil + case ue.FieldMode: + m.ResetMode() + return nil + case ue.FieldToken: + m.ResetToken() + return nil + case ue.FieldCp: + m.ResetCp() + return nil + case ue.FieldCount: + m.ResetCount() + return nil + case ue.FieldLocationX: + m.ResetLocationX() + return nil + case ue.FieldLocationY: + m.ResetLocationY() + return nil + case ue.FieldLocationZ: + m.ResetLocationZ() + return nil + case ue.FieldLocationN: + m.ResetLocationN() + return nil + case ue.FieldAuthor: + m.ResetAuthor() + return nil + case ue.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown Ue field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UeMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.owner != nil { + edges = append(edges, ue.EdgeOwner) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UeMutation) AddedIDs(name string) []ent.Value { + switch name { + case ue.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UeMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UeMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UeMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedowner { + edges = append(edges, ue.EdgeOwner) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UeMutation) EdgeCleared(name string) bool { + switch name { + case ue.EdgeOwner: + return m.clearedowner + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UeMutation) ClearEdge(name string) error { + switch name { + case ue.EdgeOwner: + m.ClearOwner() + return nil + } + return fmt.Errorf("unknown Ue unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UeMutation) ResetEdge(name string) error { + switch name { + case ue.EdgeOwner: + m.ResetOwner() + return nil + } + return fmt.Errorf("unknown Ue edge %s", name) +} + // UserMutation represents an operation that mutates the User nodes in the graph. type UserMutation struct { config @@ -1734,6 +3823,9 @@ type UserMutation struct { card map[int]struct{} removedcard map[int]struct{} clearedcard bool + ue map[int]struct{} + removedue map[int]struct{} + clearedue bool done bool oldValue func(context.Context) (*User, error) predicates []predicate.User @@ -4483,6 +6575,60 @@ func (m *UserMutation) ResetCard() { m.removedcard = nil } +// AddUeIDs adds the "ue" edge to the Ue entity by ids. +func (m *UserMutation) AddUeIDs(ids ...int) { + if m.ue == nil { + m.ue = make(map[int]struct{}) + } + for i := range ids { + m.ue[ids[i]] = struct{}{} + } +} + +// ClearUe clears the "ue" edge to the Ue entity. +func (m *UserMutation) ClearUe() { + m.clearedue = true +} + +// UeCleared reports if the "ue" edge to the Ue entity was cleared. +func (m *UserMutation) UeCleared() bool { + return m.clearedue +} + +// RemoveUeIDs removes the "ue" edge to the Ue entity by IDs. +func (m *UserMutation) RemoveUeIDs(ids ...int) { + if m.removedue == nil { + m.removedue = make(map[int]struct{}) + } + for i := range ids { + delete(m.ue, ids[i]) + m.removedue[ids[i]] = struct{}{} + } +} + +// RemovedUe returns the removed IDs of the "ue" edge to the Ue entity. +func (m *UserMutation) RemovedUeIDs() (ids []int) { + for id := range m.removedue { + ids = append(ids, id) + } + return +} + +// UeIDs returns the "ue" edge IDs in the mutation. +func (m *UserMutation) UeIDs() (ids []int) { + for id := range m.ue { + ids = append(ids, id) + } + return +} + +// ResetUe resets all changes to the "ue" edge. +func (m *UserMutation) ResetUe() { + m.ue = nil + m.clearedue = false + m.removedue = nil +} + // Where appends a list predicates to the UserMutation builder. func (m *UserMutation) Where(ps ...predicate.User) { m.predicates = append(m.predicates, ps...) @@ -5854,10 +8000,13 @@ func (m *UserMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.card != nil { edges = append(edges, user.EdgeCard) } + if m.ue != nil { + edges = append(edges, user.EdgeUe) + } return edges } @@ -5871,16 +8020,25 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case user.EdgeUe: + ids := make([]ent.Value, 0, len(m.ue)) + for id := range m.ue { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.removedcard != nil { edges = append(edges, user.EdgeCard) } + if m.removedue != nil { + edges = append(edges, user.EdgeUe) + } return edges } @@ -5894,16 +8052,25 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case user.EdgeUe: + ids := make([]ent.Value, 0, len(m.removedue)) + for id := range m.removedue { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.clearedcard { edges = append(edges, user.EdgeCard) } + if m.clearedue { + edges = append(edges, user.EdgeUe) + } return edges } @@ -5913,6 +8080,8 @@ func (m *UserMutation) EdgeCleared(name string) bool { switch name { case user.EdgeCard: return m.clearedcard + case user.EdgeUe: + return m.clearedue } return false } @@ -5932,6 +8101,9 @@ func (m *UserMutation) ResetEdge(name string) error { case user.EdgeCard: m.ResetCard() return nil + case user.EdgeUe: + m.ResetUe() + return nil } return fmt.Errorf("unknown User edge %s", name) } diff --git a/ent/ogent/oas_client_gen.go b/ent/ogent/oas_client_gen.go index a601c7b..9cd8e3f 100644 --- a/ent/ogent/oas_client_gen.go +++ b/ent/ogent/oas_client_gen.go @@ -201,6 +201,77 @@ func (c *Client) sendCreateGroup(ctx context.Context, request *CreateGroupReq) ( return result, nil } +// CreateUe invokes createUe operation. +// +// Creates a new Ue and persists it to storage. +// +// POST /ues +func (c *Client) CreateUe(ctx context.Context, request *CreateUeReq) (CreateUeRes, error) { + res, err := c.sendCreateUe(ctx, request) + _ = res + return res, err +} + +func (c *Client) sendCreateUe(ctx context.Context, request *CreateUeReq) (res CreateUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "CreateUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues" + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "POST", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeCreateUeRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeCreateUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // CreateUser invokes createUser operation. // // Creates a new User and persists it to storage. @@ -436,6 +507,88 @@ func (c *Client) sendDeleteGroup(ctx context.Context, params DeleteGroupParams) return result, nil } +// DeleteUe invokes deleteUe operation. +// +// Deletes the Ue with the requested ID. +// +// DELETE /ues/{id} +func (c *Client) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) { + res, err := c.sendDeleteUe(ctx, params) + _ = res + return res, err +} + +func (c *Client) sendDeleteUe(ctx context.Context, params DeleteUeParams) (res DeleteUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("deleteUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "DeleteUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.IntToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + u.Path += e.Result() + } + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "DELETE", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeDeleteUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // DeleteUser invokes deleteUser operation. // // Deletes the User with the requested ID. @@ -1017,6 +1170,112 @@ func (c *Client) sendListGroupUsers(ctx context.Context, params ListGroupUsersPa return result, nil } +// ListUe invokes listUe operation. +// +// List Ues. +// +// GET /ues +func (c *Client) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) { + res, err := c.sendListUe(ctx, params) + _ = res + return res, err +} + +func (c *Client) sendListUe(ctx context.Context, params ListUeParams) (res ListUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "ListUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues" + + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() + { + // Encode "page" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.Page.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "itemsPerPage" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "itemsPerPage", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.ItemsPerPage.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + u.RawQuery = q.Values().Encode() + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "GET", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeListUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // ListUser invokes listUser operation. // // List Users. @@ -1244,6 +1503,127 @@ func (c *Client) sendListUserCard(ctx context.Context, params ListUserCardParams return result, nil } +// ListUserUe invokes listUserUe operation. +// +// List attached Ues. +// +// GET /users/{id}/ue +func (c *Client) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) { + res, err := c.sendListUserUe(ctx, params) + _ = res + return res, err +} + +func (c *Client) sendListUserUe(ctx context.Context, params ListUserUeParams) (res ListUserUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUserUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "ListUserUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/users/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.IntToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + u.Path += e.Result() + } + u.Path += "/ue" + + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() + { + // Encode "page" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.Page.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "itemsPerPage" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "itemsPerPage", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.ItemsPerPage.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + u.RawQuery = q.Values().Encode() + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "GET", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeListUserUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // ReadCard invokes readCard operation. // // Finds the Card with the requested ID and returns it. @@ -1491,6 +1871,171 @@ func (c *Client) sendReadGroup(ctx context.Context, params ReadGroupParams) (res return result, nil } +// ReadUe invokes readUe operation. +// +// Finds the Ue with the requested ID and returns it. +// +// GET /ues/{id} +func (c *Client) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) { + res, err := c.sendReadUe(ctx, params) + _ = res + return res, err +} + +func (c *Client) sendReadUe(ctx context.Context, params ReadUeParams) (res ReadUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "ReadUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.IntToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + u.Path += e.Result() + } + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "GET", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeReadUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// ReadUeOwner invokes readUeOwner operation. +// +// Find the attached User of the Ue with the given ID. +// +// GET /ues/{id}/owner +func (c *Client) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) { + res, err := c.sendReadUeOwner(ctx, params) + _ = res + return res, err +} + +func (c *Client) sendReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (res ReadUeOwnerRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUeOwner"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "ReadUeOwner", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.IntToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + u.Path += e.Result() + } + u.Path += "/owner" + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "GET", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeReadUeOwnerResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // ReadUser invokes readUser operation. // // Finds the User with the requested ID and returns it. @@ -1743,6 +2288,91 @@ func (c *Client) sendUpdateGroup(ctx context.Context, request *UpdateGroupReq, p return result, nil } +// UpdateUe invokes updateUe operation. +// +// Updates a Ue and persists changes to storage. +// +// PATCH /ues/{id} +func (c *Client) UpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) { + res, err := c.sendUpdateUe(ctx, request, params) + _ = res + return res, err +} + +func (c *Client) sendUpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (res UpdateUeRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateUe"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "UpdateUe", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + u.Path += "/ues/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.IntToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + u.Path += e.Result() + } + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "PATCH", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeUpdateUeRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeUpdateUeResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // UpdateUser invokes updateUser operation. // // Updates a User and persists changes to storage. diff --git a/ent/ogent/oas_handlers_gen.go b/ent/ogent/oas_handlers_gen.go index 073e812..050522e 100644 --- a/ent/ogent/oas_handlers_gen.go +++ b/ent/ogent/oas_handlers_gen.go @@ -221,6 +221,108 @@ func (s *Server) handleCreateGroupRequest(args [0]string, w http.ResponseWriter, } } +// handleCreateUeRequest handles createUe operation. +// +// Creates a new Ue and persists it to storage. +// +// POST /ues +func (s *Server) handleCreateUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createUe"), + semconv.HTTPMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/ues"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "CreateUe", + ID: "createUe", + } + ) + request, close, err := s.decodeCreateUeRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response CreateUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "CreateUe", + OperationID: "createUe", + Body: request, + Params: middleware.Parameters{}, + Raw: r, + } + + type ( + Request = *CreateUeReq + Params = struct{} + Response = CreateUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + nil, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.CreateUe(ctx, request) + return response, err + }, + ) + } else { + response, err = s.h.CreateUe(ctx, request) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeCreateUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleCreateUserRequest handles createUser operation. // // Creates a new User and persists it to storage. @@ -527,6 +629,108 @@ func (s *Server) handleDeleteGroupRequest(args [1]string, w http.ResponseWriter, } } +// handleDeleteUeRequest handles deleteUe operation. +// +// Deletes the Ue with the requested ID. +// +// DELETE /ues/{id} +func (s *Server) handleDeleteUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("deleteUe"), + semconv.HTTPMethodKey.String("DELETE"), + semconv.HTTPRouteKey.String("/ues/{id}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "DeleteUe", + ID: "deleteUe", + } + ) + params, err := decodeDeleteUeParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response DeleteUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "DeleteUe", + OperationID: "deleteUe", + Body: nil, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = DeleteUeParams + Response = DeleteUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackDeleteUeParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.DeleteUe(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.DeleteUe(ctx, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeDeleteUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleDeleteUserRequest handles deleteUser operation. // // Deletes the User with the requested ID. @@ -1155,6 +1359,112 @@ func (s *Server) handleListGroupUsersRequest(args [1]string, w http.ResponseWrit } } +// handleListUeRequest handles listUe operation. +// +// List Ues. +// +// GET /ues +func (s *Server) handleListUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUe"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/ues"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ListUe", + ID: "listUe", + } + ) + params, err := decodeListUeParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ListUe", + OperationID: "listUe", + Body: nil, + Params: middleware.Parameters{ + { + Name: "page", + In: "query", + }: params.Page, + { + Name: "itemsPerPage", + In: "query", + }: params.ItemsPerPage, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListUeParams + Response = ListUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListUeParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListUe(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListUe(ctx, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleListUserRequest handles listUser operation. // // List Users. @@ -1371,6 +1681,116 @@ func (s *Server) handleListUserCardRequest(args [1]string, w http.ResponseWriter } } +// handleListUserUeRequest handles listUserUe operation. +// +// List attached Ues. +// +// GET /users/{id}/ue +func (s *Server) handleListUserUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUserUe"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/users/{id}/ue"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUserUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ListUserUe", + ID: "listUserUe", + } + ) + params, err := decodeListUserUeParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListUserUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ListUserUe", + OperationID: "listUserUe", + Body: nil, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + { + Name: "page", + In: "query", + }: params.Page, + { + Name: "itemsPerPage", + In: "query", + }: params.ItemsPerPage, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListUserUeParams + Response = ListUserUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListUserUeParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListUserUe(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListUserUe(ctx, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListUserUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleReadCardRequest handles readCard operation. // // Finds the Card with the requested ID and returns it. @@ -1677,6 +2097,210 @@ func (s *Server) handleReadGroupRequest(args [1]string, w http.ResponseWriter, r } } +// handleReadUeRequest handles readUe operation. +// +// Finds the Ue with the requested ID and returns it. +// +// GET /ues/{id} +func (s *Server) handleReadUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUe"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/ues/{id}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ReadUe", + ID: "readUe", + } + ) + params, err := decodeReadUeParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ReadUe", + OperationID: "readUe", + Body: nil, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadUeParams + Response = ReadUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadUeParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadUe(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadUe(ctx, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + +// handleReadUeOwnerRequest handles readUeOwner operation. +// +// Find the attached User of the Ue with the given ID. +// +// GET /ues/{id}/owner +func (s *Server) handleReadUeOwnerRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUeOwner"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/ues/{id}/owner"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUeOwner", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ReadUeOwner", + ID: "readUeOwner", + } + ) + params, err := decodeReadUeOwnerParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadUeOwnerRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ReadUeOwner", + OperationID: "readUeOwner", + Body: nil, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadUeOwnerParams + Response = ReadUeOwnerRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadUeOwnerParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadUeOwner(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadUeOwner(ctx, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadUeOwnerResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleReadUserRequest handles readUser operation. // // Finds the User with the requested ID and returns it. @@ -2013,6 +2637,123 @@ func (s *Server) handleUpdateGroupRequest(args [1]string, w http.ResponseWriter, } } +// handleUpdateUeRequest handles updateUe operation. +// +// Updates a Ue and persists changes to storage. +// +// PATCH /ues/{id} +func (s *Server) handleUpdateUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateUe"), + semconv.HTTPMethodKey.String("PATCH"), + semconv.HTTPRouteKey.String("/ues/{id}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateUe", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + s.requests.Add(ctx, 1, otelAttrs...) + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, otelAttrs...) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "UpdateUe", + ID: "updateUe", + } + ) + params, err := decodeUpdateUeParams(args, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + request, close, err := s.decodeUpdateUeRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response UpdateUeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "UpdateUe", + OperationID: "updateUe", + Body: request, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + }, + Raw: r, + } + + type ( + Request = *UpdateUeReq + Params = UpdateUeParams + Response = UpdateUeRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackUpdateUeParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.UpdateUe(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.UpdateUe(ctx, request, params) + } + if err != nil { + recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeUpdateUeResponse(response, w, span); err != nil { + recordError("EncodeResponse", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } +} + // handleUpdateUserRequest handles updateUser operation. // // Updates a User and persists changes to storage. diff --git a/ent/ogent/oas_interfaces_gen.go b/ent/ogent/oas_interfaces_gen.go index eec23f9..41b4b35 100644 --- a/ent/ogent/oas_interfaces_gen.go +++ b/ent/ogent/oas_interfaces_gen.go @@ -9,6 +9,10 @@ type CreateGroupRes interface { createGroupRes() } +type CreateUeRes interface { + createUeRes() +} + type CreateUserRes interface { createUserRes() } @@ -21,6 +25,10 @@ type DeleteGroupRes interface { deleteGroupRes() } +type DeleteUeRes interface { + deleteUeRes() +} + type DeleteUserRes interface { deleteUserRes() } @@ -37,6 +45,10 @@ type ListGroupUsersRes interface { listGroupUsersRes() } +type ListUeRes interface { + listUeRes() +} + type ListUserCardRes interface { listUserCardRes() } @@ -45,6 +57,10 @@ type ListUserRes interface { listUserRes() } +type ListUserUeRes interface { + listUserUeRes() +} + type ReadCardOwnerRes interface { readCardOwnerRes() } @@ -57,6 +73,14 @@ type ReadGroupRes interface { readGroupRes() } +type ReadUeOwnerRes interface { + readUeOwnerRes() +} + +type ReadUeRes interface { + readUeRes() +} + type ReadUserRes interface { readUserRes() } @@ -69,6 +93,10 @@ type UpdateGroupRes interface { updateGroupRes() } +type UpdateUeRes interface { + updateUeRes() +} + type UpdateUserRes interface { updateUserRes() } diff --git a/ent/ogent/oas_json_gen.go b/ent/ogent/oas_json_gen.go index 58be669..0a15679 100644 --- a/ent/ogent/oas_json_gen.go +++ b/ent/ogent/oas_json_gen.go @@ -2232,6 +2232,429 @@ func (s *CreateGroupReq) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *CreateUeReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CreateUeReq) encodeFields(e *jx.Encoder) { + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + + e.FieldStart("password") + e.Str(s.Password) + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Token.Set { + e.FieldStart("token") + s.Token.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + + e.FieldStart("owner") + e.Int(s.Owner) + } +} + +var jsonFieldsNameOfCreateUeReq = [20]string{ + 0: "limit", + 1: "limit_boss", + 2: "limit_item", + 3: "password", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "token", + 11: "cp", + 12: "count", + 13: "location_x", + 14: "location_y", + 15: "location_z", + 16: "location_n", + 17: "author", + 18: "created_at", + 19: "owner", +} + +// Decode decodes CreateUeReq from json. +func (s *CreateUeReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateUeReq to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "password": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + v, err := d.Str() + s.Password = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"password\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "token": + if err := func() error { + s.Token.Reset() + if err := s.Token.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"token\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + case "owner": + requiredBitSet[2] |= 1 << 3 + if err := func() error { + v, err := d.Int() + s.Owner = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"owner\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CreateUeReq") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00001000, + 0b00000000, + 0b00001000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCreateUeReq) { + name = jsonFieldsNameOfCreateUeReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateUeReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateUeReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *CreateUserReq) Encode(e *jx.Encoder) { e.ObjStart() @@ -2531,9 +2954,19 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) { e.ArrEnd() } } + { + if s.Ue != nil { + e.FieldStart("ue") + e.ArrStart() + for _, elem := range s.Ue { + e.Int(elem) + } + e.ArrEnd() + } + } } -var jsonFieldsNameOfCreateUserReq = [48]string{ +var jsonFieldsNameOfCreateUserReq = [49]string{ 0: "username", 1: "did", 2: "member", @@ -2582,6 +3015,7 @@ var jsonFieldsNameOfCreateUserReq = [48]string{ 45: "game_account", 46: "game_lv", 47: "card", + 48: "ue", } // Decode decodes CreateUserReq from json. @@ -2589,7 +3023,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error { if s == nil { return errors.New("invalid: unable to decode CreateUserReq to nil") } - var requiredBitSet [6]uint8 + var requiredBitSet [7]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { @@ -3086,6 +3520,25 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"card\"") } + case "ue": + if err := func() error { + s.Ue = make([]int, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem int + v, err := d.Int() + elem = int(v) + if err != nil { + return err + } + s.Ue = append(s.Ue, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ue\"") + } default: return d.Skip() } @@ -3095,13 +3548,14 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error { } // Validate required fields. var failures []validate.FieldError - for i, mask := range [6]uint8{ + for i, mask := range [7]uint8{ 0b00000001, 0b00001000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00000000, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -4625,6 +5079,56 @@ func (s *ListGroupUsersOKApplicationJSON) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ListUeOKApplicationJSON as json. +func (s ListUeOKApplicationJSON) Encode(e *jx.Encoder) { + unwrapped := []UeList(s) + + e.ArrStart() + for _, elem := range unwrapped { + elem.Encode(e) + } + e.ArrEnd() +} + +// Decode decodes ListUeOKApplicationJSON from json. +func (s *ListUeOKApplicationJSON) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListUeOKApplicationJSON to nil") + } + var unwrapped []UeList + if err := func() error { + unwrapped = make([]UeList, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem UeList + if err := elem.Decode(d); err != nil { + return err + } + unwrapped = append(unwrapped, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListUeOKApplicationJSON(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ListUeOKApplicationJSON) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListUeOKApplicationJSON) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes ListUserCardOKApplicationJSON as json. func (s ListUserCardOKApplicationJSON) Encode(e *jx.Encoder) { unwrapped := []UserCardList(s) @@ -4725,6 +5229,56 @@ func (s *ListUserOKApplicationJSON) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ListUserUeOKApplicationJSON as json. +func (s ListUserUeOKApplicationJSON) Encode(e *jx.Encoder) { + unwrapped := []UserUeList(s) + + e.ArrStart() + for _, elem := range unwrapped { + elem.Encode(e) + } + e.ArrEnd() +} + +// Decode decodes ListUserUeOKApplicationJSON from json. +func (s *ListUserUeOKApplicationJSON) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListUserUeOKApplicationJSON to nil") + } + var unwrapped []UserUeList + if err := func() error { + unwrapped = make([]UserUeList, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem UserUeList + if err := elem.Decode(d); err != nil { + return err + } + unwrapped = append(unwrapped, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListUserUeOKApplicationJSON(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ListUserUeOKApplicationJSON) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListUserUeOKApplicationJSON) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes bool as json. func (o OptBool) Encode(e *jx.Encoder) { if !o.Set { @@ -5401,6 +5955,2426 @@ func (s *R500) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *UeCreate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UeCreate) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUeCreate = [18]string{ + 0: "id", + 1: "limit", + 2: "limit_boss", + 3: "limit_item", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "created_at", +} + +// Decode decodes UeCreate from json. +func (s *UeCreate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UeCreate to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UeCreate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000001, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUeCreate) { + name = jsonFieldsNameOfUeCreate[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UeCreate) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UeCreate) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UeList) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UeList) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUeList = [18]string{ + 0: "id", + 1: "limit", + 2: "limit_boss", + 3: "limit_item", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "created_at", +} + +// Decode decodes UeList from json. +func (s *UeList) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UeList to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UeList") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000001, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUeList) { + name = jsonFieldsNameOfUeList[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UeList) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UeList) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UeOwnerRead) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UeOwnerRead) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + + e.FieldStart("username") + e.Str(s.Username) + } + { + if s.Did.Set { + e.FieldStart("did") + s.Did.Encode(e) + } + } + { + if s.Member.Set { + e.FieldStart("member") + s.Member.Encode(e) + } + } + { + if s.Book.Set { + e.FieldStart("book") + s.Book.Encode(e) + } + } + { + if s.Manga.Set { + e.FieldStart("manga") + s.Manga.Encode(e) + } + } + { + if s.Badge.Set { + e.FieldStart("badge") + s.Badge.Encode(e) + } + } + { + if s.Bsky.Set { + e.FieldStart("bsky") + s.Bsky.Encode(e) + } + } + { + if s.Mastodon.Set { + e.FieldStart("mastodon") + s.Mastodon.Encode(e) + } + } + { + if s.Delete.Set { + e.FieldStart("delete") + s.Delete.Encode(e) + } + } + { + if s.Handle.Set { + e.FieldStart("handle") + s.Handle.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.RaidAt.Set { + e.FieldStart("raid_at") + s.RaidAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.ServerAt.Set { + e.FieldStart("server_at") + s.ServerAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.EggAt.Set { + e.FieldStart("egg_at") + s.EggAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Luck.Set { + e.FieldStart("luck") + s.Luck.Encode(e) + } + } + { + if s.LuckAt.Set { + e.FieldStart("luck_at") + s.LuckAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Like.Set { + e.FieldStart("like") + s.Like.Encode(e) + } + } + { + if s.LikeRank.Set { + e.FieldStart("like_rank") + s.LikeRank.Encode(e) + } + } + { + if s.LikeAt.Set { + e.FieldStart("like_at") + s.LikeAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Fav.Set { + e.FieldStart("fav") + s.Fav.Encode(e) + } + } + { + if s.Ten.Set { + e.FieldStart("ten") + s.Ten.Encode(e) + } + } + { + if s.TenSu.Set { + e.FieldStart("ten_su") + s.TenSu.Encode(e) + } + } + { + if s.TenKai.Set { + e.FieldStart("ten_kai") + s.TenKai.Encode(e) + } + } + { + if s.Aiten.Set { + e.FieldStart("aiten") + s.Aiten.Encode(e) + } + } + { + if s.TenCard.Set { + e.FieldStart("ten_card") + s.TenCard.Encode(e) + } + } + { + if s.TenDelete.Set { + e.FieldStart("ten_delete") + s.TenDelete.Encode(e) + } + } + { + if s.TenPost.Set { + e.FieldStart("ten_post") + s.TenPost.Encode(e) + } + } + { + if s.TenGet.Set { + e.FieldStart("ten_get") + s.TenGet.Encode(e) + } + } + { + if s.TenAt.Set { + e.FieldStart("ten_at") + s.TenAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.Room.Set { + e.FieldStart("room") + s.Room.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.ModelAt.Set { + e.FieldStart("model_at") + s.ModelAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.ModelAttack.Set { + e.FieldStart("model_attack") + s.ModelAttack.Encode(e) + } + } + { + if s.ModelLimit.Set { + e.FieldStart("model_limit") + s.ModelLimit.Encode(e) + } + } + { + if s.ModelSkill.Set { + e.FieldStart("model_skill") + s.ModelSkill.Encode(e) + } + } + { + if s.ModelMode.Set { + e.FieldStart("model_mode") + s.ModelMode.Encode(e) + } + } + { + if s.ModelCritical.Set { + e.FieldStart("model_critical") + s.ModelCritical.Encode(e) + } + } + { + if s.ModelCriticalD.Set { + e.FieldStart("model_critical_d") + s.ModelCriticalD.Encode(e) + } + } + { + if s.Game.Set { + e.FieldStart("game") + s.Game.Encode(e) + } + } + { + if s.GameTest.Set { + e.FieldStart("game_test") + s.GameTest.Encode(e) + } + } + { + if s.GameEnd.Set { + e.FieldStart("game_end") + s.GameEnd.Encode(e) + } + } + { + if s.GameAccount.Set { + e.FieldStart("game_account") + s.GameAccount.Encode(e) + } + } + { + if s.GameLv.Set { + e.FieldStart("game_lv") + s.GameLv.Encode(e) + } + } +} + +var jsonFieldsNameOfUeOwnerRead = [46]string{ + 0: "id", + 1: "username", + 2: "did", + 3: "member", + 4: "book", + 5: "manga", + 6: "badge", + 7: "bsky", + 8: "mastodon", + 9: "delete", + 10: "handle", + 11: "created_at", + 12: "updated_at", + 13: "raid_at", + 14: "server_at", + 15: "egg_at", + 16: "luck", + 17: "luck_at", + 18: "like", + 19: "like_rank", + 20: "like_at", + 21: "fav", + 22: "ten", + 23: "ten_su", + 24: "ten_kai", + 25: "aiten", + 26: "ten_card", + 27: "ten_delete", + 28: "ten_post", + 29: "ten_get", + 30: "ten_at", + 31: "next", + 32: "room", + 33: "model", + 34: "model_at", + 35: "model_attack", + 36: "model_limit", + 37: "model_skill", + 38: "model_mode", + 39: "model_critical", + 40: "model_critical_d", + 41: "game", + 42: "game_test", + 43: "game_end", + 44: "game_account", + 45: "game_lv", +} + +// Decode decodes UeOwnerRead from json. +func (s *UeOwnerRead) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UeOwnerRead to nil") + } + var requiredBitSet [6]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "username": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Username = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"username\"") + } + case "did": + if err := func() error { + s.Did.Reset() + if err := s.Did.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"did\"") + } + case "member": + if err := func() error { + s.Member.Reset() + if err := s.Member.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"member\"") + } + case "book": + if err := func() error { + s.Book.Reset() + if err := s.Book.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"book\"") + } + case "manga": + if err := func() error { + s.Manga.Reset() + if err := s.Manga.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"manga\"") + } + case "badge": + if err := func() error { + s.Badge.Reset() + if err := s.Badge.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"badge\"") + } + case "bsky": + if err := func() error { + s.Bsky.Reset() + if err := s.Bsky.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"bsky\"") + } + case "mastodon": + if err := func() error { + s.Mastodon.Reset() + if err := s.Mastodon.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mastodon\"") + } + case "delete": + if err := func() error { + s.Delete.Reset() + if err := s.Delete.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"delete\"") + } + case "handle": + if err := func() error { + s.Handle.Reset() + if err := s.Handle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"handle\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + case "updated_at": + if err := func() error { + s.UpdatedAt.Reset() + if err := s.UpdatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"updated_at\"") + } + case "raid_at": + if err := func() error { + s.RaidAt.Reset() + if err := s.RaidAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"raid_at\"") + } + case "server_at": + if err := func() error { + s.ServerAt.Reset() + if err := s.ServerAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"server_at\"") + } + case "egg_at": + if err := func() error { + s.EggAt.Reset() + if err := s.EggAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"egg_at\"") + } + case "luck": + if err := func() error { + s.Luck.Reset() + if err := s.Luck.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"luck\"") + } + case "luck_at": + if err := func() error { + s.LuckAt.Reset() + if err := s.LuckAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"luck_at\"") + } + case "like": + if err := func() error { + s.Like.Reset() + if err := s.Like.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"like\"") + } + case "like_rank": + if err := func() error { + s.LikeRank.Reset() + if err := s.LikeRank.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"like_rank\"") + } + case "like_at": + if err := func() error { + s.LikeAt.Reset() + if err := s.LikeAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"like_at\"") + } + case "fav": + if err := func() error { + s.Fav.Reset() + if err := s.Fav.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fav\"") + } + case "ten": + if err := func() error { + s.Ten.Reset() + if err := s.Ten.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten\"") + } + case "ten_su": + if err := func() error { + s.TenSu.Reset() + if err := s.TenSu.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_su\"") + } + case "ten_kai": + if err := func() error { + s.TenKai.Reset() + if err := s.TenKai.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_kai\"") + } + case "aiten": + if err := func() error { + s.Aiten.Reset() + if err := s.Aiten.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"aiten\"") + } + case "ten_card": + if err := func() error { + s.TenCard.Reset() + if err := s.TenCard.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_card\"") + } + case "ten_delete": + if err := func() error { + s.TenDelete.Reset() + if err := s.TenDelete.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_delete\"") + } + case "ten_post": + if err := func() error { + s.TenPost.Reset() + if err := s.TenPost.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_post\"") + } + case "ten_get": + if err := func() error { + s.TenGet.Reset() + if err := s.TenGet.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_get\"") + } + case "ten_at": + if err := func() error { + s.TenAt.Reset() + if err := s.TenAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ten_at\"") + } + case "next": + if err := func() error { + s.Next.Reset() + if err := s.Next.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"next\"") + } + case "room": + if err := func() error { + s.Room.Reset() + if err := s.Room.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"room\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "model_at": + if err := func() error { + s.ModelAt.Reset() + if err := s.ModelAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_at\"") + } + case "model_attack": + if err := func() error { + s.ModelAttack.Reset() + if err := s.ModelAttack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_attack\"") + } + case "model_limit": + if err := func() error { + s.ModelLimit.Reset() + if err := s.ModelLimit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_limit\"") + } + case "model_skill": + if err := func() error { + s.ModelSkill.Reset() + if err := s.ModelSkill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_skill\"") + } + case "model_mode": + if err := func() error { + s.ModelMode.Reset() + if err := s.ModelMode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_mode\"") + } + case "model_critical": + if err := func() error { + s.ModelCritical.Reset() + if err := s.ModelCritical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_critical\"") + } + case "model_critical_d": + if err := func() error { + s.ModelCriticalD.Reset() + if err := s.ModelCriticalD.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model_critical_d\"") + } + case "game": + if err := func() error { + s.Game.Reset() + if err := s.Game.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"game\"") + } + case "game_test": + if err := func() error { + s.GameTest.Reset() + if err := s.GameTest.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"game_test\"") + } + case "game_end": + if err := func() error { + s.GameEnd.Reset() + if err := s.GameEnd.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"game_end\"") + } + case "game_account": + if err := func() error { + s.GameAccount.Reset() + if err := s.GameAccount.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"game_account\"") + } + case "game_lv": + if err := func() error { + s.GameLv.Reset() + if err := s.GameLv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"game_lv\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UeOwnerRead") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [6]uint8{ + 0b00000011, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUeOwnerRead) { + name = jsonFieldsNameOfUeOwnerRead[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UeOwnerRead) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UeOwnerRead) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UeRead) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UeRead) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUeRead = [18]string{ + 0: "id", + 1: "limit", + 2: "limit_boss", + 3: "limit_item", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "created_at", +} + +// Decode decodes UeRead from json. +func (s *UeRead) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UeRead to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UeRead") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000001, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUeRead) { + name = jsonFieldsNameOfUeRead[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UeRead) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UeRead) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UeUpdate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UeUpdate) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUeUpdate = [18]string{ + 0: "id", + 1: "limit", + 2: "limit_boss", + 3: "limit_item", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "created_at", +} + +// Decode decodes UeUpdate from json. +func (s *UeUpdate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UeUpdate to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UeUpdate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000001, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUeUpdate) { + name = jsonFieldsNameOfUeUpdate[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UeUpdate) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UeUpdate) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *UpdateCardReq) Encode(e *jx.Encoder) { e.ObjStart() @@ -5693,6 +8667,358 @@ func (s *UpdateGroupReq) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *UpdateUeReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UpdateUeReq) encodeFields(e *jx.Encoder) { + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Token.Set { + e.FieldStart("token") + s.Token.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.Owner.Set { + e.FieldStart("owner") + s.Owner.Encode(e) + } + } +} + +var jsonFieldsNameOfUpdateUeReq = [18]string{ + 0: "limit", + 1: "limit_boss", + 2: "limit_item", + 3: "lv", + 4: "lv_point", + 5: "model", + 6: "sword", + 7: "card", + 8: "mode", + 9: "token", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "owner", +} + +// Decode decodes UpdateUeReq from json. +func (s *UpdateUeReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateUeReq to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "token": + if err := func() error { + s.Token.Reset() + if err := s.Token.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"token\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "owner": + if err := func() error { + s.Owner.Reset() + if err := s.Owner.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"owner\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UpdateUeReq") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateUeReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateUeReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *UpdateUserReq) Encode(e *jx.Encoder) { e.ObjStart() @@ -5976,9 +9302,19 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) { e.ArrEnd() } } + { + if s.Ue != nil { + e.FieldStart("ue") + e.ArrStart() + for _, elem := range s.Ue { + e.Int(elem) + } + e.ArrEnd() + } + } } -var jsonFieldsNameOfUpdateUserReq = [45]string{ +var jsonFieldsNameOfUpdateUserReq = [46]string{ 0: "did", 1: "member", 2: "book", @@ -6024,6 +9360,7 @@ var jsonFieldsNameOfUpdateUserReq = [45]string{ 42: "game_account", 43: "game_lv", 44: "card", + 45: "ue", } // Decode decodes UpdateUserReq from json. @@ -6493,6 +9830,25 @@ func (s *UpdateUserReq) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"card\"") } + case "ue": + if err := func() error { + s.Ue = make([]int, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem int + v, err := d.Int() + elem = int(v) + if err != nil { + return err + } + s.Ue = append(s.Ue, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ue\"") + } default: return d.Skip() } @@ -9355,6 +12711,394 @@ func (s *UserRead) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *UserUeList) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UserUeList) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.LimitBoss.Set { + e.FieldStart("limit_boss") + s.LimitBoss.Encode(e) + } + } + { + if s.LimitItem.Set { + e.FieldStart("limit_item") + s.LimitItem.Encode(e) + } + } + { + if s.Lv.Set { + e.FieldStart("lv") + s.Lv.Encode(e) + } + } + { + if s.LvPoint.Set { + e.FieldStart("lv_point") + s.LvPoint.Encode(e) + } + } + { + if s.Model.Set { + e.FieldStart("model") + s.Model.Encode(e) + } + } + { + if s.Sword.Set { + e.FieldStart("sword") + s.Sword.Encode(e) + } + } + { + if s.Card.Set { + e.FieldStart("card") + s.Card.Encode(e) + } + } + { + if s.Mode.Set { + e.FieldStart("mode") + s.Mode.Encode(e) + } + } + { + if s.Cp.Set { + e.FieldStart("cp") + s.Cp.Encode(e) + } + } + { + if s.Count.Set { + e.FieldStart("count") + s.Count.Encode(e) + } + } + { + if s.LocationX.Set { + e.FieldStart("location_x") + s.LocationX.Encode(e) + } + } + { + if s.LocationY.Set { + e.FieldStart("location_y") + s.LocationY.Encode(e) + } + } + { + if s.LocationZ.Set { + e.FieldStart("location_z") + s.LocationZ.Encode(e) + } + } + { + if s.LocationN.Set { + e.FieldStart("location_n") + s.LocationN.Encode(e) + } + } + { + if s.Author.Set { + e.FieldStart("author") + s.Author.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUserUeList = [18]string{ + 0: "id", + 1: "limit", + 2: "limit_boss", + 3: "limit_item", + 4: "lv", + 5: "lv_point", + 6: "model", + 7: "sword", + 8: "card", + 9: "mode", + 10: "cp", + 11: "count", + 12: "location_x", + 13: "location_y", + 14: "location_z", + 15: "location_n", + 16: "author", + 17: "created_at", +} + +// Decode decodes UserUeList from json. +func (s *UserUeList) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UserUeList to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ID = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "limit_boss": + if err := func() error { + s.LimitBoss.Reset() + if err := s.LimitBoss.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_boss\"") + } + case "limit_item": + if err := func() error { + s.LimitItem.Reset() + if err := s.LimitItem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit_item\"") + } + case "lv": + if err := func() error { + s.Lv.Reset() + if err := s.Lv.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv\"") + } + case "lv_point": + if err := func() error { + s.LvPoint.Reset() + if err := s.LvPoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lv_point\"") + } + case "model": + if err := func() error { + s.Model.Reset() + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "sword": + if err := func() error { + s.Sword.Reset() + if err := s.Sword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sword\"") + } + case "card": + if err := func() error { + s.Card.Reset() + if err := s.Card.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card\"") + } + case "mode": + if err := func() error { + s.Mode.Reset() + if err := s.Mode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"mode\"") + } + case "cp": + if err := func() error { + s.Cp.Reset() + if err := s.Cp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cp\"") + } + case "count": + if err := func() error { + s.Count.Reset() + if err := s.Count.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"count\"") + } + case "location_x": + if err := func() error { + s.LocationX.Reset() + if err := s.LocationX.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_x\"") + } + case "location_y": + if err := func() error { + s.LocationY.Reset() + if err := s.LocationY.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_y\"") + } + case "location_z": + if err := func() error { + s.LocationZ.Reset() + if err := s.LocationZ.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_z\"") + } + case "location_n": + if err := func() error { + s.LocationN.Reset() + if err := s.LocationN.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location_n\"") + } + case "author": + if err := func() error { + s.Author.Reset() + if err := s.Author.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"author\"") + } + case "created_at": + if err := func() error { + s.CreatedAt.Reset() + if err := s.CreatedAt.Decode(d, json.DecodeDateTime); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UserUeList") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000001, + 0b00000000, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUserUeList) { + name = jsonFieldsNameOfUserUeList[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UserUeList) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UserUeList) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *UserUpdate) Encode(e *jx.Encoder) { e.ObjStart() diff --git a/ent/ogent/oas_parameters_gen.go b/ent/ogent/oas_parameters_gen.go index 9615cd0..16c822f 100644 --- a/ent/ogent/oas_parameters_gen.go +++ b/ent/ogent/oas_parameters_gen.go @@ -139,6 +139,68 @@ func decodeDeleteGroupParams(args [1]string, r *http.Request) (params DeleteGrou return params, nil } +// DeleteUeParams is parameters of deleteUe operation. +type DeleteUeParams struct { + // ID of the Ue. + ID int +} + +func unpackDeleteUeParams(packed middleware.Parameters) (params DeleteUeParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(int) + } + return params +} + +func decodeDeleteUeParams(args [1]string, r *http.Request) (params DeleteUeParams, _ error) { + // Decode path: id. + if err := func() error { + param, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + return params, nil +} + // DeleteUserParams is parameters of deleteUser operation. type DeleteUserParams struct { // ID of the User. @@ -820,6 +882,171 @@ func decodeListGroupUsersParams(args [1]string, r *http.Request) (params ListGro return params, nil } +// ListUeParams is parameters of listUe operation. +type ListUeParams struct { + // What page to render. + Page OptInt + // Item count to render per page. + ItemsPerPage OptInt +} + +func unpackListUeParams(packed middleware.Parameters) (params ListUeParams) { + { + key := middleware.ParameterKey{ + Name: "page", + In: "query", + } + if v, ok := packed[key]; ok { + params.Page = v.(OptInt) + } + } + { + key := middleware.ParameterKey{ + Name: "itemsPerPage", + In: "query", + } + if v, ok := packed[key]; ok { + params.ItemsPerPage = v.(OptInt) + } + } + return params +} + +func decodeListUeParams(args [0]string, r *http.Request) (params ListUeParams, _ error) { + q := uri.NewQueryDecoder(r.URL.Query()) + // Decode query: page. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageVal = c + return nil + }(); err != nil { + return err + } + params.Page.SetTo(paramsDotPageVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if params.Page.Set { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(params.Page.Value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page", + In: "query", + Err: err, + } + } + // Decode query: itemsPerPage. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "itemsPerPage", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotItemsPerPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotItemsPerPageVal = c + return nil + }(); err != nil { + return err + } + params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if params.ItemsPerPage.Set { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: true, + Max: 5000, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(params.ItemsPerPage.Value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "itemsPerPage", + In: "query", + Err: err, + } + } + return params, nil +} + // ListUserParams is parameters of listUser operation. type ListUserParams struct { // What page to render. @@ -1152,6 +1379,173 @@ func decodeListUserCardParams(args [1]string, r *http.Request) (params ListUserC return params, nil } +// ListUserUeParams is parameters of listUserUe operation. +type ListUserUeParams struct { + // ID of the User. + ID int + // What page to render. + Page OptInt + // Item count to render per page. + ItemsPerPage OptInt +} + +func unpackListUserUeParams(packed middleware.Parameters) (params ListUserUeParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(int) + } + { + key := middleware.ParameterKey{ + Name: "page", + In: "query", + } + if v, ok := packed[key]; ok { + params.Page = v.(OptInt) + } + } + { + key := middleware.ParameterKey{ + Name: "itemsPerPage", + In: "query", + } + if v, ok := packed[key]; ok { + params.ItemsPerPage = v.(OptInt) + } + } + return params +} + +func decodeListUserUeParams(args [1]string, r *http.Request) (params ListUserUeParams, _ error) { + q := uri.NewQueryDecoder(r.URL.Query()) + // Decode path: id. + if err := func() error { + param, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + // Decode query: page. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageVal = c + return nil + }(); err != nil { + return err + } + params.Page.SetTo(paramsDotPageVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page", + In: "query", + Err: err, + } + } + // Decode query: itemsPerPage. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "itemsPerPage", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotItemsPerPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotItemsPerPageVal = c + return nil + }(); err != nil { + return err + } + params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "itemsPerPage", + In: "query", + Err: err, + } + } + return params, nil +} + // ReadCardParams is parameters of readCard operation. type ReadCardParams struct { // ID of the Card. @@ -1338,6 +1732,130 @@ func decodeReadGroupParams(args [1]string, r *http.Request) (params ReadGroupPar return params, nil } +// ReadUeParams is parameters of readUe operation. +type ReadUeParams struct { + // ID of the Ue. + ID int +} + +func unpackReadUeParams(packed middleware.Parameters) (params ReadUeParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(int) + } + return params +} + +func decodeReadUeParams(args [1]string, r *http.Request) (params ReadUeParams, _ error) { + // Decode path: id. + if err := func() error { + param, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + return params, nil +} + +// ReadUeOwnerParams is parameters of readUeOwner operation. +type ReadUeOwnerParams struct { + // ID of the Ue. + ID int +} + +func unpackReadUeOwnerParams(packed middleware.Parameters) (params ReadUeOwnerParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(int) + } + return params +} + +func decodeReadUeOwnerParams(args [1]string, r *http.Request) (params ReadUeOwnerParams, _ error) { + // Decode path: id. + if err := func() error { + param, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + return params, nil +} + // ReadUserParams is parameters of readUser operation. type ReadUserParams struct { // ID of the User. @@ -1524,6 +2042,68 @@ func decodeUpdateGroupParams(args [1]string, r *http.Request) (params UpdateGrou return params, nil } +// UpdateUeParams is parameters of updateUe operation. +type UpdateUeParams struct { + // ID of the Ue. + ID int +} + +func unpackUpdateUeParams(packed middleware.Parameters) (params UpdateUeParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(int) + } + return params +} + +func decodeUpdateUeParams(args [1]string, r *http.Request) (params UpdateUeParams, _ error) { + // Decode path: id. + if err := func() error { + param, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + return params, nil +} + // UpdateUserParams is parameters of updateUser operation. type UpdateUserParams struct { // ID of the User. diff --git a/ent/ogent/oas_request_decoders_gen.go b/ent/ogent/oas_request_decoders_gen.go index 304ff41..4c026f4 100644 --- a/ent/ogent/oas_request_decoders_gen.go +++ b/ent/ogent/oas_request_decoders_gen.go @@ -141,6 +141,69 @@ func (s *Server) decodeCreateGroupRequest(r *http.Request) ( } } +func (s *Server) decodeCreateUeRequest(r *http.Request) ( + req *CreateUeReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, validate.ErrBodyRequired + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, validate.ErrBodyRequired + } + + d := jx.DecodeBytes(buf) + + var request CreateUeReq + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + return &request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeCreateUserRequest(r *http.Request) ( req *CreateUserReq, close func() error, @@ -330,6 +393,69 @@ func (s *Server) decodeUpdateGroupRequest(r *http.Request) ( } } +func (s *Server) decodeUpdateUeRequest(r *http.Request) ( + req *UpdateUeReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, validate.ErrBodyRequired + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, validate.ErrBodyRequired + } + + d := jx.DecodeBytes(buf) + + var request UpdateUeReq + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + return &request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeUpdateUserRequest(r *http.Request) ( req *UpdateUserReq, close func() error, diff --git a/ent/ogent/oas_request_encoders_gen.go b/ent/ogent/oas_request_encoders_gen.go index 74cd1d0..e755d49 100644 --- a/ent/ogent/oas_request_encoders_gen.go +++ b/ent/ogent/oas_request_encoders_gen.go @@ -39,6 +39,20 @@ func encodeCreateGroupRequest( return nil } +func encodeCreateUeRequest( + req *CreateUeReq, + r *http.Request, +) error { + const contentType = "application/json" + e := jx.GetEncoder() + { + req.Encode(e) + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodeCreateUserRequest( req *CreateUserReq, r *http.Request, @@ -81,6 +95,20 @@ func encodeUpdateGroupRequest( return nil } +func encodeUpdateUeRequest( + req *UpdateUeReq, + r *http.Request, +) error { + const contentType = "application/json" + e := jx.GetEncoder() + { + req.Encode(e) + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodeUpdateUserRequest( req *UpdateUserReq, r *http.Request, diff --git a/ent/ogent/oas_response_decoders_gen.go b/ent/ogent/oas_response_decoders_gen.go index 9db0016..53fbc89 100644 --- a/ent/ogent/oas_response_decoders_gen.go +++ b/ent/ogent/oas_response_decoders_gen.go @@ -306,6 +306,152 @@ func decodeCreateGroupResponse(resp *http.Response) (res CreateGroupRes, err err return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeCreateUeResponse(resp *http.Response) (res CreateUeRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UeCreate + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeCreateUserResponse(resp *http.Response) (res CreateUserRes, err error) { switch resp.StatusCode { case 200: @@ -750,6 +896,155 @@ func decodeDeleteGroupResponse(resp *http.Response) (res DeleteGroupRes, err err return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeDeleteUeResponse(resp *http.Response) (res DeleteUeRes, err error) { + switch resp.StatusCode { + case 204: + // Code 204. + return &DeleteUeNoContent{}, nil + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeDeleteUserResponse(resp *http.Response) (res DeleteUserRes, err error) { switch resp.StatusCode { case 204: @@ -1460,6 +1755,187 @@ func decodeListGroupUsersResponse(resp *http.Response) (res ListGroupUsersRes, e return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeListUeResponse(resp *http.Response) (res ListUeRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListUeOKApplicationJSON + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeListUserResponse(resp *http.Response) (res ListUserRes, err error) { switch resp.StatusCode { case 200: @@ -1822,6 +2298,187 @@ func decodeListUserCardResponse(resp *http.Response) (res ListUserCardRes, err e return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeListUserUeResponse(resp *http.Response) (res ListUserUeRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListUserUeOKApplicationJSON + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeReadCardResponse(resp *http.Response) (res ReadCardRes, err error) { switch resp.StatusCode { case 200: @@ -2365,6 +3022,368 @@ func decodeReadGroupResponse(resp *http.Response) (res ReadGroupRes, err error) return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeReadUeResponse(resp *http.Response) (res ReadUeRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UeRead + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + +func decodeReadUeOwnerResponse(resp *http.Response) (res ReadUeOwnerRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UeOwnerRead + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeReadUserResponse(resp *http.Response) (res ReadUserRes, err error) { switch resp.StatusCode { case 200: @@ -2908,6 +3927,187 @@ func decodeUpdateGroupResponse(resp *http.Response) (res UpdateGroupRes, err err return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeUpdateUeResponse(resp *http.Response) (res UpdateUeRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UeUpdate + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + // Code 409. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + // Code 500. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeUpdateUserResponse(resp *http.Response) (res UpdateUserRes, err error) { switch resp.StatusCode { case 200: diff --git a/ent/ogent/oas_response_encoders_gen.go b/ent/ogent/oas_response_encoders_gen.go index 8d7c163..737e256 100644 --- a/ent/ogent/oas_response_encoders_gen.go +++ b/ent/ogent/oas_response_encoders_gen.go @@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s } } +func encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeCreate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeCreateUserResponse(response CreateUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *UserCreate: @@ -298,6 +353,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s } } +func encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *DeleteUeNoContent: + w.WriteHeader(204) + span.SetStatus(codes.Ok, http.StatusText(204)) + + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeDeleteUserResponse(response DeleteUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *DeleteUserNoContent: @@ -575,6 +691,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri } } +func encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListUeOKApplicationJSON: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai") switch response := response.(type) { @@ -711,6 +894,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter, } } +func encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListUserUeOKApplicationJSON: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai") switch response := response.(type) { @@ -914,6 +1164,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span } } +func encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeRead: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + +func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeOwnerRead: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "*") switch response := response.(type) { @@ -1116,6 +1500,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s } } +func encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeUpdate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeUpdateUserResponse(response UpdateUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *UserUpdate: diff --git a/ent/ogent/oas_router_gen.go b/ent/ogent/oas_router_gen.go index d5dbaf7..ed71449 100644 --- a/ent/ogent/oas_router_gen.go +++ b/ent/ogent/oas_router_gen.go @@ -243,85 +243,76 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } } - case 'u': // Prefix: "users" - if l := len("users"); len(elem) >= l && elem[0:l] == "users" { + case 'u': // Prefix: "u" + if l := len("u"); len(elem) >= l && elem[0:l] == "u" { elem = elem[l:] } else { break } if len(elem) == 0 { - switch r.Method { - case "GET": - s.handleListUserRequest([0]string{}, w, r) - case "POST": - s.handleCreateUserRequest([0]string{}, w, r) - default: - s.notAllowed(w, r, "GET,POST") - } - - return + break } switch elem[0] { - case '/': // Prefix: "/" - if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + case 'e': // Prefix: "es" + if l := len("es"); len(elem) >= l && elem[0:l] == "es" { elem = elem[l:] } else { break } - // Param: "id" - // Match until "/" - idx := strings.IndexByte(elem, '/') - if idx < 0 { - idx = len(elem) - } - args[0] = elem[:idx] - elem = elem[idx:] - if len(elem) == 0 { switch r.Method { - case "DELETE": - s.handleDeleteUserRequest([1]string{ - args[0], - }, w, r) case "GET": - s.handleReadUserRequest([1]string{ - args[0], - }, w, r) - case "PATCH": - s.handleUpdateUserRequest([1]string{ - args[0], - }, w, r) + s.handleListUeRequest([0]string{}, w, r) + case "POST": + s.handleCreateUeRequest([0]string{}, w, r) default: - s.notAllowed(w, r, "DELETE,GET,PATCH") + s.notAllowed(w, r, "GET,POST") } return } switch elem[0] { - case '/': // Prefix: "/card" - if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { elem = elem[l:] } else { break } + // Param: "id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + if len(elem) == 0 { switch r.Method { + case "DELETE": + s.handleDeleteUeRequest([1]string{ + args[0], + }, w, r) case "GET": - s.handleListUserCardRequest([1]string{ + s.handleReadUeRequest([1]string{ + args[0], + }, w, r) + case "PATCH": + s.handleUpdateUeRequest([1]string{ args[0], }, w, r) default: - s.notAllowed(w, r, "GET") + s.notAllowed(w, r, "DELETE,GET,PATCH") } return } switch elem[0] { - case '/': // Prefix: "/start" - if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" { + case '/': // Prefix: "/owner" + if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" { elem = elem[l:] } else { break @@ -330,18 +321,150 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { if len(elem) == 0 { // Leaf node. switch r.Method { - case "PATCH": - s.handleDrawStartRequest([1]string{ + case "GET": + s.handleReadUeOwnerRequest([1]string{ args[0], }, w, r) default: - s.notAllowed(w, r, "PATCH") + s.notAllowed(w, r, "GET") } return } } } + case 's': // Prefix: "sers" + if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch r.Method { + case "GET": + s.handleListUserRequest([0]string{}, w, r) + case "POST": + s.handleCreateUserRequest([0]string{}, w, r) + default: + s.notAllowed(w, r, "GET,POST") + } + + return + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + switch r.Method { + case "DELETE": + s.handleDeleteUserRequest([1]string{ + args[0], + }, w, r) + case "GET": + s.handleReadUserRequest([1]string{ + args[0], + }, w, r) + case "PATCH": + s.handleUpdateUserRequest([1]string{ + args[0], + }, w, r) + default: + s.notAllowed(w, r, "DELETE,GET,PATCH") + } + + return + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + break + } + switch elem[0] { + case 'c': // Prefix: "card" + if l := len("card"); len(elem) >= l && elem[0:l] == "card" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch r.Method { + case "GET": + s.handleListUserCardRequest([1]string{ + args[0], + }, w, r) + default: + s.notAllowed(w, r, "GET") + } + + return + } + switch elem[0] { + case '/': // Prefix: "/start" + if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "PATCH": + s.handleDrawStartRequest([1]string{ + args[0], + }, w, r) + default: + s.notAllowed(w, r, "PATCH") + } + + return + } + } + case 'u': // Prefix: "ue" + if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "GET": + s.handleListUserUeRequest([1]string{ + args[0], + }, w, r) + default: + s.notAllowed(w, r, "GET") + } + + return + } + } + } + } } } } @@ -647,91 +770,81 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } } } - case 'u': // Prefix: "users" - if l := len("users"); len(elem) >= l && elem[0:l] == "users" { + case 'u': // Prefix: "u" + if l := len("u"); len(elem) >= l && elem[0:l] == "u" { elem = elem[l:] } else { break } if len(elem) == 0 { - switch method { - case "GET": - r.name = "ListUser" - r.operationID = "listUser" - r.pathPattern = "/users" - r.args = args - r.count = 0 - return r, true - case "POST": - r.name = "CreateUser" - r.operationID = "createUser" - r.pathPattern = "/users" - r.args = args - r.count = 0 - return r, true - default: - return - } + break } switch elem[0] { - case '/': // Prefix: "/" - if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + case 'e': // Prefix: "es" + if l := len("es"); len(elem) >= l && elem[0:l] == "es" { elem = elem[l:] } else { break } - // Param: "id" - // Match until "/" - idx := strings.IndexByte(elem, '/') - if idx < 0 { - idx = len(elem) - } - args[0] = elem[:idx] - elem = elem[idx:] - if len(elem) == 0 { switch method { - case "DELETE": - r.name = "DeleteUser" - r.operationID = "deleteUser" - r.pathPattern = "/users/{id}" - r.args = args - r.count = 1 - return r, true case "GET": - r.name = "ReadUser" - r.operationID = "readUser" - r.pathPattern = "/users/{id}" + r.name = "ListUe" + r.operationID = "listUe" + r.pathPattern = "/ues" r.args = args - r.count = 1 + r.count = 0 return r, true - case "PATCH": - r.name = "UpdateUser" - r.operationID = "updateUser" - r.pathPattern = "/users/{id}" + case "POST": + r.name = "CreateUe" + r.operationID = "createUe" + r.pathPattern = "/ues" r.args = args - r.count = 1 + r.count = 0 return r, true default: return } } switch elem[0] { - case '/': // Prefix: "/card" - if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { elem = elem[l:] } else { break } + // Param: "id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + if len(elem) == 0 { switch method { + case "DELETE": + r.name = "DeleteUe" + r.operationID = "deleteUe" + r.pathPattern = "/ues/{id}" + r.args = args + r.count = 1 + return r, true case "GET": - r.name = "ListUserCard" - r.operationID = "listUserCard" - r.pathPattern = "/users/{id}/card" + r.name = "ReadUe" + r.operationID = "readUe" + r.pathPattern = "/ues/{id}" + r.args = args + r.count = 1 + return r, true + case "PATCH": + r.name = "UpdateUe" + r.operationID = "updateUe" + r.pathPattern = "/ues/{id}" r.args = args r.count = 1 return r, true @@ -740,8 +853,8 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } } switch elem[0] { - case '/': // Prefix: "/start" - if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" { + case '/': // Prefix: "/owner" + if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" { elem = elem[l:] } else { break @@ -749,11 +862,11 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { if len(elem) == 0 { switch method { - case "PATCH": - // Leaf: DrawStart - r.name = "DrawStart" - r.operationID = "drawStart" - r.pathPattern = "/users/{id}/card/start" + case "GET": + // Leaf: ReadUeOwner + r.name = "ReadUeOwner" + r.operationID = "readUeOwner" + r.pathPattern = "/ues/{id}/owner" r.args = args r.count = 1 return r, true @@ -763,6 +876,156 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } } } + case 's': // Prefix: "sers" + if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch method { + case "GET": + r.name = "ListUser" + r.operationID = "listUser" + r.pathPattern = "/users" + r.args = args + r.count = 0 + return r, true + case "POST": + r.name = "CreateUser" + r.operationID = "createUser" + r.pathPattern = "/users" + r.args = args + r.count = 0 + return r, true + default: + return + } + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + switch method { + case "DELETE": + r.name = "DeleteUser" + r.operationID = "deleteUser" + r.pathPattern = "/users/{id}" + r.args = args + r.count = 1 + return r, true + case "GET": + r.name = "ReadUser" + r.operationID = "readUser" + r.pathPattern = "/users/{id}" + r.args = args + r.count = 1 + return r, true + case "PATCH": + r.name = "UpdateUser" + r.operationID = "updateUser" + r.pathPattern = "/users/{id}" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + break + } + switch elem[0] { + case 'c': // Prefix: "card" + if l := len("card"); len(elem) >= l && elem[0:l] == "card" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch method { + case "GET": + r.name = "ListUserCard" + r.operationID = "listUserCard" + r.pathPattern = "/users/{id}/card" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + switch elem[0] { + case '/': // Prefix: "/start" + if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch method { + case "PATCH": + // Leaf: DrawStart + r.name = "DrawStart" + r.operationID = "drawStart" + r.pathPattern = "/users/{id}/card/start" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + } + case 'u': // Prefix: "ue" + if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch method { + case "GET": + // Leaf: ListUserUe + r.name = "ListUserUe" + r.operationID = "listUserUe" + r.pathPattern = "/users/{id}/ue" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + } + } + } } } } diff --git a/ent/ogent/oas_schemas_gen.go b/ent/ogent/oas_schemas_gen.go index c5b81fb..f33ab86 100644 --- a/ent/ogent/oas_schemas_gen.go +++ b/ent/ogent/oas_schemas_gen.go @@ -1098,6 +1098,229 @@ func (s *CreateGroupReq) SetUsers(val []int) { s.Users = val } +type CreateUeReq struct { + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Password string `json:"password"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Token OptString `json:"token"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` + Owner int `json:"owner"` +} + +// GetLimit returns the value of Limit. +func (s *CreateUeReq) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *CreateUeReq) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *CreateUeReq) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetPassword returns the value of Password. +func (s *CreateUeReq) GetPassword() string { + return s.Password +} + +// GetLv returns the value of Lv. +func (s *CreateUeReq) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *CreateUeReq) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *CreateUeReq) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *CreateUeReq) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *CreateUeReq) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *CreateUeReq) GetMode() OptString { + return s.Mode +} + +// GetToken returns the value of Token. +func (s *CreateUeReq) GetToken() OptString { + return s.Token +} + +// GetCp returns the value of Cp. +func (s *CreateUeReq) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *CreateUeReq) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *CreateUeReq) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *CreateUeReq) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *CreateUeReq) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *CreateUeReq) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *CreateUeReq) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *CreateUeReq) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// GetOwner returns the value of Owner. +func (s *CreateUeReq) GetOwner() int { + return s.Owner +} + +// SetLimit sets the value of Limit. +func (s *CreateUeReq) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *CreateUeReq) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *CreateUeReq) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetPassword sets the value of Password. +func (s *CreateUeReq) SetPassword(val string) { + s.Password = val +} + +// SetLv sets the value of Lv. +func (s *CreateUeReq) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *CreateUeReq) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *CreateUeReq) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *CreateUeReq) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *CreateUeReq) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *CreateUeReq) SetMode(val OptString) { + s.Mode = val +} + +// SetToken sets the value of Token. +func (s *CreateUeReq) SetToken(val OptString) { + s.Token = val +} + +// SetCp sets the value of Cp. +func (s *CreateUeReq) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *CreateUeReq) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *CreateUeReq) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *CreateUeReq) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *CreateUeReq) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *CreateUeReq) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *CreateUeReq) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *CreateUeReq) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +// SetOwner sets the value of Owner. +func (s *CreateUeReq) SetOwner(val int) { + s.Owner = val +} + type CreateUserReq struct { Username string `json:"username"` Did OptString `json:"did"` @@ -1147,6 +1370,7 @@ type CreateUserReq struct { GameAccount OptBool `json:"game_account"` GameLv OptInt `json:"game_lv"` Card []int `json:"card"` + Ue []int `json:"ue"` } // GetUsername returns the value of Username. @@ -1389,6 +1613,11 @@ func (s *CreateUserReq) GetCard() []int { return s.Card } +// GetUe returns the value of Ue. +func (s *CreateUserReq) GetUe() []int { + return s.Ue +} + // SetUsername sets the value of Username. func (s *CreateUserReq) SetUsername(val string) { s.Username = val @@ -1629,6 +1858,11 @@ func (s *CreateUserReq) SetCard(val []int) { s.Card = val } +// SetUe sets the value of Ue. +func (s *CreateUserReq) SetUe(val []int) { + s.Ue = val +} + // DeleteCardNoContent is response for DeleteCard operation. type DeleteCardNoContent struct{} @@ -1639,6 +1873,11 @@ type DeleteGroupNoContent struct{} func (*DeleteGroupNoContent) deleteGroupRes() {} +// DeleteUeNoContent is response for DeleteUe operation. +type DeleteUeNoContent struct{} + +func (*DeleteUeNoContent) deleteUeRes() {} + // DeleteUserNoContent is response for DeleteUser operation. type DeleteUserNoContent struct{} @@ -2282,6 +2521,10 @@ type ListGroupUsersOKApplicationJSON []GroupUsersList func (*ListGroupUsersOKApplicationJSON) listGroupUsersRes() {} +type ListUeOKApplicationJSON []UeList + +func (*ListUeOKApplicationJSON) listUeRes() {} + type ListUserCardOKApplicationJSON []UserCardList func (*ListUserCardOKApplicationJSON) listUserCardRes() {} @@ -2290,6 +2533,10 @@ type ListUserOKApplicationJSON []UserList func (*ListUserOKApplicationJSON) listUserRes() {} +type ListUserUeOKApplicationJSON []UserUeList + +func (*ListUserUeOKApplicationJSON) listUserUeRes() {} + // NewOptBool returns new OptBool with value set to v. func NewOptBool(v bool) OptBool { return OptBool{ @@ -2512,21 +2759,28 @@ func (s *R400) SetErrors(val jx.Raw) { func (*R400) createCardRes() {} func (*R400) createGroupRes() {} +func (*R400) createUeRes() {} func (*R400) createUserRes() {} func (*R400) deleteCardRes() {} func (*R400) deleteGroupRes() {} +func (*R400) deleteUeRes() {} func (*R400) deleteUserRes() {} func (*R400) listCardRes() {} func (*R400) listGroupRes() {} func (*R400) listGroupUsersRes() {} +func (*R400) listUeRes() {} func (*R400) listUserCardRes() {} func (*R400) listUserRes() {} +func (*R400) listUserUeRes() {} func (*R400) readCardOwnerRes() {} func (*R400) readCardRes() {} func (*R400) readGroupRes() {} +func (*R400) readUeOwnerRes() {} +func (*R400) readUeRes() {} func (*R400) readUserRes() {} func (*R400) updateCardRes() {} func (*R400) updateGroupRes() {} +func (*R400) updateUeRes() {} func (*R400) updateUserRes() {} type R404 struct { @@ -2567,18 +2821,24 @@ func (s *R404) SetErrors(val jx.Raw) { func (*R404) deleteCardRes() {} func (*R404) deleteGroupRes() {} +func (*R404) deleteUeRes() {} func (*R404) deleteUserRes() {} func (*R404) listCardRes() {} func (*R404) listGroupRes() {} func (*R404) listGroupUsersRes() {} +func (*R404) listUeRes() {} func (*R404) listUserCardRes() {} func (*R404) listUserRes() {} +func (*R404) listUserUeRes() {} func (*R404) readCardOwnerRes() {} func (*R404) readCardRes() {} func (*R404) readGroupRes() {} +func (*R404) readUeOwnerRes() {} +func (*R404) readUeRes() {} func (*R404) readUserRes() {} func (*R404) updateCardRes() {} func (*R404) updateGroupRes() {} +func (*R404) updateUeRes() {} func (*R404) updateUserRes() {} type R409 struct { @@ -2619,21 +2879,28 @@ func (s *R409) SetErrors(val jx.Raw) { func (*R409) createCardRes() {} func (*R409) createGroupRes() {} +func (*R409) createUeRes() {} func (*R409) createUserRes() {} func (*R409) deleteCardRes() {} func (*R409) deleteGroupRes() {} +func (*R409) deleteUeRes() {} func (*R409) deleteUserRes() {} func (*R409) listCardRes() {} func (*R409) listGroupRes() {} func (*R409) listGroupUsersRes() {} +func (*R409) listUeRes() {} func (*R409) listUserCardRes() {} func (*R409) listUserRes() {} +func (*R409) listUserUeRes() {} func (*R409) readCardOwnerRes() {} func (*R409) readCardRes() {} func (*R409) readGroupRes() {} +func (*R409) readUeOwnerRes() {} +func (*R409) readUeRes() {} func (*R409) readUserRes() {} func (*R409) updateCardRes() {} func (*R409) updateGroupRes() {} +func (*R409) updateUeRes() {} func (*R409) updateUserRes() {} type R500 struct { @@ -2674,23 +2941,1356 @@ func (s *R500) SetErrors(val jx.Raw) { func (*R500) createCardRes() {} func (*R500) createGroupRes() {} +func (*R500) createUeRes() {} func (*R500) createUserRes() {} func (*R500) deleteCardRes() {} func (*R500) deleteGroupRes() {} +func (*R500) deleteUeRes() {} func (*R500) deleteUserRes() {} func (*R500) listCardRes() {} func (*R500) listGroupRes() {} func (*R500) listGroupUsersRes() {} +func (*R500) listUeRes() {} func (*R500) listUserCardRes() {} func (*R500) listUserRes() {} +func (*R500) listUserUeRes() {} func (*R500) readCardOwnerRes() {} func (*R500) readCardRes() {} func (*R500) readGroupRes() {} +func (*R500) readUeOwnerRes() {} +func (*R500) readUeRes() {} func (*R500) readUserRes() {} func (*R500) updateCardRes() {} func (*R500) updateGroupRes() {} +func (*R500) updateUeRes() {} func (*R500) updateUserRes() {} +// Ref: #/components/schemas/UeCreate +type UeCreate struct { + ID int `json:"id"` + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` +} + +// GetID returns the value of ID. +func (s *UeCreate) GetID() int { + return s.ID +} + +// GetLimit returns the value of Limit. +func (s *UeCreate) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UeCreate) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UeCreate) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UeCreate) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UeCreate) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UeCreate) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UeCreate) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UeCreate) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UeCreate) GetMode() OptString { + return s.Mode +} + +// GetCp returns the value of Cp. +func (s *UeCreate) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UeCreate) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UeCreate) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UeCreate) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UeCreate) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UeCreate) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UeCreate) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UeCreate) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// SetID sets the value of ID. +func (s *UeCreate) SetID(val int) { + s.ID = val +} + +// SetLimit sets the value of Limit. +func (s *UeCreate) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UeCreate) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UeCreate) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UeCreate) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UeCreate) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UeCreate) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UeCreate) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UeCreate) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UeCreate) SetMode(val OptString) { + s.Mode = val +} + +// SetCp sets the value of Cp. +func (s *UeCreate) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UeCreate) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UeCreate) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UeCreate) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UeCreate) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UeCreate) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UeCreate) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UeCreate) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +func (*UeCreate) createUeRes() {} + +// Ref: #/components/schemas/UeList +type UeList struct { + ID int `json:"id"` + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` +} + +// GetID returns the value of ID. +func (s *UeList) GetID() int { + return s.ID +} + +// GetLimit returns the value of Limit. +func (s *UeList) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UeList) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UeList) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UeList) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UeList) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UeList) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UeList) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UeList) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UeList) GetMode() OptString { + return s.Mode +} + +// GetCp returns the value of Cp. +func (s *UeList) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UeList) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UeList) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UeList) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UeList) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UeList) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UeList) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UeList) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// SetID sets the value of ID. +func (s *UeList) SetID(val int) { + s.ID = val +} + +// SetLimit sets the value of Limit. +func (s *UeList) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UeList) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UeList) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UeList) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UeList) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UeList) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UeList) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UeList) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UeList) SetMode(val OptString) { + s.Mode = val +} + +// SetCp sets the value of Cp. +func (s *UeList) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UeList) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UeList) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UeList) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UeList) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UeList) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UeList) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UeList) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +// Ref: #/components/schemas/Ue_OwnerRead +type UeOwnerRead struct { + ID int `json:"id"` + Username string `json:"username"` + Did OptString `json:"did"` + Member OptBool `json:"member"` + Book OptBool `json:"book"` + Manga OptBool `json:"manga"` + Badge OptBool `json:"badge"` + Bsky OptBool `json:"bsky"` + Mastodon OptBool `json:"mastodon"` + Delete OptBool `json:"delete"` + Handle OptBool `json:"handle"` + CreatedAt OptDateTime `json:"created_at"` + UpdatedAt OptDateTime `json:"updated_at"` + RaidAt OptDateTime `json:"raid_at"` + ServerAt OptDateTime `json:"server_at"` + EggAt OptDateTime `json:"egg_at"` + Luck OptInt `json:"luck"` + LuckAt OptDateTime `json:"luck_at"` + Like OptInt `json:"like"` + LikeRank OptInt `json:"like_rank"` + LikeAt OptDateTime `json:"like_at"` + Fav OptInt `json:"fav"` + Ten OptBool `json:"ten"` + TenSu OptInt `json:"ten_su"` + TenKai OptInt `json:"ten_kai"` + Aiten OptInt `json:"aiten"` + TenCard OptString `json:"ten_card"` + TenDelete OptString `json:"ten_delete"` + TenPost OptString `json:"ten_post"` + TenGet OptString `json:"ten_get"` + TenAt OptDateTime `json:"ten_at"` + Next OptString `json:"next"` + Room OptInt `json:"room"` + Model OptBool `json:"model"` + ModelAt OptDateTime `json:"model_at"` + ModelAttack OptInt `json:"model_attack"` + ModelLimit OptInt `json:"model_limit"` + ModelSkill OptInt `json:"model_skill"` + ModelMode OptInt `json:"model_mode"` + ModelCritical OptInt `json:"model_critical"` + ModelCriticalD OptInt `json:"model_critical_d"` + Game OptBool `json:"game"` + GameTest OptBool `json:"game_test"` + GameEnd OptBool `json:"game_end"` + GameAccount OptBool `json:"game_account"` + GameLv OptInt `json:"game_lv"` +} + +// GetID returns the value of ID. +func (s *UeOwnerRead) GetID() int { + return s.ID +} + +// GetUsername returns the value of Username. +func (s *UeOwnerRead) GetUsername() string { + return s.Username +} + +// GetDid returns the value of Did. +func (s *UeOwnerRead) GetDid() OptString { + return s.Did +} + +// GetMember returns the value of Member. +func (s *UeOwnerRead) GetMember() OptBool { + return s.Member +} + +// GetBook returns the value of Book. +func (s *UeOwnerRead) GetBook() OptBool { + return s.Book +} + +// GetManga returns the value of Manga. +func (s *UeOwnerRead) GetManga() OptBool { + return s.Manga +} + +// GetBadge returns the value of Badge. +func (s *UeOwnerRead) GetBadge() OptBool { + return s.Badge +} + +// GetBsky returns the value of Bsky. +func (s *UeOwnerRead) GetBsky() OptBool { + return s.Bsky +} + +// GetMastodon returns the value of Mastodon. +func (s *UeOwnerRead) GetMastodon() OptBool { + return s.Mastodon +} + +// GetDelete returns the value of Delete. +func (s *UeOwnerRead) GetDelete() OptBool { + return s.Delete +} + +// GetHandle returns the value of Handle. +func (s *UeOwnerRead) GetHandle() OptBool { + return s.Handle +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UeOwnerRead) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// GetUpdatedAt returns the value of UpdatedAt. +func (s *UeOwnerRead) GetUpdatedAt() OptDateTime { + return s.UpdatedAt +} + +// GetRaidAt returns the value of RaidAt. +func (s *UeOwnerRead) GetRaidAt() OptDateTime { + return s.RaidAt +} + +// GetServerAt returns the value of ServerAt. +func (s *UeOwnerRead) GetServerAt() OptDateTime { + return s.ServerAt +} + +// GetEggAt returns the value of EggAt. +func (s *UeOwnerRead) GetEggAt() OptDateTime { + return s.EggAt +} + +// GetLuck returns the value of Luck. +func (s *UeOwnerRead) GetLuck() OptInt { + return s.Luck +} + +// GetLuckAt returns the value of LuckAt. +func (s *UeOwnerRead) GetLuckAt() OptDateTime { + return s.LuckAt +} + +// GetLike returns the value of Like. +func (s *UeOwnerRead) GetLike() OptInt { + return s.Like +} + +// GetLikeRank returns the value of LikeRank. +func (s *UeOwnerRead) GetLikeRank() OptInt { + return s.LikeRank +} + +// GetLikeAt returns the value of LikeAt. +func (s *UeOwnerRead) GetLikeAt() OptDateTime { + return s.LikeAt +} + +// GetFav returns the value of Fav. +func (s *UeOwnerRead) GetFav() OptInt { + return s.Fav +} + +// GetTen returns the value of Ten. +func (s *UeOwnerRead) GetTen() OptBool { + return s.Ten +} + +// GetTenSu returns the value of TenSu. +func (s *UeOwnerRead) GetTenSu() OptInt { + return s.TenSu +} + +// GetTenKai returns the value of TenKai. +func (s *UeOwnerRead) GetTenKai() OptInt { + return s.TenKai +} + +// GetAiten returns the value of Aiten. +func (s *UeOwnerRead) GetAiten() OptInt { + return s.Aiten +} + +// GetTenCard returns the value of TenCard. +func (s *UeOwnerRead) GetTenCard() OptString { + return s.TenCard +} + +// GetTenDelete returns the value of TenDelete. +func (s *UeOwnerRead) GetTenDelete() OptString { + return s.TenDelete +} + +// GetTenPost returns the value of TenPost. +func (s *UeOwnerRead) GetTenPost() OptString { + return s.TenPost +} + +// GetTenGet returns the value of TenGet. +func (s *UeOwnerRead) GetTenGet() OptString { + return s.TenGet +} + +// GetTenAt returns the value of TenAt. +func (s *UeOwnerRead) GetTenAt() OptDateTime { + return s.TenAt +} + +// GetNext returns the value of Next. +func (s *UeOwnerRead) GetNext() OptString { + return s.Next +} + +// GetRoom returns the value of Room. +func (s *UeOwnerRead) GetRoom() OptInt { + return s.Room +} + +// GetModel returns the value of Model. +func (s *UeOwnerRead) GetModel() OptBool { + return s.Model +} + +// GetModelAt returns the value of ModelAt. +func (s *UeOwnerRead) GetModelAt() OptDateTime { + return s.ModelAt +} + +// GetModelAttack returns the value of ModelAttack. +func (s *UeOwnerRead) GetModelAttack() OptInt { + return s.ModelAttack +} + +// GetModelLimit returns the value of ModelLimit. +func (s *UeOwnerRead) GetModelLimit() OptInt { + return s.ModelLimit +} + +// GetModelSkill returns the value of ModelSkill. +func (s *UeOwnerRead) GetModelSkill() OptInt { + return s.ModelSkill +} + +// GetModelMode returns the value of ModelMode. +func (s *UeOwnerRead) GetModelMode() OptInt { + return s.ModelMode +} + +// GetModelCritical returns the value of ModelCritical. +func (s *UeOwnerRead) GetModelCritical() OptInt { + return s.ModelCritical +} + +// GetModelCriticalD returns the value of ModelCriticalD. +func (s *UeOwnerRead) GetModelCriticalD() OptInt { + return s.ModelCriticalD +} + +// GetGame returns the value of Game. +func (s *UeOwnerRead) GetGame() OptBool { + return s.Game +} + +// GetGameTest returns the value of GameTest. +func (s *UeOwnerRead) GetGameTest() OptBool { + return s.GameTest +} + +// GetGameEnd returns the value of GameEnd. +func (s *UeOwnerRead) GetGameEnd() OptBool { + return s.GameEnd +} + +// GetGameAccount returns the value of GameAccount. +func (s *UeOwnerRead) GetGameAccount() OptBool { + return s.GameAccount +} + +// GetGameLv returns the value of GameLv. +func (s *UeOwnerRead) GetGameLv() OptInt { + return s.GameLv +} + +// SetID sets the value of ID. +func (s *UeOwnerRead) SetID(val int) { + s.ID = val +} + +// SetUsername sets the value of Username. +func (s *UeOwnerRead) SetUsername(val string) { + s.Username = val +} + +// SetDid sets the value of Did. +func (s *UeOwnerRead) SetDid(val OptString) { + s.Did = val +} + +// SetMember sets the value of Member. +func (s *UeOwnerRead) SetMember(val OptBool) { + s.Member = val +} + +// SetBook sets the value of Book. +func (s *UeOwnerRead) SetBook(val OptBool) { + s.Book = val +} + +// SetManga sets the value of Manga. +func (s *UeOwnerRead) SetManga(val OptBool) { + s.Manga = val +} + +// SetBadge sets the value of Badge. +func (s *UeOwnerRead) SetBadge(val OptBool) { + s.Badge = val +} + +// SetBsky sets the value of Bsky. +func (s *UeOwnerRead) SetBsky(val OptBool) { + s.Bsky = val +} + +// SetMastodon sets the value of Mastodon. +func (s *UeOwnerRead) SetMastodon(val OptBool) { + s.Mastodon = val +} + +// SetDelete sets the value of Delete. +func (s *UeOwnerRead) SetDelete(val OptBool) { + s.Delete = val +} + +// SetHandle sets the value of Handle. +func (s *UeOwnerRead) SetHandle(val OptBool) { + s.Handle = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UeOwnerRead) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +// SetUpdatedAt sets the value of UpdatedAt. +func (s *UeOwnerRead) SetUpdatedAt(val OptDateTime) { + s.UpdatedAt = val +} + +// SetRaidAt sets the value of RaidAt. +func (s *UeOwnerRead) SetRaidAt(val OptDateTime) { + s.RaidAt = val +} + +// SetServerAt sets the value of ServerAt. +func (s *UeOwnerRead) SetServerAt(val OptDateTime) { + s.ServerAt = val +} + +// SetEggAt sets the value of EggAt. +func (s *UeOwnerRead) SetEggAt(val OptDateTime) { + s.EggAt = val +} + +// SetLuck sets the value of Luck. +func (s *UeOwnerRead) SetLuck(val OptInt) { + s.Luck = val +} + +// SetLuckAt sets the value of LuckAt. +func (s *UeOwnerRead) SetLuckAt(val OptDateTime) { + s.LuckAt = val +} + +// SetLike sets the value of Like. +func (s *UeOwnerRead) SetLike(val OptInt) { + s.Like = val +} + +// SetLikeRank sets the value of LikeRank. +func (s *UeOwnerRead) SetLikeRank(val OptInt) { + s.LikeRank = val +} + +// SetLikeAt sets the value of LikeAt. +func (s *UeOwnerRead) SetLikeAt(val OptDateTime) { + s.LikeAt = val +} + +// SetFav sets the value of Fav. +func (s *UeOwnerRead) SetFav(val OptInt) { + s.Fav = val +} + +// SetTen sets the value of Ten. +func (s *UeOwnerRead) SetTen(val OptBool) { + s.Ten = val +} + +// SetTenSu sets the value of TenSu. +func (s *UeOwnerRead) SetTenSu(val OptInt) { + s.TenSu = val +} + +// SetTenKai sets the value of TenKai. +func (s *UeOwnerRead) SetTenKai(val OptInt) { + s.TenKai = val +} + +// SetAiten sets the value of Aiten. +func (s *UeOwnerRead) SetAiten(val OptInt) { + s.Aiten = val +} + +// SetTenCard sets the value of TenCard. +func (s *UeOwnerRead) SetTenCard(val OptString) { + s.TenCard = val +} + +// SetTenDelete sets the value of TenDelete. +func (s *UeOwnerRead) SetTenDelete(val OptString) { + s.TenDelete = val +} + +// SetTenPost sets the value of TenPost. +func (s *UeOwnerRead) SetTenPost(val OptString) { + s.TenPost = val +} + +// SetTenGet sets the value of TenGet. +func (s *UeOwnerRead) SetTenGet(val OptString) { + s.TenGet = val +} + +// SetTenAt sets the value of TenAt. +func (s *UeOwnerRead) SetTenAt(val OptDateTime) { + s.TenAt = val +} + +// SetNext sets the value of Next. +func (s *UeOwnerRead) SetNext(val OptString) { + s.Next = val +} + +// SetRoom sets the value of Room. +func (s *UeOwnerRead) SetRoom(val OptInt) { + s.Room = val +} + +// SetModel sets the value of Model. +func (s *UeOwnerRead) SetModel(val OptBool) { + s.Model = val +} + +// SetModelAt sets the value of ModelAt. +func (s *UeOwnerRead) SetModelAt(val OptDateTime) { + s.ModelAt = val +} + +// SetModelAttack sets the value of ModelAttack. +func (s *UeOwnerRead) SetModelAttack(val OptInt) { + s.ModelAttack = val +} + +// SetModelLimit sets the value of ModelLimit. +func (s *UeOwnerRead) SetModelLimit(val OptInt) { + s.ModelLimit = val +} + +// SetModelSkill sets the value of ModelSkill. +func (s *UeOwnerRead) SetModelSkill(val OptInt) { + s.ModelSkill = val +} + +// SetModelMode sets the value of ModelMode. +func (s *UeOwnerRead) SetModelMode(val OptInt) { + s.ModelMode = val +} + +// SetModelCritical sets the value of ModelCritical. +func (s *UeOwnerRead) SetModelCritical(val OptInt) { + s.ModelCritical = val +} + +// SetModelCriticalD sets the value of ModelCriticalD. +func (s *UeOwnerRead) SetModelCriticalD(val OptInt) { + s.ModelCriticalD = val +} + +// SetGame sets the value of Game. +func (s *UeOwnerRead) SetGame(val OptBool) { + s.Game = val +} + +// SetGameTest sets the value of GameTest. +func (s *UeOwnerRead) SetGameTest(val OptBool) { + s.GameTest = val +} + +// SetGameEnd sets the value of GameEnd. +func (s *UeOwnerRead) SetGameEnd(val OptBool) { + s.GameEnd = val +} + +// SetGameAccount sets the value of GameAccount. +func (s *UeOwnerRead) SetGameAccount(val OptBool) { + s.GameAccount = val +} + +// SetGameLv sets the value of GameLv. +func (s *UeOwnerRead) SetGameLv(val OptInt) { + s.GameLv = val +} + +func (*UeOwnerRead) readUeOwnerRes() {} + +// Ref: #/components/schemas/UeRead +type UeRead struct { + ID int `json:"id"` + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` +} + +// GetID returns the value of ID. +func (s *UeRead) GetID() int { + return s.ID +} + +// GetLimit returns the value of Limit. +func (s *UeRead) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UeRead) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UeRead) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UeRead) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UeRead) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UeRead) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UeRead) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UeRead) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UeRead) GetMode() OptString { + return s.Mode +} + +// GetCp returns the value of Cp. +func (s *UeRead) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UeRead) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UeRead) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UeRead) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UeRead) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UeRead) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UeRead) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UeRead) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// SetID sets the value of ID. +func (s *UeRead) SetID(val int) { + s.ID = val +} + +// SetLimit sets the value of Limit. +func (s *UeRead) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UeRead) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UeRead) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UeRead) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UeRead) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UeRead) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UeRead) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UeRead) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UeRead) SetMode(val OptString) { + s.Mode = val +} + +// SetCp sets the value of Cp. +func (s *UeRead) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UeRead) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UeRead) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UeRead) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UeRead) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UeRead) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UeRead) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UeRead) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +func (*UeRead) readUeRes() {} + +// Ref: #/components/schemas/UeUpdate +type UeUpdate struct { + ID int `json:"id"` + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` +} + +// GetID returns the value of ID. +func (s *UeUpdate) GetID() int { + return s.ID +} + +// GetLimit returns the value of Limit. +func (s *UeUpdate) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UeUpdate) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UeUpdate) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UeUpdate) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UeUpdate) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UeUpdate) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UeUpdate) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UeUpdate) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UeUpdate) GetMode() OptString { + return s.Mode +} + +// GetCp returns the value of Cp. +func (s *UeUpdate) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UeUpdate) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UeUpdate) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UeUpdate) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UeUpdate) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UeUpdate) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UeUpdate) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UeUpdate) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// SetID sets the value of ID. +func (s *UeUpdate) SetID(val int) { + s.ID = val +} + +// SetLimit sets the value of Limit. +func (s *UeUpdate) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UeUpdate) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UeUpdate) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UeUpdate) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UeUpdate) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UeUpdate) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UeUpdate) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UeUpdate) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UeUpdate) SetMode(val OptString) { + s.Mode = val +} + +// SetCp sets the value of Cp. +func (s *UeUpdate) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UeUpdate) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UeUpdate) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UeUpdate) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UeUpdate) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UeUpdate) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UeUpdate) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UeUpdate) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + +func (*UeUpdate) updateUeRes() {} + type UpdateCardReq struct { Card OptInt `json:"card"` Skill OptString `json:"skill"` @@ -2818,6 +4418,207 @@ func (s *UpdateGroupReq) SetUsers(val []int) { s.Users = val } +type UpdateUeReq struct { + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Token OptString `json:"token"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + Owner OptInt `json:"owner"` +} + +// GetLimit returns the value of Limit. +func (s *UpdateUeReq) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UpdateUeReq) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UpdateUeReq) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UpdateUeReq) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UpdateUeReq) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UpdateUeReq) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UpdateUeReq) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UpdateUeReq) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UpdateUeReq) GetMode() OptString { + return s.Mode +} + +// GetToken returns the value of Token. +func (s *UpdateUeReq) GetToken() OptString { + return s.Token +} + +// GetCp returns the value of Cp. +func (s *UpdateUeReq) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UpdateUeReq) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UpdateUeReq) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UpdateUeReq) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UpdateUeReq) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UpdateUeReq) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UpdateUeReq) GetAuthor() OptString { + return s.Author +} + +// GetOwner returns the value of Owner. +func (s *UpdateUeReq) GetOwner() OptInt { + return s.Owner +} + +// SetLimit sets the value of Limit. +func (s *UpdateUeReq) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UpdateUeReq) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UpdateUeReq) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UpdateUeReq) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UpdateUeReq) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UpdateUeReq) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UpdateUeReq) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UpdateUeReq) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UpdateUeReq) SetMode(val OptString) { + s.Mode = val +} + +// SetToken sets the value of Token. +func (s *UpdateUeReq) SetToken(val OptString) { + s.Token = val +} + +// SetCp sets the value of Cp. +func (s *UpdateUeReq) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UpdateUeReq) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UpdateUeReq) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UpdateUeReq) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UpdateUeReq) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UpdateUeReq) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UpdateUeReq) SetAuthor(val OptString) { + s.Author = val +} + +// SetOwner sets the value of Owner. +func (s *UpdateUeReq) SetOwner(val OptInt) { + s.Owner = val +} + type UpdateUserReq struct { Did OptString `json:"did"` Member OptBool `json:"member"` @@ -2864,6 +4665,7 @@ type UpdateUserReq struct { GameAccount OptBool `json:"game_account"` GameLv OptInt `json:"game_lv"` Card []int `json:"card"` + Ue []int `json:"ue"` } // GetDid returns the value of Did. @@ -3091,6 +4893,11 @@ func (s *UpdateUserReq) GetCard() []int { return s.Card } +// GetUe returns the value of Ue. +func (s *UpdateUserReq) GetUe() []int { + return s.Ue +} + // SetDid sets the value of Did. func (s *UpdateUserReq) SetDid(val OptString) { s.Did = val @@ -3316,6 +5123,11 @@ func (s *UpdateUserReq) SetCard(val []int) { s.Card = val } +// SetUe sets the value of Ue. +func (s *UpdateUserReq) SetUe(val []int) { + s.Ue = val +} + // Ref: #/components/schemas/User_CardList type UserCardList struct { ID int `json:"id"` @@ -4953,6 +6765,208 @@ func (s *UserRead) SetGameLv(val OptInt) { func (*UserRead) readUserRes() {} +// Ref: #/components/schemas/User_UeList +type UserUeList struct { + ID int `json:"id"` + Limit OptBool `json:"limit"` + LimitBoss OptBool `json:"limit_boss"` + LimitItem OptBool `json:"limit_item"` + Lv OptInt `json:"lv"` + LvPoint OptInt `json:"lv_point"` + Model OptInt `json:"model"` + Sword OptInt `json:"sword"` + Card OptInt `json:"card"` + Mode OptString `json:"mode"` + Cp OptInt `json:"cp"` + Count OptInt `json:"count"` + LocationX OptInt `json:"location_x"` + LocationY OptInt `json:"location_y"` + LocationZ OptInt `json:"location_z"` + LocationN OptInt `json:"location_n"` + Author OptString `json:"author"` + CreatedAt OptDateTime `json:"created_at"` +} + +// GetID returns the value of ID. +func (s *UserUeList) GetID() int { + return s.ID +} + +// GetLimit returns the value of Limit. +func (s *UserUeList) GetLimit() OptBool { + return s.Limit +} + +// GetLimitBoss returns the value of LimitBoss. +func (s *UserUeList) GetLimitBoss() OptBool { + return s.LimitBoss +} + +// GetLimitItem returns the value of LimitItem. +func (s *UserUeList) GetLimitItem() OptBool { + return s.LimitItem +} + +// GetLv returns the value of Lv. +func (s *UserUeList) GetLv() OptInt { + return s.Lv +} + +// GetLvPoint returns the value of LvPoint. +func (s *UserUeList) GetLvPoint() OptInt { + return s.LvPoint +} + +// GetModel returns the value of Model. +func (s *UserUeList) GetModel() OptInt { + return s.Model +} + +// GetSword returns the value of Sword. +func (s *UserUeList) GetSword() OptInt { + return s.Sword +} + +// GetCard returns the value of Card. +func (s *UserUeList) GetCard() OptInt { + return s.Card +} + +// GetMode returns the value of Mode. +func (s *UserUeList) GetMode() OptString { + return s.Mode +} + +// GetCp returns the value of Cp. +func (s *UserUeList) GetCp() OptInt { + return s.Cp +} + +// GetCount returns the value of Count. +func (s *UserUeList) GetCount() OptInt { + return s.Count +} + +// GetLocationX returns the value of LocationX. +func (s *UserUeList) GetLocationX() OptInt { + return s.LocationX +} + +// GetLocationY returns the value of LocationY. +func (s *UserUeList) GetLocationY() OptInt { + return s.LocationY +} + +// GetLocationZ returns the value of LocationZ. +func (s *UserUeList) GetLocationZ() OptInt { + return s.LocationZ +} + +// GetLocationN returns the value of LocationN. +func (s *UserUeList) GetLocationN() OptInt { + return s.LocationN +} + +// GetAuthor returns the value of Author. +func (s *UserUeList) GetAuthor() OptString { + return s.Author +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *UserUeList) GetCreatedAt() OptDateTime { + return s.CreatedAt +} + +// SetID sets the value of ID. +func (s *UserUeList) SetID(val int) { + s.ID = val +} + +// SetLimit sets the value of Limit. +func (s *UserUeList) SetLimit(val OptBool) { + s.Limit = val +} + +// SetLimitBoss sets the value of LimitBoss. +func (s *UserUeList) SetLimitBoss(val OptBool) { + s.LimitBoss = val +} + +// SetLimitItem sets the value of LimitItem. +func (s *UserUeList) SetLimitItem(val OptBool) { + s.LimitItem = val +} + +// SetLv sets the value of Lv. +func (s *UserUeList) SetLv(val OptInt) { + s.Lv = val +} + +// SetLvPoint sets the value of LvPoint. +func (s *UserUeList) SetLvPoint(val OptInt) { + s.LvPoint = val +} + +// SetModel sets the value of Model. +func (s *UserUeList) SetModel(val OptInt) { + s.Model = val +} + +// SetSword sets the value of Sword. +func (s *UserUeList) SetSword(val OptInt) { + s.Sword = val +} + +// SetCard sets the value of Card. +func (s *UserUeList) SetCard(val OptInt) { + s.Card = val +} + +// SetMode sets the value of Mode. +func (s *UserUeList) SetMode(val OptString) { + s.Mode = val +} + +// SetCp sets the value of Cp. +func (s *UserUeList) SetCp(val OptInt) { + s.Cp = val +} + +// SetCount sets the value of Count. +func (s *UserUeList) SetCount(val OptInt) { + s.Count = val +} + +// SetLocationX sets the value of LocationX. +func (s *UserUeList) SetLocationX(val OptInt) { + s.LocationX = val +} + +// SetLocationY sets the value of LocationY. +func (s *UserUeList) SetLocationY(val OptInt) { + s.LocationY = val +} + +// SetLocationZ sets the value of LocationZ. +func (s *UserUeList) SetLocationZ(val OptInt) { + s.LocationZ = val +} + +// SetLocationN sets the value of LocationN. +func (s *UserUeList) SetLocationN(val OptInt) { + s.LocationN = val +} + +// SetAuthor sets the value of Author. +func (s *UserUeList) SetAuthor(val OptString) { + s.Author = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *UserUeList) SetCreatedAt(val OptDateTime) { + s.CreatedAt = val +} + // Ref: #/components/schemas/UserUpdate type UserUpdate struct { ID int `json:"id"` diff --git a/ent/ogent/oas_server_gen.go b/ent/ogent/oas_server_gen.go index 9d3d350..91275b1 100644 --- a/ent/ogent/oas_server_gen.go +++ b/ent/ogent/oas_server_gen.go @@ -20,6 +20,12 @@ type Handler interface { // // POST /groups CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) + // CreateUe implements createUe operation. + // + // Creates a new Ue and persists it to storage. + // + // POST /ues + CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error) // CreateUser implements createUser operation. // // Creates a new User and persists it to storage. @@ -38,6 +44,12 @@ type Handler interface { // // DELETE /groups/{id} DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) + // DeleteUe implements deleteUe operation. + // + // Deletes the Ue with the requested ID. + // + // DELETE /ues/{id} + DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) // DeleteUser implements deleteUser operation. // // Deletes the User with the requested ID. @@ -74,6 +86,12 @@ type Handler interface { // // GET /groups/{id}/users ListGroupUsers(ctx context.Context, params ListGroupUsersParams) (ListGroupUsersRes, error) + // ListUe implements listUe operation. + // + // List Ues. + // + // GET /ues + ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) // ListUser implements listUser operation. // // List Users. @@ -86,6 +104,12 @@ type Handler interface { // // GET /users/{id}/card ListUserCard(ctx context.Context, params ListUserCardParams) (ListUserCardRes, error) + // ListUserUe implements listUserUe operation. + // + // List attached Ues. + // + // GET /users/{id}/ue + ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) // ReadCard implements readCard operation. // // Finds the Card with the requested ID and returns it. @@ -104,6 +128,18 @@ type Handler interface { // // GET /groups/{id} ReadGroup(ctx context.Context, params ReadGroupParams) (ReadGroupRes, error) + // ReadUe implements readUe operation. + // + // Finds the Ue with the requested ID and returns it. + // + // GET /ues/{id} + ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) + // ReadUeOwner implements readUeOwner operation. + // + // Find the attached User of the Ue with the given ID. + // + // GET /ues/{id}/owner + ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) // ReadUser implements readUser operation. // // Finds the User with the requested ID and returns it. @@ -122,6 +158,12 @@ type Handler interface { // // PATCH /groups/{id} UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) + // UpdateUe implements updateUe operation. + // + // Updates a Ue and persists changes to storage. + // + // PATCH /ues/{id} + UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) // UpdateUser implements updateUser operation. // // Updates a User and persists changes to storage. diff --git a/ent/ogent/oas_unimplemented_gen.go b/ent/ogent/oas_unimplemented_gen.go index 3a7db56..d2b1c82 100644 --- a/ent/ogent/oas_unimplemented_gen.go +++ b/ent/ogent/oas_unimplemented_gen.go @@ -31,6 +31,15 @@ func (UnimplementedHandler) CreateGroup(ctx context.Context, req *CreateGroupReq return r, ht.ErrNotImplemented } +// CreateUe implements createUe operation. +// +// Creates a new Ue and persists it to storage. +// +// POST /ues +func (UnimplementedHandler) CreateUe(ctx context.Context, req *CreateUeReq) (r CreateUeRes, _ error) { + return r, ht.ErrNotImplemented +} + // CreateUser implements createUser operation. // // Creates a new User and persists it to storage. @@ -58,6 +67,15 @@ func (UnimplementedHandler) DeleteGroup(ctx context.Context, params DeleteGroupP return r, ht.ErrNotImplemented } +// DeleteUe implements deleteUe operation. +// +// Deletes the Ue with the requested ID. +// +// DELETE /ues/{id} +func (UnimplementedHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (r DeleteUeRes, _ error) { + return r, ht.ErrNotImplemented +} + // DeleteUser implements deleteUser operation. // // Deletes the User with the requested ID. @@ -112,6 +130,15 @@ func (UnimplementedHandler) ListGroupUsers(ctx context.Context, params ListGroup return r, ht.ErrNotImplemented } +// ListUe implements listUe operation. +// +// List Ues. +// +// GET /ues +func (UnimplementedHandler) ListUe(ctx context.Context, params ListUeParams) (r ListUeRes, _ error) { + return r, ht.ErrNotImplemented +} + // ListUser implements listUser operation. // // List Users. @@ -130,6 +157,15 @@ func (UnimplementedHandler) ListUserCard(ctx context.Context, params ListUserCar return r, ht.ErrNotImplemented } +// ListUserUe implements listUserUe operation. +// +// List attached Ues. +// +// GET /users/{id}/ue +func (UnimplementedHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (r ListUserUeRes, _ error) { + return r, ht.ErrNotImplemented +} + // ReadCard implements readCard operation. // // Finds the Card with the requested ID and returns it. @@ -157,6 +193,24 @@ func (UnimplementedHandler) ReadGroup(ctx context.Context, params ReadGroupParam return r, ht.ErrNotImplemented } +// ReadUe implements readUe operation. +// +// Finds the Ue with the requested ID and returns it. +// +// GET /ues/{id} +func (UnimplementedHandler) ReadUe(ctx context.Context, params ReadUeParams) (r ReadUeRes, _ error) { + return r, ht.ErrNotImplemented +} + +// ReadUeOwner implements readUeOwner operation. +// +// Find the attached User of the Ue with the given ID. +// +// GET /ues/{id}/owner +func (UnimplementedHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (r ReadUeOwnerRes, _ error) { + return r, ht.ErrNotImplemented +} + // ReadUser implements readUser operation. // // Finds the User with the requested ID and returns it. @@ -184,6 +238,15 @@ func (UnimplementedHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq return r, ht.ErrNotImplemented } +// UpdateUe implements updateUe operation. +// +// Updates a Ue and persists changes to storage. +// +// PATCH /ues/{id} +func (UnimplementedHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (r UpdateUeRes, _ error) { + return r, ht.ErrNotImplemented +} + // UpdateUser implements updateUser operation. // // Updates a User and persists changes to storage. diff --git a/ent/ogent/oas_validators_gen.go b/ent/ogent/oas_validators_gen.go index be92ecd..02236c4 100644 --- a/ent/ogent/oas_validators_gen.go +++ b/ent/ogent/oas_validators_gen.go @@ -24,6 +24,12 @@ func (s ListGroupUsersOKApplicationJSON) Validate() error { } return nil } +func (s ListUeOKApplicationJSON) Validate() error { + if s == nil { + return errors.New("nil is invalid value") + } + return nil +} func (s ListUserCardOKApplicationJSON) Validate() error { if s == nil { return errors.New("nil is invalid value") @@ -36,3 +42,9 @@ func (s ListUserOKApplicationJSON) Validate() error { } return nil } +func (s ListUserUeOKApplicationJSON) Validate() error { + if s == nil { + return errors.New("nil is invalid value") + } + return nil +} diff --git a/ent/ogent/ogent.go b/ent/ogent/ogent.go index 3dfede2..7c83275 100644 --- a/ent/ogent/ogent.go +++ b/ent/ogent/ogent.go @@ -9,10 +9,10 @@ import ( "t/ent" "t/ent/card" "t/ent/group" + "t/ent/ue" "t/ent/user" - - "github.com/go-faster/jx" "os" + "github.com/go-faster/jx" ) // origin-config @@ -48,29 +48,31 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea if v, ok := req.Status.Get(); ok { b.SetStatus(v) } + if v, ok := req.Token.Get(); ok { + b.SetToken(v) + } if v, ok := req.Cp.Get(); ok { b.SetCp(v) } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } if v, ok := req.Count.Get(); ok { b.SetCount(v) } if v, ok := req.Author.Get(); ok { b.SetAuthor(v) } - if v, ok := req.URL.Get(); ok { - b.SetURL(v) - } if v, ok := req.CreatedAt.Get(); ok { b.SetCreatedAt(v) } // Add all edges. - //b.SetOwnerID(req.Owner) - // origin-config if req.Password == password { b.SetOwnerID(req.Owner) } else { b.SetOwnerID(0) } + //b.SetOwnerID(req.Owner) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -131,33 +133,32 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea // UpdateCard handles PATCH /cards/{id} requests. func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) { b := h.client.Card.UpdateOneID(params.ID) + // Add all fields. + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Skill.Get(); ok { + b.SetSkill(v) + } + if v, ok := req.Status.Get(); ok { + b.SetStatus(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + // Add all edges. if v, ok := req.Token.Get(); ok { if v == token { b.SetToken(v) - if v, ok := req.Skill.Get(); ok { - b.SetSkill(v) - } - if v, ok := req.URL.Get(); ok { - b.SetURL(v) - } - if v, ok := req.Status.Get(); ok { - b.SetStatus(v) - } - if v, ok := req.Count.Get(); ok { - b.SetCount(v) - } - if v, ok := req.Author.Get(); ok { - b.SetAuthor(v) - } - if v, ok := req.Token.Get(); ok { - b.SetToken(v) - } - if v, ok := req.Cp.Get(); ok { - b.SetCp(v) - } - if v, ok := req.Card.Get(); ok { - b.SetCard(v) - } if v, ok := req.Owner.Get(); ok { b.SetOwnerID(v) } @@ -197,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param // DeleteCard handles DELETE /cards/{id} requests. func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) { - err := h.client.Card.DeleteOneID(0).Exec(ctx) //err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) + err := h.client.Card.DeleteOneID(0).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -289,7 +290,7 @@ func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerPa func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) { b := h.client.Group.Create() // Add all fields. - b.SetName("") + b.SetName(req.Name) b.SetPassword(req.Password) // Add all edges. b.AddUserIDs(req.Users...) @@ -353,6 +354,7 @@ func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (R // UpdateGroup handles PATCH /groups/{id} requests. func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) { b := h.client.Group.UpdateOneID(0) + //b := h.client.Group.UpdateOneID(params.ID) // Add all fields. if v, ok := req.Name.Get(); ok { b.SetName(v) @@ -395,6 +397,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par // DeleteGroup handles DELETE /groups/{id} requests. func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) { err := h.client.Group.DeleteOneID(0).Exec(ctx) + //err := h.client.Group.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -491,40 +494,318 @@ func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsers return (*ListGroupUsersOKApplicationJSON)(&r), nil } +// CreateUe handles POST /ues requests. +func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error) { + b := h.client.Ue.Create() + // Add all fields. + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.LimitBoss.Get(); ok { + b.SetLimitBoss(v) + } + if v, ok := req.LimitItem.Get(); ok { + b.SetLimitItem(v) + } + b.SetPassword(req.Password) + if v, ok := req.Lv.Get(); ok { + b.SetLv(v) + } + if v, ok := req.LvPoint.Get(); ok { + b.SetLvPoint(v) + } + if v, ok := req.Model.Get(); ok { + b.SetModel(v) + } + if v, ok := req.Sword.Get(); ok { + b.SetSword(v) + } + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Mode.Get(); ok { + b.SetMode(v) + } + if v, ok := req.Token.Get(); ok { + b.SetToken(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.LocationX.Get(); ok { + b.SetLocationX(v) + } + if v, ok := req.LocationY.Get(); ok { + b.SetLocationY(v) + } + if v, ok := req.LocationZ.Get(); ok { + b.SetLocationZ(v) + } + if v, ok := req.LocationN.Get(); ok { + b.SetLocationN(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + if v, ok := req.CreatedAt.Get(); ok { + b.SetCreatedAt(v) + } + // Add all edges. + //b.SetOwnerID(req.Owner) + if req.Password == password { + b.SetOwnerID(req.Owner) + } else { + b.SetOwnerID(0) + } + // Persist to storage. + e, err := b.Save(ctx) + if err != nil { + switch { + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + // Reload the entity to attach all eager-loaded edges. + q := h.client.Ue.Query().Where(ue.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUeCreate(e), nil +} + +// ReadUe handles GET /ues/{id} requests. +func (h *OgentHandler) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) { + q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)) + e, err := q.Only(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return NewUeRead(e), nil +} + +// UpdateUe handles PATCH /ues/{id} requests. +func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) { + b := h.client.Ue.UpdateOneID(params.ID) + // Add all fields. + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.LimitBoss.Get(); ok { + b.SetLimitBoss(v) + } + if v, ok := req.LimitItem.Get(); ok { + b.SetLimitItem(v) + } + if v, ok := req.Lv.Get(); ok { + b.SetLv(v) + } + if v, ok := req.LvPoint.Get(); ok { + b.SetLvPoint(v) + } + if v, ok := req.Model.Get(); ok { + b.SetModel(v) + } + if v, ok := req.Sword.Get(); ok { + b.SetSword(v) + } + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Mode.Get(); ok { + b.SetMode(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.LocationX.Get(); ok { + b.SetLocationX(v) + } + if v, ok := req.LocationY.Get(); ok { + b.SetLocationY(v) + } + if v, ok := req.LocationZ.Get(); ok { + b.SetLocationZ(v) + } + if v, ok := req.LocationN.Get(); ok { + b.SetLocationN(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + // Add all edges. + if v, ok := req.Token.Get(); ok { + if v == token { + b.SetToken(v) + if v, ok := req.Owner.Get(); ok { + b.SetOwnerID(v) + } + } + } + + // Persist to storage. + e, err := b.Save(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + // Reload the entity to attach all eager-loaded edges. + q := h.client.Ue.Query().Where(ue.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUeUpdate(e), nil +} + +// DeleteUe handles DELETE /ues/{id} requests. +func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) { + err := h.client.Ue.DeleteOneID(0).Exec(ctx) + //err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return new(DeleteUeNoContent), nil + +} + +// ListUe handles GET /ues requests. +func (h *OgentHandler) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) { + q := h.client.Ue.Query() + page := 1 + if v, ok := params.Page.Get(); ok { + page = v + } + itemsPerPage := 30 + if v, ok := params.ItemsPerPage.Get(); ok { + itemsPerPage = v + } + q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage) + + es, err := q.All(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + r := NewUeLists(es) + return (*ListUeOKApplicationJSON)(&r), nil +} + +// ReadUeOwner handles GET /ues/{id}/owner requests. +func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) { + q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)).QueryOwner() + e, err := q.Only(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return NewUeOwnerRead(e), nil +} + // CreateUser handles POST /users requests. func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) { b := h.client.User.Create() - - // Add all fields. - //b.SetUsername(req.Username) - //origin-config - if req.Password == password { - b.SetUsername(req.Username) - } else { - b.SetUsername("") - } - - b.SetPassword(req.Password) - - if v, ok := req.ServerAt.Get(); ok { - b.SetServerAt(v) - } - - if v, ok := req.Room.Get(); ok { - b.SetRoom(v) - } - if v, ok := req.Fav.Get(); ok { - b.SetFav(v) - } - if v, ok := req.Did.Get(); ok { + if v, ok := req.Did.Get(); ok { b.SetDid(v) } - if v, ok := req.Bsky.Get(); ok { - b.SetBsky(v) - } - if v, ok := req.Mastodon.Get(); ok { - b.SetMastodon(v) - } if v, ok := req.Member.Get(); ok { b.SetMember(v) } @@ -537,6 +818,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Badge.Get(); ok { b.SetBadge(v) } + if v, ok := req.Bsky.Get(); ok { + b.SetBsky(v) + } + if v, ok := req.Mastodon.Get(); ok { + b.SetMastodon(v) + } if v, ok := req.Delete.Get(); ok { b.SetDelete(v) } @@ -546,9 +833,7 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Token.Get(); ok { b.SetToken(v) } - if v, ok := req.EggAt.Get(); ok { - b.SetEggAt(v) - } + b.SetPassword(req.Password) if v, ok := req.CreatedAt.Get(); ok { b.SetCreatedAt(v) } @@ -558,12 +843,15 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.RaidAt.Get(); ok { b.SetRaidAt(v) } + if v, ok := req.ServerAt.Get(); ok { + b.SetServerAt(v) + } + if v, ok := req.EggAt.Get(); ok { + b.SetEggAt(v) + } if v, ok := req.Luck.Get(); ok { b.SetLuck(v) } - if v, ok := req.Aiten.Get(); ok { - b.SetAiten(v) - } if v, ok := req.LuckAt.Get(); ok { b.SetLuckAt(v) } @@ -576,6 +864,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.LikeAt.Get(); ok { b.SetLikeAt(v) } + if v, ok := req.Fav.Get(); ok { + b.SetFav(v) + } if v, ok := req.Ten.Get(); ok { b.SetTen(v) } @@ -585,6 +876,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.TenKai.Get(); ok { b.SetTenKai(v) } + if v, ok := req.Aiten.Get(); ok { + b.SetAiten(v) + } if v, ok := req.TenCard.Get(); ok { b.SetTenCard(v) } @@ -603,6 +897,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Next.Get(); ok { b.SetNext(v) } + if v, ok := req.Room.Get(); ok { + b.SetRoom(v) + } if v, ok := req.Model.Get(); ok { b.SetModel(v) } @@ -612,12 +909,6 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.ModelAttack.Get(); ok { b.SetModelAttack(v) } - if v, ok := req.ModelCriticalD.Get(); ok { - b.SetModelCriticalD(v) - } - if v, ok := req.ModelCritical.Get(); ok { - b.SetModelCritical(v) - } if v, ok := req.ModelLimit.Get(); ok { b.SetModelLimit(v) } @@ -627,6 +918,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.ModelMode.Get(); ok { b.SetModelMode(v) } + if v, ok := req.ModelCritical.Get(); ok { + b.SetModelCritical(v) + } + if v, ok := req.ModelCriticalD.Get(); ok { + b.SetModelCriticalD(v) + } if v, ok := req.Game.Get(); ok { b.SetGame(v) } @@ -643,8 +940,16 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea b.SetGameLv(v) } + // Add all fields. + //b.SetUsername(req.Username) + if req.Password == password { + b.SetUsername(req.Username) + } else { + b.SetUsername("") + } // Add all edges. b.AddCardIDs(req.Card...) + b.AddUeIDs(req.Ue...) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -705,20 +1010,9 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea // UpdateUser handles PATCH /users/{id} requests. func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) { b := h.client.User.UpdateOneID(params.ID) - if v, ok := req.Token.Get(); ok { if v == token { - b.SetToken(v) - - if v, ok := req.ServerAt.Get(); ok { - b.SetServerAt(v) - } - if v, ok := req.Room.Get(); ok { - b.SetRoom(v) - } - if v, ok := req.Fav.Get(); ok { - b.SetFav(v) - } + // Add all fields. if v, ok := req.Did.Get(); ok { b.SetDid(v) } @@ -746,17 +1040,17 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.Handle.Get(); ok { b.SetHandle(v) } - if v, ok := req.EggAt.Get(); ok { - b.SetEggAt(v) - } if v, ok := req.UpdatedAt.Get(); ok { b.SetUpdatedAt(v) } if v, ok := req.RaidAt.Get(); ok { b.SetRaidAt(v) } - if v, ok := req.Aiten.Get(); ok { - b.SetAiten(v) + if v, ok := req.ServerAt.Get(); ok { + b.SetServerAt(v) + } + if v, ok := req.EggAt.Get(); ok { + b.SetEggAt(v) } if v, ok := req.Luck.Get(); ok { b.SetLuck(v) @@ -773,6 +1067,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.LikeAt.Get(); ok { b.SetLikeAt(v) } + if v, ok := req.Fav.Get(); ok { + b.SetFav(v) + } if v, ok := req.Ten.Get(); ok { b.SetTen(v) } @@ -782,6 +1079,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.TenKai.Get(); ok { b.SetTenKai(v) } + if v, ok := req.Aiten.Get(); ok { + b.SetAiten(v) + } if v, ok := req.TenCard.Get(); ok { b.SetTenCard(v) } @@ -800,6 +1100,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.Next.Get(); ok { b.SetNext(v) } + if v, ok := req.Room.Get(); ok { + b.SetRoom(v) + } if v, ok := req.Model.Get(); ok { b.SetModel(v) } @@ -809,12 +1112,6 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.ModelAttack.Get(); ok { b.SetModelAttack(v) } - if v, ok := req.ModelCriticalD.Get(); ok { - b.SetModelCriticalD(v) - } - if v, ok := req.ModelCritical.Get(); ok { - b.SetModelCritical(v) - } if v, ok := req.ModelLimit.Get(); ok { b.SetModelLimit(v) } @@ -824,6 +1121,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.ModelMode.Get(); ok { b.SetModelMode(v) } + if v, ok := req.ModelCritical.Get(); ok { + b.SetModelCritical(v) + } + if v, ok := req.ModelCriticalD.Get(); ok { + b.SetModelCriticalD(v) + } if v, ok := req.Game.Get(); ok { b.SetGame(v) } @@ -843,9 +1146,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if req.Card != nil { b.ClearCard().AddCardIDs(req.Card...) } + if req.Ue != nil { + b.ClearUe().AddUeIDs(req.Ue...) + } + b.SetToken(v) } } - // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -880,6 +1186,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param // DeleteUser handles DELETE /users/{id} requests. func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) { err := h.client.User.DeleteOneID(0).Exec(ctx) + //err := h.client.User.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -975,3 +1282,39 @@ func (h *OgentHandler) ListUserCard(ctx context.Context, params ListUserCardPara r := NewUserCardLists(es) return (*ListUserCardOKApplicationJSON)(&r), nil } + +// ListUserUe handles GET /users/{id}/ue requests. +func (h *OgentHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) { + q := h.client.User.Query().Where(user.IDEQ(params.ID)).QueryUe() + page := 1 + if v, ok := params.Page.Get(); ok { + page = v + } + itemsPerPage := 30 + if v, ok := params.ItemsPerPage.Get(); ok { + itemsPerPage = v + } + q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage) + es, err := q.All(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + r := NewUserUeLists(es) + return (*ListUserUeOKApplicationJSON)(&r), nil +} diff --git a/ent/ogent/responses.go b/ent/ogent/responses.go index c8f29f4..9160f5d 100644 --- a/ent/ogent/responses.go +++ b/ent/ogent/responses.go @@ -400,6 +400,254 @@ func (u *GroupUsersList) Elem() GroupUsersList { return *u } +func NewUeCreate(e *ent.Ue) *UeCreate { + if e == nil { + return nil + } + var ret UeCreate + ret.ID = e.ID + ret.Limit = NewOptBool(e.Limit) + ret.LimitBoss = NewOptBool(e.LimitBoss) + ret.LimitItem = NewOptBool(e.LimitItem) + ret.Lv = NewOptInt(e.Lv) + ret.LvPoint = NewOptInt(e.LvPoint) + ret.Model = NewOptInt(e.Model) + ret.Sword = NewOptInt(e.Sword) + ret.Card = NewOptInt(e.Card) + ret.Mode = NewOptString(e.Mode) + ret.Cp = NewOptInt(e.Cp) + ret.Count = NewOptInt(e.Count) + ret.LocationX = NewOptInt(e.LocationX) + ret.LocationY = NewOptInt(e.LocationY) + ret.LocationZ = NewOptInt(e.LocationZ) + ret.LocationN = NewOptInt(e.LocationN) + ret.Author = NewOptString(e.Author) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + return &ret +} + +func NewUeCreates(es []*ent.Ue) []UeCreate { + if len(es) == 0 { + return nil + } + r := make([]UeCreate, len(es)) + for i, e := range es { + r[i] = NewUeCreate(e).Elem() + } + return r +} + +func (u *UeCreate) Elem() UeCreate { + if u == nil { + return UeCreate{} + } + return *u +} + +func NewUeList(e *ent.Ue) *UeList { + if e == nil { + return nil + } + var ret UeList + ret.ID = e.ID + ret.Limit = NewOptBool(e.Limit) + ret.LimitBoss = NewOptBool(e.LimitBoss) + ret.LimitItem = NewOptBool(e.LimitItem) + ret.Lv = NewOptInt(e.Lv) + ret.LvPoint = NewOptInt(e.LvPoint) + ret.Model = NewOptInt(e.Model) + ret.Sword = NewOptInt(e.Sword) + ret.Card = NewOptInt(e.Card) + ret.Mode = NewOptString(e.Mode) + ret.Cp = NewOptInt(e.Cp) + ret.Count = NewOptInt(e.Count) + ret.LocationX = NewOptInt(e.LocationX) + ret.LocationY = NewOptInt(e.LocationY) + ret.LocationZ = NewOptInt(e.LocationZ) + ret.LocationN = NewOptInt(e.LocationN) + ret.Author = NewOptString(e.Author) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + return &ret +} + +func NewUeLists(es []*ent.Ue) []UeList { + if len(es) == 0 { + return nil + } + r := make([]UeList, len(es)) + for i, e := range es { + r[i] = NewUeList(e).Elem() + } + return r +} + +func (u *UeList) Elem() UeList { + if u == nil { + return UeList{} + } + return *u +} + +func NewUeRead(e *ent.Ue) *UeRead { + if e == nil { + return nil + } + var ret UeRead + ret.ID = e.ID + ret.Limit = NewOptBool(e.Limit) + ret.LimitBoss = NewOptBool(e.LimitBoss) + ret.LimitItem = NewOptBool(e.LimitItem) + ret.Lv = NewOptInt(e.Lv) + ret.LvPoint = NewOptInt(e.LvPoint) + ret.Model = NewOptInt(e.Model) + ret.Sword = NewOptInt(e.Sword) + ret.Card = NewOptInt(e.Card) + ret.Mode = NewOptString(e.Mode) + ret.Cp = NewOptInt(e.Cp) + ret.Count = NewOptInt(e.Count) + ret.LocationX = NewOptInt(e.LocationX) + ret.LocationY = NewOptInt(e.LocationY) + ret.LocationZ = NewOptInt(e.LocationZ) + ret.LocationN = NewOptInt(e.LocationN) + ret.Author = NewOptString(e.Author) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + return &ret +} + +func NewUeReads(es []*ent.Ue) []UeRead { + if len(es) == 0 { + return nil + } + r := make([]UeRead, len(es)) + for i, e := range es { + r[i] = NewUeRead(e).Elem() + } + return r +} + +func (u *UeRead) Elem() UeRead { + if u == nil { + return UeRead{} + } + return *u +} + +func NewUeUpdate(e *ent.Ue) *UeUpdate { + if e == nil { + return nil + } + var ret UeUpdate + ret.ID = e.ID + ret.Limit = NewOptBool(e.Limit) + ret.LimitBoss = NewOptBool(e.LimitBoss) + ret.LimitItem = NewOptBool(e.LimitItem) + ret.Lv = NewOptInt(e.Lv) + ret.LvPoint = NewOptInt(e.LvPoint) + ret.Model = NewOptInt(e.Model) + ret.Sword = NewOptInt(e.Sword) + ret.Card = NewOptInt(e.Card) + ret.Mode = NewOptString(e.Mode) + ret.Cp = NewOptInt(e.Cp) + ret.Count = NewOptInt(e.Count) + ret.LocationX = NewOptInt(e.LocationX) + ret.LocationY = NewOptInt(e.LocationY) + ret.LocationZ = NewOptInt(e.LocationZ) + ret.LocationN = NewOptInt(e.LocationN) + ret.Author = NewOptString(e.Author) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + return &ret +} + +func NewUeUpdates(es []*ent.Ue) []UeUpdate { + if len(es) == 0 { + return nil + } + r := make([]UeUpdate, len(es)) + for i, e := range es { + r[i] = NewUeUpdate(e).Elem() + } + return r +} + +func (u *UeUpdate) Elem() UeUpdate { + if u == nil { + return UeUpdate{} + } + return *u +} + +func NewUeOwnerRead(e *ent.User) *UeOwnerRead { + if e == nil { + return nil + } + var ret UeOwnerRead + ret.ID = e.ID + ret.Username = e.Username + ret.Did = NewOptString(e.Did) + ret.Member = NewOptBool(e.Member) + ret.Book = NewOptBool(e.Book) + ret.Manga = NewOptBool(e.Manga) + ret.Badge = NewOptBool(e.Badge) + ret.Bsky = NewOptBool(e.Bsky) + ret.Mastodon = NewOptBool(e.Mastodon) + ret.Delete = NewOptBool(e.Delete) + ret.Handle = NewOptBool(e.Handle) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) + ret.RaidAt = NewOptDateTime(e.RaidAt) + ret.ServerAt = NewOptDateTime(e.ServerAt) + ret.EggAt = NewOptDateTime(e.EggAt) + ret.Luck = NewOptInt(e.Luck) + ret.LuckAt = NewOptDateTime(e.LuckAt) + ret.Like = NewOptInt(e.Like) + ret.LikeRank = NewOptInt(e.LikeRank) + ret.LikeAt = NewOptDateTime(e.LikeAt) + ret.Fav = NewOptInt(e.Fav) + ret.Ten = NewOptBool(e.Ten) + ret.TenSu = NewOptInt(e.TenSu) + ret.TenKai = NewOptInt(e.TenKai) + ret.Aiten = NewOptInt(e.Aiten) + ret.TenCard = NewOptString(e.TenCard) + ret.TenDelete = NewOptString(e.TenDelete) + ret.TenPost = NewOptString(e.TenPost) + ret.TenGet = NewOptString(e.TenGet) + ret.TenAt = NewOptDateTime(e.TenAt) + ret.Next = NewOptString(e.Next) + ret.Room = NewOptInt(e.Room) + ret.Model = NewOptBool(e.Model) + ret.ModelAt = NewOptDateTime(e.ModelAt) + ret.ModelAttack = NewOptInt(e.ModelAttack) + ret.ModelLimit = NewOptInt(e.ModelLimit) + ret.ModelSkill = NewOptInt(e.ModelSkill) + ret.ModelMode = NewOptInt(e.ModelMode) + ret.ModelCritical = NewOptInt(e.ModelCritical) + ret.ModelCriticalD = NewOptInt(e.ModelCriticalD) + ret.Game = NewOptBool(e.Game) + ret.GameTest = NewOptBool(e.GameTest) + ret.GameEnd = NewOptBool(e.GameEnd) + ret.GameAccount = NewOptBool(e.GameAccount) + ret.GameLv = NewOptInt(e.GameLv) + return &ret +} + +func NewUeOwnerReads(es []*ent.User) []UeOwnerRead { + if len(es) == 0 { + return nil + } + r := make([]UeOwnerRead, len(es)) + for i, e := range es { + r[i] = NewUeOwnerRead(e).Elem() + } + return r +} + +func (u *UeOwnerRead) Elem() UeOwnerRead { + if u == nil { + return UeOwnerRead{} + } + return *u +} + func NewUserCreate(e *ent.User) *UserCreate { if e == nil { return nil @@ -722,3 +970,47 @@ func (c *UserCardList) Elem() UserCardList { } return *c } + +func NewUserUeList(e *ent.Ue) *UserUeList { + if e == nil { + return nil + } + var ret UserUeList + ret.ID = e.ID + ret.Limit = NewOptBool(e.Limit) + ret.LimitBoss = NewOptBool(e.LimitBoss) + ret.LimitItem = NewOptBool(e.LimitItem) + ret.Lv = NewOptInt(e.Lv) + ret.LvPoint = NewOptInt(e.LvPoint) + ret.Model = NewOptInt(e.Model) + ret.Sword = NewOptInt(e.Sword) + ret.Card = NewOptInt(e.Card) + ret.Mode = NewOptString(e.Mode) + ret.Cp = NewOptInt(e.Cp) + ret.Count = NewOptInt(e.Count) + ret.LocationX = NewOptInt(e.LocationX) + ret.LocationY = NewOptInt(e.LocationY) + ret.LocationZ = NewOptInt(e.LocationZ) + ret.LocationN = NewOptInt(e.LocationN) + ret.Author = NewOptString(e.Author) + ret.CreatedAt = NewOptDateTime(e.CreatedAt) + return &ret +} + +func NewUserUeLists(es []*ent.Ue) []UserUeList { + if len(es) == 0 { + return nil + } + r := make([]UserUeList, len(es)) + for i, e := range es { + r[i] = NewUserUeList(e).Elem() + } + return r +} + +func (u *UserUeList) Elem() UserUeList { + if u == nil { + return UserUeList{} + } + return *u +} diff --git a/ent/openapi.json b/ent/openapi.json index 03dcf71..8f818ae 100644 --- a/ent/openapi.json +++ b/ent/openapi.json @@ -704,6 +704,407 @@ } } }, + "/ues": { + "get": { + "tags": [ + "Ue" + ], + "summary": "List Ues", + "description": "List Ues.", + "operationId": "listUe", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "what page to render", + "schema": { + "type": "integer", + "minimum": 1 + } + }, + { + "name": "itemsPerPage", + "in": "query", + "description": "item count to render per page", + "schema": { + "type": "integer", + "maximum": 5000, + "minimum": 1 + } + } + ], + "responses": { + "200": { + "description": "result Ue list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/UeList" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + }, + "post": { + "tags": [ + "Ue" + ], + "summary": "Create a new Ue", + "description": "Creates a new Ue and persists it to storage.", + "operationId": "createUe", + "requestBody": { + "description": "Ue to create", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "password": { + "type": "string" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "token": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "owner": { + "type": "integer" + } + }, + "required": [ + "password", + "owner" + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Ue created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UeCreate" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } + }, + "/ues/{id}": { + "get": { + "tags": [ + "Ue" + ], + "summary": "Find a Ue by ID", + "description": "Finds the Ue with the requested ID and returns it.", + "operationId": "readUe", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Ue", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "Ue with requested ID was found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UeRead" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + }, + "delete": { + "tags": [ + "Ue" + ], + "summary": "Deletes a Ue by ID", + "description": "Deletes the Ue with the requested ID.", + "operationId": "deleteUe", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Ue", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "Ue with requested ID was deleted" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + }, + "patch": { + "tags": [ + "Ue" + ], + "summary": "Updates a Ue", + "description": "Updates a Ue and persists changes to storage.", + "operationId": "updateUe", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Ue", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "description": "Ue properties to update", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "token": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "owner": { + "type": "integer" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Ue updated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UeUpdate" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } + }, + "/ues/{id}/owner": { + "get": { + "tags": [ + "Ue" + ], + "summary": "Find the attached User", + "description": "Find the attached User of the Ue with the given ID", + "operationId": "readUeOwner", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Ue", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "User attached to Ue with requested ID was found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Ue_OwnerRead" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } + }, "/users": { "get": { "tags": [ @@ -930,6 +1331,12 @@ "items": { "type": "integer" } + }, + "ue": { + "type": "array", + "items": { + "type": "integer" + } } }, "required": [ @@ -1214,6 +1621,12 @@ "items": { "type": "integer" } + }, + "ue": { + "type": "array", + "items": { + "type": "integer" + } } } } @@ -1335,6 +1748,70 @@ } } ] + }, + "/users/{id}/ue": { + "get": { + "tags": [ + "User" + ], + "summary": "List attached Ues", + "description": "List attached Ues.", + "operationId": "listUserUe", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the User", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "name": "page", + "in": "query", + "description": "what page to render", + "schema": { + "type": "integer" + } + }, + { + "name": "itemsPerPage", + "in": "query", + "description": "item count to render per page", + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "result Users list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User_UeList" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } } }, "components": { @@ -1927,6 +2404,488 @@ "username" ] }, + "Ue": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "password": { + "type": "string" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "token": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "owner": { + "$ref": "#/components/schemas/User" + } + }, + "required": [ + "id", + "password", + "owner" + ] + }, + "UeCreate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id" + ] + }, + "UeList": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id" + ] + }, + "UeRead": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id" + ] + }, + "UeUpdate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id" + ] + }, + "Ue_OwnerRead": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "username": { + "type": "string" + }, + "did": { + "type": "string" + }, + "member": { + "type": "boolean" + }, + "book": { + "type": "boolean" + }, + "manga": { + "type": "boolean" + }, + "badge": { + "type": "boolean" + }, + "bsky": { + "type": "boolean" + }, + "mastodon": { + "type": "boolean" + }, + "delete": { + "type": "boolean" + }, + "handle": { + "type": "boolean" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "raid_at": { + "type": "string", + "format": "date-time" + }, + "server_at": { + "type": "string", + "format": "date-time" + }, + "egg_at": { + "type": "string", + "format": "date-time" + }, + "luck": { + "type": "integer" + }, + "luck_at": { + "type": "string", + "format": "date-time" + }, + "like": { + "type": "integer" + }, + "like_rank": { + "type": "integer" + }, + "like_at": { + "type": "string", + "format": "date-time" + }, + "fav": { + "type": "integer" + }, + "ten": { + "type": "boolean" + }, + "ten_su": { + "type": "integer" + }, + "ten_kai": { + "type": "integer" + }, + "aiten": { + "type": "integer" + }, + "ten_card": { + "type": "string" + }, + "ten_delete": { + "type": "string" + }, + "ten_post": { + "type": "string" + }, + "ten_get": { + "type": "string" + }, + "ten_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "room": { + "type": "integer" + }, + "model": { + "type": "boolean" + }, + "model_at": { + "type": "string", + "format": "date-time" + }, + "model_attack": { + "type": "integer" + }, + "model_limit": { + "type": "integer" + }, + "model_skill": { + "type": "integer" + }, + "model_mode": { + "type": "integer" + }, + "model_critical": { + "type": "integer" + }, + "model_critical_d": { + "type": "integer" + }, + "game": { + "type": "boolean" + }, + "game_test": { + "type": "boolean" + }, + "game_end": { + "type": "boolean" + }, + "game_account": { + "type": "boolean" + }, + "game_lv": { + "type": "integer" + } + }, + "required": [ + "id", + "username" + ] + }, "User": { "type": "object", "properties": { @@ -2088,6 +3047,12 @@ "items": { "$ref": "#/components/schemas/Card" } + }, + "ue": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Ue" + } } }, "required": [ @@ -2755,6 +3720,69 @@ "required": [ "id" ] + }, + "User_UeList": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "limit": { + "type": "boolean" + }, + "limit_boss": { + "type": "boolean" + }, + "limit_item": { + "type": "boolean" + }, + "lv": { + "type": "integer" + }, + "lv_point": { + "type": "integer" + }, + "model": { + "type": "integer" + }, + "sword": { + "type": "integer" + }, + "card": { + "type": "integer" + }, + "mode": { + "type": "string" + }, + "cp": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "location_x": { + "type": "integer" + }, + "location_y": { + "type": "integer" + }, + "location_z": { + "type": "integer" + }, + "location_n": { + "type": "integer" + }, + "author": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id" + ] } }, "responses": { diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index 62c2877..221303d 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -12,5 +12,8 @@ type Card func(*sql.Selector) // Group is the predicate function for group builders. type Group func(*sql.Selector) +// Ue is the predicate function for ue builders. +type Ue func(*sql.Selector) + // User is the predicate function for user builders. type User func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go index 8423679..7f9450b 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -6,6 +6,7 @@ import ( "t/ent/card" "t/ent/group" "t/ent/schema" + "t/ent/ue" "t/ent/user" "time" ) @@ -50,6 +51,28 @@ func init() { groupDescPassword := groupFields[1].Descriptor() // group.PasswordValidator is a validator for the "password" field. It is called by the builders before save. group.PasswordValidator = groupDescPassword.Validators[0].(func(string) error) + ueFields := schema.Ue{}.Fields() + _ = ueFields + // ueDescLimit is the schema descriptor for limit field. + ueDescLimit := ueFields[0].Descriptor() + // ue.DefaultLimit holds the default value on creation for the limit field. + ue.DefaultLimit = ueDescLimit.Default.(bool) + // ueDescLimitBoss is the schema descriptor for limit_boss field. + ueDescLimitBoss := ueFields[1].Descriptor() + // ue.DefaultLimitBoss holds the default value on creation for the limit_boss field. + ue.DefaultLimitBoss = ueDescLimitBoss.Default.(bool) + // ueDescLimitItem is the schema descriptor for limit_item field. + ueDescLimitItem := ueFields[2].Descriptor() + // ue.DefaultLimitItem holds the default value on creation for the limit_item field. + ue.DefaultLimitItem = ueDescLimitItem.Default.(bool) + // ueDescPassword is the schema descriptor for password field. + ueDescPassword := ueFields[3].Descriptor() + // ue.PasswordValidator is a validator for the "password" field. It is called by the builders before save. + ue.PasswordValidator = ueDescPassword.Validators[0].(func(string) error) + // ueDescCreatedAt is the schema descriptor for created_at field. + ueDescCreatedAt := ueFields[18].Descriptor() + // ue.DefaultCreatedAt holds the default value on creation for the created_at field. + ue.DefaultCreatedAt = ueDescCreatedAt.Default.(func() time.Time) userFields := schema.User{}.Fields() _ = userFields // userDescUsername is the schema descriptor for username field. diff --git a/ent/schema/ue.go b/ent/schema/ue.go new file mode 100644 index 0000000..80a6b05 --- /dev/null +++ b/ent/schema/ue.go @@ -0,0 +1,95 @@ +package schema + +import ( + "time" + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Game holds the schema definition for the Game entity. +type Ue struct { + ent.Schema +} + +func (Ue) Fields() []ent.Field { + return []ent.Field{ + + field.Bool("limit"). + Default(false). + Optional(), + + field.Bool("limit_boss"). + Default(false). + Optional(), + + field.Bool("limit_item"). + Default(false). + Optional(), + + field.String("password"). + NotEmpty(). + Immutable(). + Sensitive(), + + field.Int("lv"). + Optional(), + + field.Int("lv_point"). + Optional(), + + field.Int("model"). + Optional(), + + field.Int("sword"). + Optional(), + + field.Int("card"). + Optional(), + + field.String("mode"). + Optional(), + + field.String("token"). + Optional(). + Sensitive(), + + field.Int("cp"). + Optional(), + + field.Int("count"). + Optional(), + + field.Int("location_x"). + Optional(), + + field.Int("location_y"). + Optional(), + + field.Int("location_z"). + Optional(), + + field.Int("location_n"). + Optional(), + + field.String("author"). + Optional(), + + field.Time("created_at"). + Immutable(). + Optional(). + Default(func() time.Time { + return time.Now().In(jst) + }), + } +} + +func (Ue) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("owner", User.Type). + Ref("ue"). + Unique(). + Required(), + + } +} diff --git a/ent/schema/user.go b/ent/schema/user.go index 44a3f9e..cce57b8 100644 --- a/ent/schema/user.go +++ b/ent/schema/user.go @@ -229,6 +229,8 @@ func (User) Indexes() []ent.Index { func (User) Edges() []ent.Edge { return []ent.Edge{ edge.To("card", Card.Type), + edge.To("ue", Ue.Type), //Unique(), } } + diff --git a/ent/tx.go b/ent/tx.go index 598fb90..26bdf04 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { Card *CardClient // Group is the client for interacting with the Group builders. Group *GroupClient + // Ue is the client for interacting with the Ue builders. + Ue *UeClient // User is the client for interacting with the User builders. User *UserClient @@ -151,6 +153,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Card = NewCardClient(tx.config) tx.Group = NewGroupClient(tx.config) + tx.Ue = NewUeClient(tx.config) tx.User = NewUserClient(tx.config) } diff --git a/ent/ue.go b/ent/ue.go new file mode 100644 index 0000000..459a685 --- /dev/null +++ b/ent/ue.go @@ -0,0 +1,335 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "t/ent/ue" + "t/ent/user" + "time" + + "entgo.io/ent/dialect/sql" +) + +// Ue is the model entity for the Ue schema. +type Ue struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Limit holds the value of the "limit" field. + Limit bool `json:"limit,omitempty"` + // LimitBoss holds the value of the "limit_boss" field. + LimitBoss bool `json:"limit_boss,omitempty"` + // LimitItem holds the value of the "limit_item" field. + LimitItem bool `json:"limit_item,omitempty"` + // Password holds the value of the "password" field. + Password string `json:"-"` + // Lv holds the value of the "lv" field. + Lv int `json:"lv,omitempty"` + // LvPoint holds the value of the "lv_point" field. + LvPoint int `json:"lv_point,omitempty"` + // Model holds the value of the "model" field. + Model int `json:"model,omitempty"` + // Sword holds the value of the "sword" field. + Sword int `json:"sword,omitempty"` + // Card holds the value of the "card" field. + Card int `json:"card,omitempty"` + // Mode holds the value of the "mode" field. + Mode string `json:"mode,omitempty"` + // Token holds the value of the "token" field. + Token string `json:"-"` + // Cp holds the value of the "cp" field. + Cp int `json:"cp,omitempty"` + // Count holds the value of the "count" field. + Count int `json:"count,omitempty"` + // LocationX holds the value of the "location_x" field. + LocationX int `json:"location_x,omitempty"` + // LocationY holds the value of the "location_y" field. + LocationY int `json:"location_y,omitempty"` + // LocationZ holds the value of the "location_z" field. + LocationZ int `json:"location_z,omitempty"` + // LocationN holds the value of the "location_n" field. + LocationN int `json:"location_n,omitempty"` + // Author holds the value of the "author" field. + Author string `json:"author,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UeQuery when eager-loading is set. + Edges UeEdges `json:"edges"` + user_ue *int +} + +// UeEdges holds the relations/edges for other nodes in the graph. +type UeEdges struct { + // Owner holds the value of the owner edge. + Owner *User `json:"owner,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// OwnerOrErr returns the Owner value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UeEdges) OwnerOrErr() (*User, error) { + if e.loadedTypes[0] { + if e.Owner == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.Owner, nil + } + return nil, &NotLoadedError{edge: "owner"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Ue) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case ue.FieldLimit, ue.FieldLimitBoss, ue.FieldLimitItem: + values[i] = new(sql.NullBool) + case ue.FieldID, ue.FieldLv, ue.FieldLvPoint, ue.FieldModel, ue.FieldSword, ue.FieldCard, ue.FieldCp, ue.FieldCount, ue.FieldLocationX, ue.FieldLocationY, ue.FieldLocationZ, ue.FieldLocationN: + values[i] = new(sql.NullInt64) + case ue.FieldPassword, ue.FieldMode, ue.FieldToken, ue.FieldAuthor: + values[i] = new(sql.NullString) + case ue.FieldCreatedAt: + values[i] = new(sql.NullTime) + case ue.ForeignKeys[0]: // user_ue + values[i] = new(sql.NullInt64) + default: + return nil, fmt.Errorf("unexpected column %q for type Ue", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Ue fields. +func (u *Ue) 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 ue.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + u.ID = int(value.Int64) + case ue.FieldLimit: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field limit", values[i]) + } else if value.Valid { + u.Limit = value.Bool + } + case ue.FieldLimitBoss: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field limit_boss", values[i]) + } else if value.Valid { + u.LimitBoss = value.Bool + } + case ue.FieldLimitItem: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field limit_item", values[i]) + } else if value.Valid { + u.LimitItem = value.Bool + } + case ue.FieldPassword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field password", values[i]) + } else if value.Valid { + u.Password = value.String + } + case ue.FieldLv: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field lv", values[i]) + } else if value.Valid { + u.Lv = int(value.Int64) + } + case ue.FieldLvPoint: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field lv_point", values[i]) + } else if value.Valid { + u.LvPoint = int(value.Int64) + } + case ue.FieldModel: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field model", values[i]) + } else if value.Valid { + u.Model = int(value.Int64) + } + case ue.FieldSword: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sword", values[i]) + } else if value.Valid { + u.Sword = int(value.Int64) + } + case ue.FieldCard: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field card", values[i]) + } else if value.Valid { + u.Card = int(value.Int64) + } + case ue.FieldMode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mode", values[i]) + } else if value.Valid { + u.Mode = value.String + } + case ue.FieldToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field token", values[i]) + } else if value.Valid { + u.Token = value.String + } + case ue.FieldCp: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field cp", values[i]) + } else if value.Valid { + u.Cp = int(value.Int64) + } + case ue.FieldCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field count", values[i]) + } else if value.Valid { + u.Count = int(value.Int64) + } + case ue.FieldLocationX: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field location_x", values[i]) + } else if value.Valid { + u.LocationX = int(value.Int64) + } + case ue.FieldLocationY: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field location_y", values[i]) + } else if value.Valid { + u.LocationY = int(value.Int64) + } + case ue.FieldLocationZ: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field location_z", values[i]) + } else if value.Valid { + u.LocationZ = int(value.Int64) + } + case ue.FieldLocationN: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field location_n", values[i]) + } else if value.Valid { + u.LocationN = int(value.Int64) + } + case ue.FieldAuthor: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field author", values[i]) + } else if value.Valid { + u.Author = value.String + } + case ue.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 { + u.CreatedAt = value.Time + } + case ue.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field user_ue", value) + } else if value.Valid { + u.user_ue = new(int) + *u.user_ue = int(value.Int64) + } + } + } + return nil +} + +// QueryOwner queries the "owner" edge of the Ue entity. +func (u *Ue) QueryOwner() *UserQuery { + return NewUeClient(u.config).QueryOwner(u) +} + +// Update returns a builder for updating this Ue. +// Note that you need to call Ue.Unwrap() before calling this method if this Ue +// was returned from a transaction, and the transaction was committed or rolled back. +func (u *Ue) Update() *UeUpdateOne { + return NewUeClient(u.config).UpdateOne(u) +} + +// Unwrap unwraps the Ue 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 (u *Ue) Unwrap() *Ue { + _tx, ok := u.config.driver.(*txDriver) + if !ok { + panic("ent: Ue is not a transactional entity") + } + u.config.driver = _tx.drv + return u +} + +// String implements the fmt.Stringer. +func (u *Ue) String() string { + var builder strings.Builder + builder.WriteString("Ue(") + builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) + builder.WriteString("limit=") + builder.WriteString(fmt.Sprintf("%v", u.Limit)) + builder.WriteString(", ") + builder.WriteString("limit_boss=") + builder.WriteString(fmt.Sprintf("%v", u.LimitBoss)) + builder.WriteString(", ") + builder.WriteString("limit_item=") + builder.WriteString(fmt.Sprintf("%v", u.LimitItem)) + builder.WriteString(", ") + builder.WriteString("password=") + builder.WriteString(", ") + builder.WriteString("lv=") + builder.WriteString(fmt.Sprintf("%v", u.Lv)) + builder.WriteString(", ") + builder.WriteString("lv_point=") + builder.WriteString(fmt.Sprintf("%v", u.LvPoint)) + builder.WriteString(", ") + builder.WriteString("model=") + builder.WriteString(fmt.Sprintf("%v", u.Model)) + builder.WriteString(", ") + builder.WriteString("sword=") + builder.WriteString(fmt.Sprintf("%v", u.Sword)) + builder.WriteString(", ") + builder.WriteString("card=") + builder.WriteString(fmt.Sprintf("%v", u.Card)) + builder.WriteString(", ") + builder.WriteString("mode=") + builder.WriteString(u.Mode) + builder.WriteString(", ") + builder.WriteString("token=") + builder.WriteString(", ") + builder.WriteString("cp=") + builder.WriteString(fmt.Sprintf("%v", u.Cp)) + builder.WriteString(", ") + builder.WriteString("count=") + builder.WriteString(fmt.Sprintf("%v", u.Count)) + builder.WriteString(", ") + builder.WriteString("location_x=") + builder.WriteString(fmt.Sprintf("%v", u.LocationX)) + builder.WriteString(", ") + builder.WriteString("location_y=") + builder.WriteString(fmt.Sprintf("%v", u.LocationY)) + builder.WriteString(", ") + builder.WriteString("location_z=") + builder.WriteString(fmt.Sprintf("%v", u.LocationZ)) + builder.WriteString(", ") + builder.WriteString("location_n=") + builder.WriteString(fmt.Sprintf("%v", u.LocationN)) + builder.WriteString(", ") + builder.WriteString("author=") + builder.WriteString(u.Author) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(u.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// Ues is a parsable slice of Ue. +type Ues []*Ue diff --git a/ent/ue/ue.go b/ent/ue/ue.go new file mode 100644 index 0000000..d6a78a7 --- /dev/null +++ b/ent/ue/ue.go @@ -0,0 +1,121 @@ +// Code generated by ent, DO NOT EDIT. + +package ue + +import ( + "time" +) + +const ( + // Label holds the string label denoting the ue type in the database. + Label = "ue" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldLimit holds the string denoting the limit field in the database. + FieldLimit = "limit" + // FieldLimitBoss holds the string denoting the limit_boss field in the database. + FieldLimitBoss = "limit_boss" + // FieldLimitItem holds the string denoting the limit_item field in the database. + FieldLimitItem = "limit_item" + // FieldPassword holds the string denoting the password field in the database. + FieldPassword = "password" + // FieldLv holds the string denoting the lv field in the database. + FieldLv = "lv" + // FieldLvPoint holds the string denoting the lv_point field in the database. + FieldLvPoint = "lv_point" + // FieldModel holds the string denoting the model field in the database. + FieldModel = "model" + // FieldSword holds the string denoting the sword field in the database. + FieldSword = "sword" + // FieldCard holds the string denoting the card field in the database. + FieldCard = "card" + // FieldMode holds the string denoting the mode field in the database. + FieldMode = "mode" + // FieldToken holds the string denoting the token field in the database. + FieldToken = "token" + // FieldCp holds the string denoting the cp field in the database. + FieldCp = "cp" + // FieldCount holds the string denoting the count field in the database. + FieldCount = "count" + // FieldLocationX holds the string denoting the location_x field in the database. + FieldLocationX = "location_x" + // FieldLocationY holds the string denoting the location_y field in the database. + FieldLocationY = "location_y" + // FieldLocationZ holds the string denoting the location_z field in the database. + FieldLocationZ = "location_z" + // FieldLocationN holds the string denoting the location_n field in the database. + FieldLocationN = "location_n" + // FieldAuthor holds the string denoting the author field in the database. + FieldAuthor = "author" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // EdgeOwner holds the string denoting the owner edge name in mutations. + EdgeOwner = "owner" + // Table holds the table name of the ue in the database. + Table = "ues" + // OwnerTable is the table that holds the owner relation/edge. + OwnerTable = "ues" + // OwnerInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + OwnerInverseTable = "users" + // OwnerColumn is the table column denoting the owner relation/edge. + OwnerColumn = "user_ue" +) + +// Columns holds all SQL columns for ue fields. +var Columns = []string{ + FieldID, + FieldLimit, + FieldLimitBoss, + FieldLimitItem, + FieldPassword, + FieldLv, + FieldLvPoint, + FieldModel, + FieldSword, + FieldCard, + FieldMode, + FieldToken, + FieldCp, + FieldCount, + FieldLocationX, + FieldLocationY, + FieldLocationZ, + FieldLocationN, + FieldAuthor, + FieldCreatedAt, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "ues" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "user_ue", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // DefaultLimit holds the default value on creation for the "limit" field. + DefaultLimit bool + // DefaultLimitBoss holds the default value on creation for the "limit_boss" field. + DefaultLimitBoss bool + // DefaultLimitItem holds the default value on creation for the "limit_item" field. + DefaultLimitItem bool + // PasswordValidator is a validator for the "password" field. It is called by the builders before save. + PasswordValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time +) diff --git a/ent/ue/where.go b/ent/ue/where.go new file mode 100644 index 0000000..7ee84d7 --- /dev/null +++ b/ent/ue/where.go @@ -0,0 +1,1160 @@ +// Code generated by ent, DO NOT EDIT. + +package ue + +import ( + "t/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldID, id)) +} + +// Limit applies equality check predicate on the "limit" field. It's identical to LimitEQ. +func Limit(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimit, v)) +} + +// LimitBoss applies equality check predicate on the "limit_boss" field. It's identical to LimitBossEQ. +func LimitBoss(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimitBoss, v)) +} + +// LimitItem applies equality check predicate on the "limit_item" field. It's identical to LimitItemEQ. +func LimitItem(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimitItem, v)) +} + +// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. +func Password(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldPassword, v)) +} + +// Lv applies equality check predicate on the "lv" field. It's identical to LvEQ. +func Lv(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLv, v)) +} + +// LvPoint applies equality check predicate on the "lv_point" field. It's identical to LvPointEQ. +func LvPoint(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLvPoint, v)) +} + +// Model applies equality check predicate on the "model" field. It's identical to ModelEQ. +func Model(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldModel, v)) +} + +// Sword applies equality check predicate on the "sword" field. It's identical to SwordEQ. +func Sword(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldSword, v)) +} + +// Card applies equality check predicate on the "card" field. It's identical to CardEQ. +func Card(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCard, v)) +} + +// Mode applies equality check predicate on the "mode" field. It's identical to ModeEQ. +func Mode(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldMode, v)) +} + +// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. +func Token(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldToken, v)) +} + +// Cp applies equality check predicate on the "cp" field. It's identical to CpEQ. +func Cp(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCp, v)) +} + +// Count applies equality check predicate on the "count" field. It's identical to CountEQ. +func Count(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCount, v)) +} + +// LocationX applies equality check predicate on the "location_x" field. It's identical to LocationXEQ. +func LocationX(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationX, v)) +} + +// LocationY applies equality check predicate on the "location_y" field. It's identical to LocationYEQ. +func LocationY(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationY, v)) +} + +// LocationZ applies equality check predicate on the "location_z" field. It's identical to LocationZEQ. +func LocationZ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationZ, v)) +} + +// LocationN applies equality check predicate on the "location_n" field. It's identical to LocationNEQ. +func LocationN(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationN, v)) +} + +// Author applies equality check predicate on the "author" field. It's identical to AuthorEQ. +func Author(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldAuthor, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LimitEQ applies the EQ predicate on the "limit" field. +func LimitEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimit, v)) +} + +// LimitNEQ applies the NEQ predicate on the "limit" field. +func LimitNEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLimit, v)) +} + +// LimitIsNil applies the IsNil predicate on the "limit" field. +func LimitIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLimit)) +} + +// LimitNotNil applies the NotNil predicate on the "limit" field. +func LimitNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLimit)) +} + +// LimitBossEQ applies the EQ predicate on the "limit_boss" field. +func LimitBossEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimitBoss, v)) +} + +// LimitBossNEQ applies the NEQ predicate on the "limit_boss" field. +func LimitBossNEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLimitBoss, v)) +} + +// LimitBossIsNil applies the IsNil predicate on the "limit_boss" field. +func LimitBossIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLimitBoss)) +} + +// LimitBossNotNil applies the NotNil predicate on the "limit_boss" field. +func LimitBossNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLimitBoss)) +} + +// LimitItemEQ applies the EQ predicate on the "limit_item" field. +func LimitItemEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLimitItem, v)) +} + +// LimitItemNEQ applies the NEQ predicate on the "limit_item" field. +func LimitItemNEQ(v bool) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLimitItem, v)) +} + +// LimitItemIsNil applies the IsNil predicate on the "limit_item" field. +func LimitItemIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLimitItem)) +} + +// LimitItemNotNil applies the NotNil predicate on the "limit_item" field. +func LimitItemNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLimitItem)) +} + +// PasswordEQ applies the EQ predicate on the "password" field. +func PasswordEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldPassword, v)) +} + +// PasswordNEQ applies the NEQ predicate on the "password" field. +func PasswordNEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldPassword, v)) +} + +// PasswordIn applies the In predicate on the "password" field. +func PasswordIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldPassword, vs...)) +} + +// PasswordNotIn applies the NotIn predicate on the "password" field. +func PasswordNotIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldPassword, vs...)) +} + +// PasswordGT applies the GT predicate on the "password" field. +func PasswordGT(v string) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldPassword, v)) +} + +// PasswordGTE applies the GTE predicate on the "password" field. +func PasswordGTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldPassword, v)) +} + +// PasswordLT applies the LT predicate on the "password" field. +func PasswordLT(v string) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldPassword, v)) +} + +// PasswordLTE applies the LTE predicate on the "password" field. +func PasswordLTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldPassword, v)) +} + +// PasswordContains applies the Contains predicate on the "password" field. +func PasswordContains(v string) predicate.Ue { + return predicate.Ue(sql.FieldContains(FieldPassword, v)) +} + +// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. +func PasswordHasPrefix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasPrefix(FieldPassword, v)) +} + +// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. +func PasswordHasSuffix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasSuffix(FieldPassword, v)) +} + +// PasswordEqualFold applies the EqualFold predicate on the "password" field. +func PasswordEqualFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldEqualFold(FieldPassword, v)) +} + +// PasswordContainsFold applies the ContainsFold predicate on the "password" field. +func PasswordContainsFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldContainsFold(FieldPassword, v)) +} + +// LvEQ applies the EQ predicate on the "lv" field. +func LvEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLv, v)) +} + +// LvNEQ applies the NEQ predicate on the "lv" field. +func LvNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLv, v)) +} + +// LvIn applies the In predicate on the "lv" field. +func LvIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLv, vs...)) +} + +// LvNotIn applies the NotIn predicate on the "lv" field. +func LvNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLv, vs...)) +} + +// LvGT applies the GT predicate on the "lv" field. +func LvGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLv, v)) +} + +// LvGTE applies the GTE predicate on the "lv" field. +func LvGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLv, v)) +} + +// LvLT applies the LT predicate on the "lv" field. +func LvLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLv, v)) +} + +// LvLTE applies the LTE predicate on the "lv" field. +func LvLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLv, v)) +} + +// LvIsNil applies the IsNil predicate on the "lv" field. +func LvIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLv)) +} + +// LvNotNil applies the NotNil predicate on the "lv" field. +func LvNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLv)) +} + +// LvPointEQ applies the EQ predicate on the "lv_point" field. +func LvPointEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLvPoint, v)) +} + +// LvPointNEQ applies the NEQ predicate on the "lv_point" field. +func LvPointNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLvPoint, v)) +} + +// LvPointIn applies the In predicate on the "lv_point" field. +func LvPointIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLvPoint, vs...)) +} + +// LvPointNotIn applies the NotIn predicate on the "lv_point" field. +func LvPointNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLvPoint, vs...)) +} + +// LvPointGT applies the GT predicate on the "lv_point" field. +func LvPointGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLvPoint, v)) +} + +// LvPointGTE applies the GTE predicate on the "lv_point" field. +func LvPointGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLvPoint, v)) +} + +// LvPointLT applies the LT predicate on the "lv_point" field. +func LvPointLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLvPoint, v)) +} + +// LvPointLTE applies the LTE predicate on the "lv_point" field. +func LvPointLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLvPoint, v)) +} + +// LvPointIsNil applies the IsNil predicate on the "lv_point" field. +func LvPointIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLvPoint)) +} + +// LvPointNotNil applies the NotNil predicate on the "lv_point" field. +func LvPointNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLvPoint)) +} + +// ModelEQ applies the EQ predicate on the "model" field. +func ModelEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldModel, v)) +} + +// ModelNEQ applies the NEQ predicate on the "model" field. +func ModelNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldModel, v)) +} + +// ModelIn applies the In predicate on the "model" field. +func ModelIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldModel, vs...)) +} + +// ModelNotIn applies the NotIn predicate on the "model" field. +func ModelNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldModel, vs...)) +} + +// ModelGT applies the GT predicate on the "model" field. +func ModelGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldModel, v)) +} + +// ModelGTE applies the GTE predicate on the "model" field. +func ModelGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldModel, v)) +} + +// ModelLT applies the LT predicate on the "model" field. +func ModelLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldModel, v)) +} + +// ModelLTE applies the LTE predicate on the "model" field. +func ModelLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldModel, v)) +} + +// ModelIsNil applies the IsNil predicate on the "model" field. +func ModelIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldModel)) +} + +// ModelNotNil applies the NotNil predicate on the "model" field. +func ModelNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldModel)) +} + +// SwordEQ applies the EQ predicate on the "sword" field. +func SwordEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldSword, v)) +} + +// SwordNEQ applies the NEQ predicate on the "sword" field. +func SwordNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldSword, v)) +} + +// SwordIn applies the In predicate on the "sword" field. +func SwordIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldSword, vs...)) +} + +// SwordNotIn applies the NotIn predicate on the "sword" field. +func SwordNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldSword, vs...)) +} + +// SwordGT applies the GT predicate on the "sword" field. +func SwordGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldSword, v)) +} + +// SwordGTE applies the GTE predicate on the "sword" field. +func SwordGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldSword, v)) +} + +// SwordLT applies the LT predicate on the "sword" field. +func SwordLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldSword, v)) +} + +// SwordLTE applies the LTE predicate on the "sword" field. +func SwordLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldSword, v)) +} + +// SwordIsNil applies the IsNil predicate on the "sword" field. +func SwordIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldSword)) +} + +// SwordNotNil applies the NotNil predicate on the "sword" field. +func SwordNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldSword)) +} + +// CardEQ applies the EQ predicate on the "card" field. +func CardEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCard, v)) +} + +// CardNEQ applies the NEQ predicate on the "card" field. +func CardNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldCard, v)) +} + +// CardIn applies the In predicate on the "card" field. +func CardIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldCard, vs...)) +} + +// CardNotIn applies the NotIn predicate on the "card" field. +func CardNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldCard, vs...)) +} + +// CardGT applies the GT predicate on the "card" field. +func CardGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldCard, v)) +} + +// CardGTE applies the GTE predicate on the "card" field. +func CardGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldCard, v)) +} + +// CardLT applies the LT predicate on the "card" field. +func CardLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldCard, v)) +} + +// CardLTE applies the LTE predicate on the "card" field. +func CardLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldCard, v)) +} + +// CardIsNil applies the IsNil predicate on the "card" field. +func CardIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldCard)) +} + +// CardNotNil applies the NotNil predicate on the "card" field. +func CardNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldCard)) +} + +// ModeEQ applies the EQ predicate on the "mode" field. +func ModeEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldMode, v)) +} + +// ModeNEQ applies the NEQ predicate on the "mode" field. +func ModeNEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldMode, v)) +} + +// ModeIn applies the In predicate on the "mode" field. +func ModeIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldMode, vs...)) +} + +// ModeNotIn applies the NotIn predicate on the "mode" field. +func ModeNotIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldMode, vs...)) +} + +// ModeGT applies the GT predicate on the "mode" field. +func ModeGT(v string) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldMode, v)) +} + +// ModeGTE applies the GTE predicate on the "mode" field. +func ModeGTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldMode, v)) +} + +// ModeLT applies the LT predicate on the "mode" field. +func ModeLT(v string) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldMode, v)) +} + +// ModeLTE applies the LTE predicate on the "mode" field. +func ModeLTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldMode, v)) +} + +// ModeContains applies the Contains predicate on the "mode" field. +func ModeContains(v string) predicate.Ue { + return predicate.Ue(sql.FieldContains(FieldMode, v)) +} + +// ModeHasPrefix applies the HasPrefix predicate on the "mode" field. +func ModeHasPrefix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasPrefix(FieldMode, v)) +} + +// ModeHasSuffix applies the HasSuffix predicate on the "mode" field. +func ModeHasSuffix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasSuffix(FieldMode, v)) +} + +// ModeIsNil applies the IsNil predicate on the "mode" field. +func ModeIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldMode)) +} + +// ModeNotNil applies the NotNil predicate on the "mode" field. +func ModeNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldMode)) +} + +// ModeEqualFold applies the EqualFold predicate on the "mode" field. +func ModeEqualFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldEqualFold(FieldMode, v)) +} + +// ModeContainsFold applies the ContainsFold predicate on the "mode" field. +func ModeContainsFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldContainsFold(FieldMode, v)) +} + +// TokenEQ applies the EQ predicate on the "token" field. +func TokenEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldToken, v)) +} + +// TokenNEQ applies the NEQ predicate on the "token" field. +func TokenNEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldToken, v)) +} + +// TokenIn applies the In predicate on the "token" field. +func TokenIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldToken, vs...)) +} + +// TokenNotIn applies the NotIn predicate on the "token" field. +func TokenNotIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldToken, vs...)) +} + +// TokenGT applies the GT predicate on the "token" field. +func TokenGT(v string) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldToken, v)) +} + +// TokenGTE applies the GTE predicate on the "token" field. +func TokenGTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldToken, v)) +} + +// TokenLT applies the LT predicate on the "token" field. +func TokenLT(v string) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldToken, v)) +} + +// TokenLTE applies the LTE predicate on the "token" field. +func TokenLTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldToken, v)) +} + +// TokenContains applies the Contains predicate on the "token" field. +func TokenContains(v string) predicate.Ue { + return predicate.Ue(sql.FieldContains(FieldToken, v)) +} + +// TokenHasPrefix applies the HasPrefix predicate on the "token" field. +func TokenHasPrefix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasPrefix(FieldToken, v)) +} + +// TokenHasSuffix applies the HasSuffix predicate on the "token" field. +func TokenHasSuffix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasSuffix(FieldToken, v)) +} + +// TokenIsNil applies the IsNil predicate on the "token" field. +func TokenIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldToken)) +} + +// TokenNotNil applies the NotNil predicate on the "token" field. +func TokenNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldToken)) +} + +// TokenEqualFold applies the EqualFold predicate on the "token" field. +func TokenEqualFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldEqualFold(FieldToken, v)) +} + +// TokenContainsFold applies the ContainsFold predicate on the "token" field. +func TokenContainsFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldContainsFold(FieldToken, v)) +} + +// CpEQ applies the EQ predicate on the "cp" field. +func CpEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCp, v)) +} + +// CpNEQ applies the NEQ predicate on the "cp" field. +func CpNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldCp, v)) +} + +// CpIn applies the In predicate on the "cp" field. +func CpIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldCp, vs...)) +} + +// CpNotIn applies the NotIn predicate on the "cp" field. +func CpNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldCp, vs...)) +} + +// CpGT applies the GT predicate on the "cp" field. +func CpGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldCp, v)) +} + +// CpGTE applies the GTE predicate on the "cp" field. +func CpGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldCp, v)) +} + +// CpLT applies the LT predicate on the "cp" field. +func CpLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldCp, v)) +} + +// CpLTE applies the LTE predicate on the "cp" field. +func CpLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldCp, v)) +} + +// CpIsNil applies the IsNil predicate on the "cp" field. +func CpIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldCp)) +} + +// CpNotNil applies the NotNil predicate on the "cp" field. +func CpNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldCp)) +} + +// CountEQ applies the EQ predicate on the "count" field. +func CountEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCount, v)) +} + +// CountNEQ applies the NEQ predicate on the "count" field. +func CountNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldCount, v)) +} + +// CountIn applies the In predicate on the "count" field. +func CountIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldCount, vs...)) +} + +// CountNotIn applies the NotIn predicate on the "count" field. +func CountNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldCount, vs...)) +} + +// CountGT applies the GT predicate on the "count" field. +func CountGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldCount, v)) +} + +// CountGTE applies the GTE predicate on the "count" field. +func CountGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldCount, v)) +} + +// CountLT applies the LT predicate on the "count" field. +func CountLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldCount, v)) +} + +// CountLTE applies the LTE predicate on the "count" field. +func CountLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldCount, v)) +} + +// CountIsNil applies the IsNil predicate on the "count" field. +func CountIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldCount)) +} + +// CountNotNil applies the NotNil predicate on the "count" field. +func CountNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldCount)) +} + +// LocationXEQ applies the EQ predicate on the "location_x" field. +func LocationXEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationX, v)) +} + +// LocationXNEQ applies the NEQ predicate on the "location_x" field. +func LocationXNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLocationX, v)) +} + +// LocationXIn applies the In predicate on the "location_x" field. +func LocationXIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLocationX, vs...)) +} + +// LocationXNotIn applies the NotIn predicate on the "location_x" field. +func LocationXNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLocationX, vs...)) +} + +// LocationXGT applies the GT predicate on the "location_x" field. +func LocationXGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLocationX, v)) +} + +// LocationXGTE applies the GTE predicate on the "location_x" field. +func LocationXGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLocationX, v)) +} + +// LocationXLT applies the LT predicate on the "location_x" field. +func LocationXLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLocationX, v)) +} + +// LocationXLTE applies the LTE predicate on the "location_x" field. +func LocationXLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLocationX, v)) +} + +// LocationXIsNil applies the IsNil predicate on the "location_x" field. +func LocationXIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLocationX)) +} + +// LocationXNotNil applies the NotNil predicate on the "location_x" field. +func LocationXNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLocationX)) +} + +// LocationYEQ applies the EQ predicate on the "location_y" field. +func LocationYEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationY, v)) +} + +// LocationYNEQ applies the NEQ predicate on the "location_y" field. +func LocationYNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLocationY, v)) +} + +// LocationYIn applies the In predicate on the "location_y" field. +func LocationYIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLocationY, vs...)) +} + +// LocationYNotIn applies the NotIn predicate on the "location_y" field. +func LocationYNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLocationY, vs...)) +} + +// LocationYGT applies the GT predicate on the "location_y" field. +func LocationYGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLocationY, v)) +} + +// LocationYGTE applies the GTE predicate on the "location_y" field. +func LocationYGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLocationY, v)) +} + +// LocationYLT applies the LT predicate on the "location_y" field. +func LocationYLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLocationY, v)) +} + +// LocationYLTE applies the LTE predicate on the "location_y" field. +func LocationYLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLocationY, v)) +} + +// LocationYIsNil applies the IsNil predicate on the "location_y" field. +func LocationYIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLocationY)) +} + +// LocationYNotNil applies the NotNil predicate on the "location_y" field. +func LocationYNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLocationY)) +} + +// LocationZEQ applies the EQ predicate on the "location_z" field. +func LocationZEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationZ, v)) +} + +// LocationZNEQ applies the NEQ predicate on the "location_z" field. +func LocationZNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLocationZ, v)) +} + +// LocationZIn applies the In predicate on the "location_z" field. +func LocationZIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLocationZ, vs...)) +} + +// LocationZNotIn applies the NotIn predicate on the "location_z" field. +func LocationZNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLocationZ, vs...)) +} + +// LocationZGT applies the GT predicate on the "location_z" field. +func LocationZGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLocationZ, v)) +} + +// LocationZGTE applies the GTE predicate on the "location_z" field. +func LocationZGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLocationZ, v)) +} + +// LocationZLT applies the LT predicate on the "location_z" field. +func LocationZLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLocationZ, v)) +} + +// LocationZLTE applies the LTE predicate on the "location_z" field. +func LocationZLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLocationZ, v)) +} + +// LocationZIsNil applies the IsNil predicate on the "location_z" field. +func LocationZIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLocationZ)) +} + +// LocationZNotNil applies the NotNil predicate on the "location_z" field. +func LocationZNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLocationZ)) +} + +// LocationNEQ applies the EQ predicate on the "location_n" field. +func LocationNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldLocationN, v)) +} + +// LocationNNEQ applies the NEQ predicate on the "location_n" field. +func LocationNNEQ(v int) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldLocationN, v)) +} + +// LocationNIn applies the In predicate on the "location_n" field. +func LocationNIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldLocationN, vs...)) +} + +// LocationNNotIn applies the NotIn predicate on the "location_n" field. +func LocationNNotIn(vs ...int) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldLocationN, vs...)) +} + +// LocationNGT applies the GT predicate on the "location_n" field. +func LocationNGT(v int) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldLocationN, v)) +} + +// LocationNGTE applies the GTE predicate on the "location_n" field. +func LocationNGTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldLocationN, v)) +} + +// LocationNLT applies the LT predicate on the "location_n" field. +func LocationNLT(v int) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldLocationN, v)) +} + +// LocationNLTE applies the LTE predicate on the "location_n" field. +func LocationNLTE(v int) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldLocationN, v)) +} + +// LocationNIsNil applies the IsNil predicate on the "location_n" field. +func LocationNIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldLocationN)) +} + +// LocationNNotNil applies the NotNil predicate on the "location_n" field. +func LocationNNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldLocationN)) +} + +// AuthorEQ applies the EQ predicate on the "author" field. +func AuthorEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldAuthor, v)) +} + +// AuthorNEQ applies the NEQ predicate on the "author" field. +func AuthorNEQ(v string) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldAuthor, v)) +} + +// AuthorIn applies the In predicate on the "author" field. +func AuthorIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldAuthor, vs...)) +} + +// AuthorNotIn applies the NotIn predicate on the "author" field. +func AuthorNotIn(vs ...string) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldAuthor, vs...)) +} + +// AuthorGT applies the GT predicate on the "author" field. +func AuthorGT(v string) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldAuthor, v)) +} + +// AuthorGTE applies the GTE predicate on the "author" field. +func AuthorGTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldAuthor, v)) +} + +// AuthorLT applies the LT predicate on the "author" field. +func AuthorLT(v string) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldAuthor, v)) +} + +// AuthorLTE applies the LTE predicate on the "author" field. +func AuthorLTE(v string) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldAuthor, v)) +} + +// AuthorContains applies the Contains predicate on the "author" field. +func AuthorContains(v string) predicate.Ue { + return predicate.Ue(sql.FieldContains(FieldAuthor, v)) +} + +// AuthorHasPrefix applies the HasPrefix predicate on the "author" field. +func AuthorHasPrefix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasPrefix(FieldAuthor, v)) +} + +// AuthorHasSuffix applies the HasSuffix predicate on the "author" field. +func AuthorHasSuffix(v string) predicate.Ue { + return predicate.Ue(sql.FieldHasSuffix(FieldAuthor, v)) +} + +// AuthorIsNil applies the IsNil predicate on the "author" field. +func AuthorIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldAuthor)) +} + +// AuthorNotNil applies the NotNil predicate on the "author" field. +func AuthorNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldAuthor)) +} + +// AuthorEqualFold applies the EqualFold predicate on the "author" field. +func AuthorEqualFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldEqualFold(FieldAuthor, v)) +} + +// AuthorContainsFold applies the ContainsFold predicate on the "author" field. +func AuthorContainsFold(v string) predicate.Ue { + return predicate.Ue(sql.FieldContainsFold(FieldAuthor, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Ue { + return predicate.Ue(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Ue { + return predicate.Ue(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Ue { + return predicate.Ue(sql.FieldLTE(FieldCreatedAt, v)) +} + +// CreatedAtIsNil applies the IsNil predicate on the "created_at" field. +func CreatedAtIsNil() predicate.Ue { + return predicate.Ue(sql.FieldIsNull(FieldCreatedAt)) +} + +// CreatedAtNotNil applies the NotNil predicate on the "created_at" field. +func CreatedAtNotNil() predicate.Ue { + return predicate.Ue(sql.FieldNotNull(FieldCreatedAt)) +} + +// HasOwner applies the HasEdge predicate on the "owner" edge. +func HasOwner() predicate.Ue { + return predicate.Ue(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates). +func HasOwnerWith(preds ...predicate.User) predicate.Ue { + return predicate.Ue(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Ue) predicate.Ue { + return predicate.Ue(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Ue) predicate.Ue { + return predicate.Ue(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Ue) predicate.Ue { + return predicate.Ue(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/ue_create.go b/ent/ue_create.go new file mode 100644 index 0000000..dd0eba5 --- /dev/null +++ b/ent/ue_create.go @@ -0,0 +1,563 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "t/ent/ue" + "t/ent/user" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UeCreate is the builder for creating a Ue entity. +type UeCreate struct { + config + mutation *UeMutation + hooks []Hook +} + +// SetLimit sets the "limit" field. +func (uc *UeCreate) SetLimit(b bool) *UeCreate { + uc.mutation.SetLimit(b) + return uc +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uc *UeCreate) SetNillableLimit(b *bool) *UeCreate { + if b != nil { + uc.SetLimit(*b) + } + return uc +} + +// SetLimitBoss sets the "limit_boss" field. +func (uc *UeCreate) SetLimitBoss(b bool) *UeCreate { + uc.mutation.SetLimitBoss(b) + return uc +} + +// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil. +func (uc *UeCreate) SetNillableLimitBoss(b *bool) *UeCreate { + if b != nil { + uc.SetLimitBoss(*b) + } + return uc +} + +// SetLimitItem sets the "limit_item" field. +func (uc *UeCreate) SetLimitItem(b bool) *UeCreate { + uc.mutation.SetLimitItem(b) + return uc +} + +// SetNillableLimitItem sets the "limit_item" field if the given value is not nil. +func (uc *UeCreate) SetNillableLimitItem(b *bool) *UeCreate { + if b != nil { + uc.SetLimitItem(*b) + } + return uc +} + +// SetPassword sets the "password" field. +func (uc *UeCreate) SetPassword(s string) *UeCreate { + uc.mutation.SetPassword(s) + return uc +} + +// SetLv sets the "lv" field. +func (uc *UeCreate) SetLv(i int) *UeCreate { + uc.mutation.SetLv(i) + return uc +} + +// SetNillableLv sets the "lv" field if the given value is not nil. +func (uc *UeCreate) SetNillableLv(i *int) *UeCreate { + if i != nil { + uc.SetLv(*i) + } + return uc +} + +// SetLvPoint sets the "lv_point" field. +func (uc *UeCreate) SetLvPoint(i int) *UeCreate { + uc.mutation.SetLvPoint(i) + return uc +} + +// SetNillableLvPoint sets the "lv_point" field if the given value is not nil. +func (uc *UeCreate) SetNillableLvPoint(i *int) *UeCreate { + if i != nil { + uc.SetLvPoint(*i) + } + return uc +} + +// SetModel sets the "model" field. +func (uc *UeCreate) SetModel(i int) *UeCreate { + uc.mutation.SetModel(i) + return uc +} + +// SetNillableModel sets the "model" field if the given value is not nil. +func (uc *UeCreate) SetNillableModel(i *int) *UeCreate { + if i != nil { + uc.SetModel(*i) + } + return uc +} + +// SetSword sets the "sword" field. +func (uc *UeCreate) SetSword(i int) *UeCreate { + uc.mutation.SetSword(i) + return uc +} + +// SetNillableSword sets the "sword" field if the given value is not nil. +func (uc *UeCreate) SetNillableSword(i *int) *UeCreate { + if i != nil { + uc.SetSword(*i) + } + return uc +} + +// SetCard sets the "card" field. +func (uc *UeCreate) SetCard(i int) *UeCreate { + uc.mutation.SetCard(i) + return uc +} + +// SetNillableCard sets the "card" field if the given value is not nil. +func (uc *UeCreate) SetNillableCard(i *int) *UeCreate { + if i != nil { + uc.SetCard(*i) + } + return uc +} + +// SetMode sets the "mode" field. +func (uc *UeCreate) SetMode(s string) *UeCreate { + uc.mutation.SetMode(s) + return uc +} + +// SetNillableMode sets the "mode" field if the given value is not nil. +func (uc *UeCreate) SetNillableMode(s *string) *UeCreate { + if s != nil { + uc.SetMode(*s) + } + return uc +} + +// SetToken sets the "token" field. +func (uc *UeCreate) SetToken(s string) *UeCreate { + uc.mutation.SetToken(s) + return uc +} + +// SetNillableToken sets the "token" field if the given value is not nil. +func (uc *UeCreate) SetNillableToken(s *string) *UeCreate { + if s != nil { + uc.SetToken(*s) + } + return uc +} + +// SetCp sets the "cp" field. +func (uc *UeCreate) SetCp(i int) *UeCreate { + uc.mutation.SetCp(i) + return uc +} + +// SetNillableCp sets the "cp" field if the given value is not nil. +func (uc *UeCreate) SetNillableCp(i *int) *UeCreate { + if i != nil { + uc.SetCp(*i) + } + return uc +} + +// SetCount sets the "count" field. +func (uc *UeCreate) SetCount(i int) *UeCreate { + uc.mutation.SetCount(i) + return uc +} + +// SetNillableCount sets the "count" field if the given value is not nil. +func (uc *UeCreate) SetNillableCount(i *int) *UeCreate { + if i != nil { + uc.SetCount(*i) + } + return uc +} + +// SetLocationX sets the "location_x" field. +func (uc *UeCreate) SetLocationX(i int) *UeCreate { + uc.mutation.SetLocationX(i) + return uc +} + +// SetNillableLocationX sets the "location_x" field if the given value is not nil. +func (uc *UeCreate) SetNillableLocationX(i *int) *UeCreate { + if i != nil { + uc.SetLocationX(*i) + } + return uc +} + +// SetLocationY sets the "location_y" field. +func (uc *UeCreate) SetLocationY(i int) *UeCreate { + uc.mutation.SetLocationY(i) + return uc +} + +// SetNillableLocationY sets the "location_y" field if the given value is not nil. +func (uc *UeCreate) SetNillableLocationY(i *int) *UeCreate { + if i != nil { + uc.SetLocationY(*i) + } + return uc +} + +// SetLocationZ sets the "location_z" field. +func (uc *UeCreate) SetLocationZ(i int) *UeCreate { + uc.mutation.SetLocationZ(i) + return uc +} + +// SetNillableLocationZ sets the "location_z" field if the given value is not nil. +func (uc *UeCreate) SetNillableLocationZ(i *int) *UeCreate { + if i != nil { + uc.SetLocationZ(*i) + } + return uc +} + +// SetLocationN sets the "location_n" field. +func (uc *UeCreate) SetLocationN(i int) *UeCreate { + uc.mutation.SetLocationN(i) + return uc +} + +// SetNillableLocationN sets the "location_n" field if the given value is not nil. +func (uc *UeCreate) SetNillableLocationN(i *int) *UeCreate { + if i != nil { + uc.SetLocationN(*i) + } + return uc +} + +// SetAuthor sets the "author" field. +func (uc *UeCreate) SetAuthor(s string) *UeCreate { + uc.mutation.SetAuthor(s) + return uc +} + +// SetNillableAuthor sets the "author" field if the given value is not nil. +func (uc *UeCreate) SetNillableAuthor(s *string) *UeCreate { + if s != nil { + uc.SetAuthor(*s) + } + return uc +} + +// SetCreatedAt sets the "created_at" field. +func (uc *UeCreate) SetCreatedAt(t time.Time) *UeCreate { + uc.mutation.SetCreatedAt(t) + return uc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (uc *UeCreate) SetNillableCreatedAt(t *time.Time) *UeCreate { + if t != nil { + uc.SetCreatedAt(*t) + } + return uc +} + +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (uc *UeCreate) SetOwnerID(id int) *UeCreate { + uc.mutation.SetOwnerID(id) + return uc +} + +// SetOwner sets the "owner" edge to the User entity. +func (uc *UeCreate) SetOwner(u *User) *UeCreate { + return uc.SetOwnerID(u.ID) +} + +// Mutation returns the UeMutation object of the builder. +func (uc *UeCreate) Mutation() *UeMutation { + return uc.mutation +} + +// Save creates the Ue in the database. +func (uc *UeCreate) Save(ctx context.Context) (*Ue, error) { + uc.defaults() + return withHooks[*Ue, UeMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (uc *UeCreate) SaveX(ctx context.Context) *Ue { + v, err := uc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uc *UeCreate) Exec(ctx context.Context) error { + _, err := uc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uc *UeCreate) ExecX(ctx context.Context) { + if err := uc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uc *UeCreate) defaults() { + if _, ok := uc.mutation.Limit(); !ok { + v := ue.DefaultLimit + uc.mutation.SetLimit(v) + } + if _, ok := uc.mutation.LimitBoss(); !ok { + v := ue.DefaultLimitBoss + uc.mutation.SetLimitBoss(v) + } + if _, ok := uc.mutation.LimitItem(); !ok { + v := ue.DefaultLimitItem + uc.mutation.SetLimitItem(v) + } + if _, ok := uc.mutation.CreatedAt(); !ok { + v := ue.DefaultCreatedAt() + uc.mutation.SetCreatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uc *UeCreate) check() error { + if _, ok := uc.mutation.Password(); !ok { + return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Ue.password"`)} + } + if v, ok := uc.mutation.Password(); ok { + if err := ue.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Ue.password": %w`, err)} + } + } + if _, ok := uc.mutation.OwnerID(); !ok { + return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Ue.owner"`)} + } + return nil +} + +func (uc *UeCreate) sqlSave(ctx context.Context) (*Ue, error) { + if err := uc.check(); err != nil { + return nil, err + } + _node, _spec := uc.createSpec() + if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + uc.mutation.id = &_node.ID + uc.mutation.done = true + return _node, nil +} + +func (uc *UeCreate) createSpec() (*Ue, *sqlgraph.CreateSpec) { + var ( + _node = &Ue{config: uc.config} + _spec = sqlgraph.NewCreateSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt)) + ) + if value, ok := uc.mutation.Limit(); ok { + _spec.SetField(ue.FieldLimit, field.TypeBool, value) + _node.Limit = value + } + if value, ok := uc.mutation.LimitBoss(); ok { + _spec.SetField(ue.FieldLimitBoss, field.TypeBool, value) + _node.LimitBoss = value + } + if value, ok := uc.mutation.LimitItem(); ok { + _spec.SetField(ue.FieldLimitItem, field.TypeBool, value) + _node.LimitItem = value + } + if value, ok := uc.mutation.Password(); ok { + _spec.SetField(ue.FieldPassword, field.TypeString, value) + _node.Password = value + } + if value, ok := uc.mutation.Lv(); ok { + _spec.SetField(ue.FieldLv, field.TypeInt, value) + _node.Lv = value + } + if value, ok := uc.mutation.LvPoint(); ok { + _spec.SetField(ue.FieldLvPoint, field.TypeInt, value) + _node.LvPoint = value + } + if value, ok := uc.mutation.Model(); ok { + _spec.SetField(ue.FieldModel, field.TypeInt, value) + _node.Model = value + } + if value, ok := uc.mutation.Sword(); ok { + _spec.SetField(ue.FieldSword, field.TypeInt, value) + _node.Sword = value + } + if value, ok := uc.mutation.Card(); ok { + _spec.SetField(ue.FieldCard, field.TypeInt, value) + _node.Card = value + } + if value, ok := uc.mutation.Mode(); ok { + _spec.SetField(ue.FieldMode, field.TypeString, value) + _node.Mode = value + } + if value, ok := uc.mutation.Token(); ok { + _spec.SetField(ue.FieldToken, field.TypeString, value) + _node.Token = value + } + if value, ok := uc.mutation.Cp(); ok { + _spec.SetField(ue.FieldCp, field.TypeInt, value) + _node.Cp = value + } + if value, ok := uc.mutation.Count(); ok { + _spec.SetField(ue.FieldCount, field.TypeInt, value) + _node.Count = value + } + if value, ok := uc.mutation.LocationX(); ok { + _spec.SetField(ue.FieldLocationX, field.TypeInt, value) + _node.LocationX = value + } + if value, ok := uc.mutation.LocationY(); ok { + _spec.SetField(ue.FieldLocationY, field.TypeInt, value) + _node.LocationY = value + } + if value, ok := uc.mutation.LocationZ(); ok { + _spec.SetField(ue.FieldLocationZ, field.TypeInt, value) + _node.LocationZ = value + } + if value, ok := uc.mutation.LocationN(); ok { + _spec.SetField(ue.FieldLocationN, field.TypeInt, value) + _node.LocationN = value + } + if value, ok := uc.mutation.Author(); ok { + _spec.SetField(ue.FieldAuthor, field.TypeString, value) + _node.Author = value + } + if value, ok := uc.mutation.CreatedAt(); ok { + _spec.SetField(ue.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if nodes := uc.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: ue.OwnerTable, + Columns: []string{ue.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_ue = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// UeCreateBulk is the builder for creating many Ue entities in bulk. +type UeCreateBulk struct { + config + builders []*UeCreate +} + +// Save creates the Ue entities in the database. +func (ucb *UeCreateBulk) Save(ctx context.Context) ([]*Ue, error) { + specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) + nodes := make([]*Ue, len(ucb.builders)) + mutators := make([]Mutator, len(ucb.builders)) + for i := range ucb.builders { + func(i int, root context.Context) { + builder := ucb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UeMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ucb *UeCreateBulk) SaveX(ctx context.Context) []*Ue { + v, err := ucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ucb *UeCreateBulk) Exec(ctx context.Context) error { + _, err := ucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ucb *UeCreateBulk) ExecX(ctx context.Context) { + if err := ucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/ue_delete.go b/ent/ue_delete.go new file mode 100644 index 0000000..98f3dc5 --- /dev/null +++ b/ent/ue_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "t/ent/predicate" + "t/ent/ue" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UeDelete is the builder for deleting a Ue entity. +type UeDelete struct { + config + hooks []Hook + mutation *UeMutation +} + +// Where appends a list predicates to the UeDelete builder. +func (ud *UeDelete) Where(ps ...predicate.Ue) *UeDelete { + ud.mutation.Where(ps...) + return ud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ud *UeDelete) Exec(ctx context.Context) (int, error) { + return withHooks[int, UeMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ud *UeDelete) ExecX(ctx context.Context) int { + n, err := ud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ud *UeDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt)) + if ps := ud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ud.mutation.done = true + return affected, err +} + +// UeDeleteOne is the builder for deleting a single Ue entity. +type UeDeleteOne struct { + ud *UeDelete +} + +// Where appends a list predicates to the UeDelete builder. +func (udo *UeDeleteOne) Where(ps ...predicate.Ue) *UeDeleteOne { + udo.ud.mutation.Where(ps...) + return udo +} + +// Exec executes the deletion query. +func (udo *UeDeleteOne) Exec(ctx context.Context) error { + n, err := udo.ud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{ue.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (udo *UeDeleteOne) ExecX(ctx context.Context) { + if err := udo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/ue_query.go b/ent/ue_query.go new file mode 100644 index 0000000..240b74e --- /dev/null +++ b/ent/ue_query.go @@ -0,0 +1,613 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "t/ent/predicate" + "t/ent/ue" + "t/ent/user" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UeQuery is the builder for querying Ue entities. +type UeQuery struct { + config + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Ue + withOwner *UserQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UeQuery builder. +func (uq *UeQuery) Where(ps ...predicate.Ue) *UeQuery { + uq.predicates = append(uq.predicates, ps...) + return uq +} + +// Limit the number of records to be returned by this query. +func (uq *UeQuery) Limit(limit int) *UeQuery { + uq.ctx.Limit = &limit + return uq +} + +// Offset to start from. +func (uq *UeQuery) Offset(offset int) *UeQuery { + uq.ctx.Offset = &offset + return uq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (uq *UeQuery) Unique(unique bool) *UeQuery { + uq.ctx.Unique = &unique + return uq +} + +// Order specifies how the records should be ordered. +func (uq *UeQuery) Order(o ...OrderFunc) *UeQuery { + uq.order = append(uq.order, o...) + return uq +} + +// QueryOwner chains the current query on the "owner" edge. +func (uq *UeQuery) QueryOwner() *UserQuery { + query := (&UserClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(ue.Table, ue.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Ue entity from the query. +// Returns a *NotFoundError when no Ue was found. +func (uq *UeQuery) First(ctx context.Context) (*Ue, error) { + nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{ue.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (uq *UeQuery) FirstX(ctx context.Context) *Ue { + node, err := uq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Ue ID from the query. +// Returns a *NotFoundError when no Ue ID was found. +func (uq *UeQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{ue.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (uq *UeQuery) FirstIDX(ctx context.Context) int { + id, err := uq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Ue entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Ue entity is found. +// Returns a *NotFoundError when no Ue entities are found. +func (uq *UeQuery) Only(ctx context.Context) (*Ue, error) { + nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{ue.Label} + default: + return nil, &NotSingularError{ue.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (uq *UeQuery) OnlyX(ctx context.Context) *Ue { + node, err := uq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Ue ID in the query. +// Returns a *NotSingularError when more than one Ue ID is found. +// Returns a *NotFoundError when no entities are found. +func (uq *UeQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{ue.Label} + default: + err = &NotSingularError{ue.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (uq *UeQuery) OnlyIDX(ctx context.Context) int { + id, err := uq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Ues. +func (uq *UeQuery) All(ctx context.Context) ([]*Ue, error) { + ctx = setContextOp(ctx, uq.ctx, "All") + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Ue, *UeQuery]() + return withInterceptors[[]*Ue](ctx, uq, qr, uq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (uq *UeQuery) AllX(ctx context.Context) []*Ue { + nodes, err := uq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Ue IDs. +func (uq *UeQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } + ctx = setContextOp(ctx, uq.ctx, "IDs") + if err = uq.Select(ue.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (uq *UeQuery) IDsX(ctx context.Context) []int { + ids, err := uq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (uq *UeQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, uq.ctx, "Count") + if err := uq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, uq, querierCount[*UeQuery](), uq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (uq *UeQuery) CountX(ctx context.Context) int { + count, err := uq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (uq *UeQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, uq.ctx, "Exist") + switch _, err := uq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (uq *UeQuery) ExistX(ctx context.Context) bool { + exist, err := uq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UeQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (uq *UeQuery) Clone() *UeQuery { + if uq == nil { + return nil + } + return &UeQuery{ + config: uq.config, + ctx: uq.ctx.Clone(), + order: append([]OrderFunc{}, uq.order...), + inters: append([]Interceptor{}, uq.inters...), + predicates: append([]predicate.Ue{}, uq.predicates...), + withOwner: uq.withOwner.Clone(), + // clone intermediate query. + sql: uq.sql.Clone(), + path: uq.path, + } +} + +// WithOwner tells the query-builder to eager-load the nodes that are connected to +// the "owner" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UeQuery) WithOwner(opts ...func(*UserQuery)) *UeQuery { + query := (&UserClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withOwner = query + return uq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Limit bool `json:"limit,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Ue.Query(). +// GroupBy(ue.FieldLimit). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (uq *UeQuery) GroupBy(field string, fields ...string) *UeGroupBy { + uq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UeGroupBy{build: uq} + grbuild.flds = &uq.ctx.Fields + grbuild.label = ue.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Limit bool `json:"limit,omitempty"` +// } +// +// client.Ue.Query(). +// Select(ue.FieldLimit). +// Scan(ctx, &v) +func (uq *UeQuery) Select(fields ...string) *UeSelect { + uq.ctx.Fields = append(uq.ctx.Fields, fields...) + sbuild := &UeSelect{UeQuery: uq} + sbuild.label = ue.Label + sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UeSelect configured with the given aggregations. +func (uq *UeQuery) Aggregate(fns ...AggregateFunc) *UeSelect { + return uq.Select().Aggregate(fns...) +} + +func (uq *UeQuery) prepareQuery(ctx context.Context) error { + for _, inter := range uq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, uq); err != nil { + return err + } + } + } + for _, f := range uq.ctx.Fields { + if !ue.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if uq.path != nil { + prev, err := uq.path(ctx) + if err != nil { + return err + } + uq.sql = prev + } + return nil +} + +func (uq *UeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ue, error) { + var ( + nodes = []*Ue{} + withFKs = uq.withFKs + _spec = uq.querySpec() + loadedTypes = [1]bool{ + uq.withOwner != nil, + } + ) + if uq.withOwner != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, ue.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Ue).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Ue{config: uq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := uq.withOwner; query != nil { + if err := uq.loadOwner(ctx, query, nodes, nil, + func(n *Ue, e *User) { n.Edges.Owner = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (uq *UeQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Ue, init func(*Ue), assign func(*Ue, *User)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Ue) + for i := range nodes { + if nodes[i].user_ue == nil { + continue + } + fk := *nodes[i].user_ue + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (uq *UeQuery) sqlCount(ctx context.Context) (int, error) { + _spec := uq.querySpec() + _spec.Node.Columns = uq.ctx.Fields + if len(uq.ctx.Fields) > 0 { + _spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, uq.driver, _spec) +} + +func (uq *UeQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(ue.Table, ue.Columns, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt)) + _spec.From = uq.sql + if unique := uq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true + } + if fields := uq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, ue.FieldID) + for i := range fields { + if fields[i] != ue.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := uq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := uq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := uq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := uq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (uq *UeQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(uq.driver.Dialect()) + t1 := builder.Table(ue.Table) + columns := uq.ctx.Fields + if len(columns) == 0 { + columns = ue.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if uq.sql != nil { + selector = uq.sql + selector.Select(selector.Columns(columns...)...) + } + if uq.ctx.Unique != nil && *uq.ctx.Unique { + selector.Distinct() + } + for _, p := range uq.predicates { + p(selector) + } + for _, p := range uq.order { + p(selector) + } + if offset := uq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := uq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UeGroupBy is the group-by builder for Ue entities. +type UeGroupBy struct { + selector + build *UeQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ugb *UeGroupBy) Aggregate(fns ...AggregateFunc) *UeGroupBy { + ugb.fns = append(ugb.fns, fns...) + return ugb +} + +// Scan applies the selector query and scans the result into the given value. +func (ugb *UeGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy") + if err := ugb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UeQuery, *UeGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v) +} + +func (ugb *UeGroupBy) sqlScan(ctx context.Context, root *UeQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ugb.fns)) + for _, fn := range ugb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns)) + for _, f := range *ugb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ugb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UeSelect is the builder for selecting fields of Ue entities. +type UeSelect struct { + *UeQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (us *UeSelect) Aggregate(fns ...AggregateFunc) *UeSelect { + us.fns = append(us.fns, fns...) + return us +} + +// Scan applies the selector query and scans the result into the given value. +func (us *UeSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, us.ctx, "Select") + if err := us.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UeQuery, *UeSelect](ctx, us.UeQuery, us, us.inters, v) +} + +func (us *UeSelect) sqlScan(ctx context.Context, root *UeQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(us.fns)) + for _, fn := range us.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*us.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := us.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/ue_update.go b/ent/ue_update.go new file mode 100644 index 0000000..649304c --- /dev/null +++ b/ent/ue_update.go @@ -0,0 +1,1400 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "t/ent/predicate" + "t/ent/ue" + "t/ent/user" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UeUpdate is the builder for updating Ue entities. +type UeUpdate struct { + config + hooks []Hook + mutation *UeMutation +} + +// Where appends a list predicates to the UeUpdate builder. +func (uu *UeUpdate) Where(ps ...predicate.Ue) *UeUpdate { + uu.mutation.Where(ps...) + return uu +} + +// SetLimit sets the "limit" field. +func (uu *UeUpdate) SetLimit(b bool) *UeUpdate { + uu.mutation.SetLimit(b) + return uu +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLimit(b *bool) *UeUpdate { + if b != nil { + uu.SetLimit(*b) + } + return uu +} + +// ClearLimit clears the value of the "limit" field. +func (uu *UeUpdate) ClearLimit() *UeUpdate { + uu.mutation.ClearLimit() + return uu +} + +// SetLimitBoss sets the "limit_boss" field. +func (uu *UeUpdate) SetLimitBoss(b bool) *UeUpdate { + uu.mutation.SetLimitBoss(b) + return uu +} + +// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLimitBoss(b *bool) *UeUpdate { + if b != nil { + uu.SetLimitBoss(*b) + } + return uu +} + +// ClearLimitBoss clears the value of the "limit_boss" field. +func (uu *UeUpdate) ClearLimitBoss() *UeUpdate { + uu.mutation.ClearLimitBoss() + return uu +} + +// SetLimitItem sets the "limit_item" field. +func (uu *UeUpdate) SetLimitItem(b bool) *UeUpdate { + uu.mutation.SetLimitItem(b) + return uu +} + +// SetNillableLimitItem sets the "limit_item" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLimitItem(b *bool) *UeUpdate { + if b != nil { + uu.SetLimitItem(*b) + } + return uu +} + +// ClearLimitItem clears the value of the "limit_item" field. +func (uu *UeUpdate) ClearLimitItem() *UeUpdate { + uu.mutation.ClearLimitItem() + return uu +} + +// SetLv sets the "lv" field. +func (uu *UeUpdate) SetLv(i int) *UeUpdate { + uu.mutation.ResetLv() + uu.mutation.SetLv(i) + return uu +} + +// SetNillableLv sets the "lv" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLv(i *int) *UeUpdate { + if i != nil { + uu.SetLv(*i) + } + return uu +} + +// AddLv adds i to the "lv" field. +func (uu *UeUpdate) AddLv(i int) *UeUpdate { + uu.mutation.AddLv(i) + return uu +} + +// ClearLv clears the value of the "lv" field. +func (uu *UeUpdate) ClearLv() *UeUpdate { + uu.mutation.ClearLv() + return uu +} + +// SetLvPoint sets the "lv_point" field. +func (uu *UeUpdate) SetLvPoint(i int) *UeUpdate { + uu.mutation.ResetLvPoint() + uu.mutation.SetLvPoint(i) + return uu +} + +// SetNillableLvPoint sets the "lv_point" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLvPoint(i *int) *UeUpdate { + if i != nil { + uu.SetLvPoint(*i) + } + return uu +} + +// AddLvPoint adds i to the "lv_point" field. +func (uu *UeUpdate) AddLvPoint(i int) *UeUpdate { + uu.mutation.AddLvPoint(i) + return uu +} + +// ClearLvPoint clears the value of the "lv_point" field. +func (uu *UeUpdate) ClearLvPoint() *UeUpdate { + uu.mutation.ClearLvPoint() + return uu +} + +// SetModel sets the "model" field. +func (uu *UeUpdate) SetModel(i int) *UeUpdate { + uu.mutation.ResetModel() + uu.mutation.SetModel(i) + return uu +} + +// SetNillableModel sets the "model" field if the given value is not nil. +func (uu *UeUpdate) SetNillableModel(i *int) *UeUpdate { + if i != nil { + uu.SetModel(*i) + } + return uu +} + +// AddModel adds i to the "model" field. +func (uu *UeUpdate) AddModel(i int) *UeUpdate { + uu.mutation.AddModel(i) + return uu +} + +// ClearModel clears the value of the "model" field. +func (uu *UeUpdate) ClearModel() *UeUpdate { + uu.mutation.ClearModel() + return uu +} + +// SetSword sets the "sword" field. +func (uu *UeUpdate) SetSword(i int) *UeUpdate { + uu.mutation.ResetSword() + uu.mutation.SetSword(i) + return uu +} + +// SetNillableSword sets the "sword" field if the given value is not nil. +func (uu *UeUpdate) SetNillableSword(i *int) *UeUpdate { + if i != nil { + uu.SetSword(*i) + } + return uu +} + +// AddSword adds i to the "sword" field. +func (uu *UeUpdate) AddSword(i int) *UeUpdate { + uu.mutation.AddSword(i) + return uu +} + +// ClearSword clears the value of the "sword" field. +func (uu *UeUpdate) ClearSword() *UeUpdate { + uu.mutation.ClearSword() + return uu +} + +// SetCard sets the "card" field. +func (uu *UeUpdate) SetCard(i int) *UeUpdate { + uu.mutation.ResetCard() + uu.mutation.SetCard(i) + return uu +} + +// SetNillableCard sets the "card" field if the given value is not nil. +func (uu *UeUpdate) SetNillableCard(i *int) *UeUpdate { + if i != nil { + uu.SetCard(*i) + } + return uu +} + +// AddCard adds i to the "card" field. +func (uu *UeUpdate) AddCard(i int) *UeUpdate { + uu.mutation.AddCard(i) + return uu +} + +// ClearCard clears the value of the "card" field. +func (uu *UeUpdate) ClearCard() *UeUpdate { + uu.mutation.ClearCard() + return uu +} + +// SetMode sets the "mode" field. +func (uu *UeUpdate) SetMode(s string) *UeUpdate { + uu.mutation.SetMode(s) + return uu +} + +// SetNillableMode sets the "mode" field if the given value is not nil. +func (uu *UeUpdate) SetNillableMode(s *string) *UeUpdate { + if s != nil { + uu.SetMode(*s) + } + return uu +} + +// ClearMode clears the value of the "mode" field. +func (uu *UeUpdate) ClearMode() *UeUpdate { + uu.mutation.ClearMode() + return uu +} + +// SetToken sets the "token" field. +func (uu *UeUpdate) SetToken(s string) *UeUpdate { + uu.mutation.SetToken(s) + return uu +} + +// SetNillableToken sets the "token" field if the given value is not nil. +func (uu *UeUpdate) SetNillableToken(s *string) *UeUpdate { + if s != nil { + uu.SetToken(*s) + } + return uu +} + +// ClearToken clears the value of the "token" field. +func (uu *UeUpdate) ClearToken() *UeUpdate { + uu.mutation.ClearToken() + return uu +} + +// SetCp sets the "cp" field. +func (uu *UeUpdate) SetCp(i int) *UeUpdate { + uu.mutation.ResetCp() + uu.mutation.SetCp(i) + return uu +} + +// SetNillableCp sets the "cp" field if the given value is not nil. +func (uu *UeUpdate) SetNillableCp(i *int) *UeUpdate { + if i != nil { + uu.SetCp(*i) + } + return uu +} + +// AddCp adds i to the "cp" field. +func (uu *UeUpdate) AddCp(i int) *UeUpdate { + uu.mutation.AddCp(i) + return uu +} + +// ClearCp clears the value of the "cp" field. +func (uu *UeUpdate) ClearCp() *UeUpdate { + uu.mutation.ClearCp() + return uu +} + +// SetCount sets the "count" field. +func (uu *UeUpdate) SetCount(i int) *UeUpdate { + uu.mutation.ResetCount() + uu.mutation.SetCount(i) + return uu +} + +// SetNillableCount sets the "count" field if the given value is not nil. +func (uu *UeUpdate) SetNillableCount(i *int) *UeUpdate { + if i != nil { + uu.SetCount(*i) + } + return uu +} + +// AddCount adds i to the "count" field. +func (uu *UeUpdate) AddCount(i int) *UeUpdate { + uu.mutation.AddCount(i) + return uu +} + +// ClearCount clears the value of the "count" field. +func (uu *UeUpdate) ClearCount() *UeUpdate { + uu.mutation.ClearCount() + return uu +} + +// SetLocationX sets the "location_x" field. +func (uu *UeUpdate) SetLocationX(i int) *UeUpdate { + uu.mutation.ResetLocationX() + uu.mutation.SetLocationX(i) + return uu +} + +// SetNillableLocationX sets the "location_x" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLocationX(i *int) *UeUpdate { + if i != nil { + uu.SetLocationX(*i) + } + return uu +} + +// AddLocationX adds i to the "location_x" field. +func (uu *UeUpdate) AddLocationX(i int) *UeUpdate { + uu.mutation.AddLocationX(i) + return uu +} + +// ClearLocationX clears the value of the "location_x" field. +func (uu *UeUpdate) ClearLocationX() *UeUpdate { + uu.mutation.ClearLocationX() + return uu +} + +// SetLocationY sets the "location_y" field. +func (uu *UeUpdate) SetLocationY(i int) *UeUpdate { + uu.mutation.ResetLocationY() + uu.mutation.SetLocationY(i) + return uu +} + +// SetNillableLocationY sets the "location_y" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLocationY(i *int) *UeUpdate { + if i != nil { + uu.SetLocationY(*i) + } + return uu +} + +// AddLocationY adds i to the "location_y" field. +func (uu *UeUpdate) AddLocationY(i int) *UeUpdate { + uu.mutation.AddLocationY(i) + return uu +} + +// ClearLocationY clears the value of the "location_y" field. +func (uu *UeUpdate) ClearLocationY() *UeUpdate { + uu.mutation.ClearLocationY() + return uu +} + +// SetLocationZ sets the "location_z" field. +func (uu *UeUpdate) SetLocationZ(i int) *UeUpdate { + uu.mutation.ResetLocationZ() + uu.mutation.SetLocationZ(i) + return uu +} + +// SetNillableLocationZ sets the "location_z" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLocationZ(i *int) *UeUpdate { + if i != nil { + uu.SetLocationZ(*i) + } + return uu +} + +// AddLocationZ adds i to the "location_z" field. +func (uu *UeUpdate) AddLocationZ(i int) *UeUpdate { + uu.mutation.AddLocationZ(i) + return uu +} + +// ClearLocationZ clears the value of the "location_z" field. +func (uu *UeUpdate) ClearLocationZ() *UeUpdate { + uu.mutation.ClearLocationZ() + return uu +} + +// SetLocationN sets the "location_n" field. +func (uu *UeUpdate) SetLocationN(i int) *UeUpdate { + uu.mutation.ResetLocationN() + uu.mutation.SetLocationN(i) + return uu +} + +// SetNillableLocationN sets the "location_n" field if the given value is not nil. +func (uu *UeUpdate) SetNillableLocationN(i *int) *UeUpdate { + if i != nil { + uu.SetLocationN(*i) + } + return uu +} + +// AddLocationN adds i to the "location_n" field. +func (uu *UeUpdate) AddLocationN(i int) *UeUpdate { + uu.mutation.AddLocationN(i) + return uu +} + +// ClearLocationN clears the value of the "location_n" field. +func (uu *UeUpdate) ClearLocationN() *UeUpdate { + uu.mutation.ClearLocationN() + return uu +} + +// SetAuthor sets the "author" field. +func (uu *UeUpdate) SetAuthor(s string) *UeUpdate { + uu.mutation.SetAuthor(s) + return uu +} + +// SetNillableAuthor sets the "author" field if the given value is not nil. +func (uu *UeUpdate) SetNillableAuthor(s *string) *UeUpdate { + if s != nil { + uu.SetAuthor(*s) + } + return uu +} + +// ClearAuthor clears the value of the "author" field. +func (uu *UeUpdate) ClearAuthor() *UeUpdate { + uu.mutation.ClearAuthor() + return uu +} + +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (uu *UeUpdate) SetOwnerID(id int) *UeUpdate { + uu.mutation.SetOwnerID(id) + return uu +} + +// SetOwner sets the "owner" edge to the User entity. +func (uu *UeUpdate) SetOwner(u *User) *UeUpdate { + return uu.SetOwnerID(u.ID) +} + +// Mutation returns the UeMutation object of the builder. +func (uu *UeUpdate) Mutation() *UeMutation { + return uu.mutation +} + +// ClearOwner clears the "owner" edge to the User entity. +func (uu *UeUpdate) ClearOwner() *UeUpdate { + uu.mutation.ClearOwner() + return uu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (uu *UeUpdate) Save(ctx context.Context) (int, error) { + return withHooks[int, UeMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uu *UeUpdate) SaveX(ctx context.Context) int { + affected, err := uu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (uu *UeUpdate) Exec(ctx context.Context) error { + _, err := uu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uu *UeUpdate) ExecX(ctx context.Context) { + if err := uu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uu *UeUpdate) check() error { + if _, ok := uu.mutation.OwnerID(); uu.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Ue.owner"`) + } + return nil +} + +func (uu *UeUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := uu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(ue.Table, ue.Columns, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt)) + if ps := uu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uu.mutation.Limit(); ok { + _spec.SetField(ue.FieldLimit, field.TypeBool, value) + } + if uu.mutation.LimitCleared() { + _spec.ClearField(ue.FieldLimit, field.TypeBool) + } + if value, ok := uu.mutation.LimitBoss(); ok { + _spec.SetField(ue.FieldLimitBoss, field.TypeBool, value) + } + if uu.mutation.LimitBossCleared() { + _spec.ClearField(ue.FieldLimitBoss, field.TypeBool) + } + if value, ok := uu.mutation.LimitItem(); ok { + _spec.SetField(ue.FieldLimitItem, field.TypeBool, value) + } + if uu.mutation.LimitItemCleared() { + _spec.ClearField(ue.FieldLimitItem, field.TypeBool) + } + if value, ok := uu.mutation.Lv(); ok { + _spec.SetField(ue.FieldLv, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLv(); ok { + _spec.AddField(ue.FieldLv, field.TypeInt, value) + } + if uu.mutation.LvCleared() { + _spec.ClearField(ue.FieldLv, field.TypeInt) + } + if value, ok := uu.mutation.LvPoint(); ok { + _spec.SetField(ue.FieldLvPoint, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLvPoint(); ok { + _spec.AddField(ue.FieldLvPoint, field.TypeInt, value) + } + if uu.mutation.LvPointCleared() { + _spec.ClearField(ue.FieldLvPoint, field.TypeInt) + } + if value, ok := uu.mutation.Model(); ok { + _spec.SetField(ue.FieldModel, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedModel(); ok { + _spec.AddField(ue.FieldModel, field.TypeInt, value) + } + if uu.mutation.ModelCleared() { + _spec.ClearField(ue.FieldModel, field.TypeInt) + } + if value, ok := uu.mutation.Sword(); ok { + _spec.SetField(ue.FieldSword, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedSword(); ok { + _spec.AddField(ue.FieldSword, field.TypeInt, value) + } + if uu.mutation.SwordCleared() { + _spec.ClearField(ue.FieldSword, field.TypeInt) + } + if value, ok := uu.mutation.Card(); ok { + _spec.SetField(ue.FieldCard, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedCard(); ok { + _spec.AddField(ue.FieldCard, field.TypeInt, value) + } + if uu.mutation.CardCleared() { + _spec.ClearField(ue.FieldCard, field.TypeInt) + } + if value, ok := uu.mutation.Mode(); ok { + _spec.SetField(ue.FieldMode, field.TypeString, value) + } + if uu.mutation.ModeCleared() { + _spec.ClearField(ue.FieldMode, field.TypeString) + } + if value, ok := uu.mutation.Token(); ok { + _spec.SetField(ue.FieldToken, field.TypeString, value) + } + if uu.mutation.TokenCleared() { + _spec.ClearField(ue.FieldToken, field.TypeString) + } + if value, ok := uu.mutation.Cp(); ok { + _spec.SetField(ue.FieldCp, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedCp(); ok { + _spec.AddField(ue.FieldCp, field.TypeInt, value) + } + if uu.mutation.CpCleared() { + _spec.ClearField(ue.FieldCp, field.TypeInt) + } + if value, ok := uu.mutation.Count(); ok { + _spec.SetField(ue.FieldCount, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedCount(); ok { + _spec.AddField(ue.FieldCount, field.TypeInt, value) + } + if uu.mutation.CountCleared() { + _spec.ClearField(ue.FieldCount, field.TypeInt) + } + if value, ok := uu.mutation.LocationX(); ok { + _spec.SetField(ue.FieldLocationX, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLocationX(); ok { + _spec.AddField(ue.FieldLocationX, field.TypeInt, value) + } + if uu.mutation.LocationXCleared() { + _spec.ClearField(ue.FieldLocationX, field.TypeInt) + } + if value, ok := uu.mutation.LocationY(); ok { + _spec.SetField(ue.FieldLocationY, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLocationY(); ok { + _spec.AddField(ue.FieldLocationY, field.TypeInt, value) + } + if uu.mutation.LocationYCleared() { + _spec.ClearField(ue.FieldLocationY, field.TypeInt) + } + if value, ok := uu.mutation.LocationZ(); ok { + _spec.SetField(ue.FieldLocationZ, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLocationZ(); ok { + _spec.AddField(ue.FieldLocationZ, field.TypeInt, value) + } + if uu.mutation.LocationZCleared() { + _spec.ClearField(ue.FieldLocationZ, field.TypeInt) + } + if value, ok := uu.mutation.LocationN(); ok { + _spec.SetField(ue.FieldLocationN, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedLocationN(); ok { + _spec.AddField(ue.FieldLocationN, field.TypeInt, value) + } + if uu.mutation.LocationNCleared() { + _spec.ClearField(ue.FieldLocationN, field.TypeInt) + } + if value, ok := uu.mutation.Author(); ok { + _spec.SetField(ue.FieldAuthor, field.TypeString, value) + } + if uu.mutation.AuthorCleared() { + _spec.ClearField(ue.FieldAuthor, field.TypeString) + } + if uu.mutation.CreatedAtCleared() { + _spec.ClearField(ue.FieldCreatedAt, field.TypeTime) + } + if uu.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: ue.OwnerTable, + Columns: []string{ue.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: ue.OwnerTable, + Columns: []string{ue.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{ue.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + uu.mutation.done = true + return n, nil +} + +// UeUpdateOne is the builder for updating a single Ue entity. +type UeUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UeMutation +} + +// SetLimit sets the "limit" field. +func (uuo *UeUpdateOne) SetLimit(b bool) *UeUpdateOne { + uuo.mutation.SetLimit(b) + return uuo +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLimit(b *bool) *UeUpdateOne { + if b != nil { + uuo.SetLimit(*b) + } + return uuo +} + +// ClearLimit clears the value of the "limit" field. +func (uuo *UeUpdateOne) ClearLimit() *UeUpdateOne { + uuo.mutation.ClearLimit() + return uuo +} + +// SetLimitBoss sets the "limit_boss" field. +func (uuo *UeUpdateOne) SetLimitBoss(b bool) *UeUpdateOne { + uuo.mutation.SetLimitBoss(b) + return uuo +} + +// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLimitBoss(b *bool) *UeUpdateOne { + if b != nil { + uuo.SetLimitBoss(*b) + } + return uuo +} + +// ClearLimitBoss clears the value of the "limit_boss" field. +func (uuo *UeUpdateOne) ClearLimitBoss() *UeUpdateOne { + uuo.mutation.ClearLimitBoss() + return uuo +} + +// SetLimitItem sets the "limit_item" field. +func (uuo *UeUpdateOne) SetLimitItem(b bool) *UeUpdateOne { + uuo.mutation.SetLimitItem(b) + return uuo +} + +// SetNillableLimitItem sets the "limit_item" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLimitItem(b *bool) *UeUpdateOne { + if b != nil { + uuo.SetLimitItem(*b) + } + return uuo +} + +// ClearLimitItem clears the value of the "limit_item" field. +func (uuo *UeUpdateOne) ClearLimitItem() *UeUpdateOne { + uuo.mutation.ClearLimitItem() + return uuo +} + +// SetLv sets the "lv" field. +func (uuo *UeUpdateOne) SetLv(i int) *UeUpdateOne { + uuo.mutation.ResetLv() + uuo.mutation.SetLv(i) + return uuo +} + +// SetNillableLv sets the "lv" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLv(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLv(*i) + } + return uuo +} + +// AddLv adds i to the "lv" field. +func (uuo *UeUpdateOne) AddLv(i int) *UeUpdateOne { + uuo.mutation.AddLv(i) + return uuo +} + +// ClearLv clears the value of the "lv" field. +func (uuo *UeUpdateOne) ClearLv() *UeUpdateOne { + uuo.mutation.ClearLv() + return uuo +} + +// SetLvPoint sets the "lv_point" field. +func (uuo *UeUpdateOne) SetLvPoint(i int) *UeUpdateOne { + uuo.mutation.ResetLvPoint() + uuo.mutation.SetLvPoint(i) + return uuo +} + +// SetNillableLvPoint sets the "lv_point" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLvPoint(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLvPoint(*i) + } + return uuo +} + +// AddLvPoint adds i to the "lv_point" field. +func (uuo *UeUpdateOne) AddLvPoint(i int) *UeUpdateOne { + uuo.mutation.AddLvPoint(i) + return uuo +} + +// ClearLvPoint clears the value of the "lv_point" field. +func (uuo *UeUpdateOne) ClearLvPoint() *UeUpdateOne { + uuo.mutation.ClearLvPoint() + return uuo +} + +// SetModel sets the "model" field. +func (uuo *UeUpdateOne) SetModel(i int) *UeUpdateOne { + uuo.mutation.ResetModel() + uuo.mutation.SetModel(i) + return uuo +} + +// SetNillableModel sets the "model" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableModel(i *int) *UeUpdateOne { + if i != nil { + uuo.SetModel(*i) + } + return uuo +} + +// AddModel adds i to the "model" field. +func (uuo *UeUpdateOne) AddModel(i int) *UeUpdateOne { + uuo.mutation.AddModel(i) + return uuo +} + +// ClearModel clears the value of the "model" field. +func (uuo *UeUpdateOne) ClearModel() *UeUpdateOne { + uuo.mutation.ClearModel() + return uuo +} + +// SetSword sets the "sword" field. +func (uuo *UeUpdateOne) SetSword(i int) *UeUpdateOne { + uuo.mutation.ResetSword() + uuo.mutation.SetSword(i) + return uuo +} + +// SetNillableSword sets the "sword" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableSword(i *int) *UeUpdateOne { + if i != nil { + uuo.SetSword(*i) + } + return uuo +} + +// AddSword adds i to the "sword" field. +func (uuo *UeUpdateOne) AddSword(i int) *UeUpdateOne { + uuo.mutation.AddSword(i) + return uuo +} + +// ClearSword clears the value of the "sword" field. +func (uuo *UeUpdateOne) ClearSword() *UeUpdateOne { + uuo.mutation.ClearSword() + return uuo +} + +// SetCard sets the "card" field. +func (uuo *UeUpdateOne) SetCard(i int) *UeUpdateOne { + uuo.mutation.ResetCard() + uuo.mutation.SetCard(i) + return uuo +} + +// SetNillableCard sets the "card" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableCard(i *int) *UeUpdateOne { + if i != nil { + uuo.SetCard(*i) + } + return uuo +} + +// AddCard adds i to the "card" field. +func (uuo *UeUpdateOne) AddCard(i int) *UeUpdateOne { + uuo.mutation.AddCard(i) + return uuo +} + +// ClearCard clears the value of the "card" field. +func (uuo *UeUpdateOne) ClearCard() *UeUpdateOne { + uuo.mutation.ClearCard() + return uuo +} + +// SetMode sets the "mode" field. +func (uuo *UeUpdateOne) SetMode(s string) *UeUpdateOne { + uuo.mutation.SetMode(s) + return uuo +} + +// SetNillableMode sets the "mode" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableMode(s *string) *UeUpdateOne { + if s != nil { + uuo.SetMode(*s) + } + return uuo +} + +// ClearMode clears the value of the "mode" field. +func (uuo *UeUpdateOne) ClearMode() *UeUpdateOne { + uuo.mutation.ClearMode() + return uuo +} + +// SetToken sets the "token" field. +func (uuo *UeUpdateOne) SetToken(s string) *UeUpdateOne { + uuo.mutation.SetToken(s) + return uuo +} + +// SetNillableToken sets the "token" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableToken(s *string) *UeUpdateOne { + if s != nil { + uuo.SetToken(*s) + } + return uuo +} + +// ClearToken clears the value of the "token" field. +func (uuo *UeUpdateOne) ClearToken() *UeUpdateOne { + uuo.mutation.ClearToken() + return uuo +} + +// SetCp sets the "cp" field. +func (uuo *UeUpdateOne) SetCp(i int) *UeUpdateOne { + uuo.mutation.ResetCp() + uuo.mutation.SetCp(i) + return uuo +} + +// SetNillableCp sets the "cp" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableCp(i *int) *UeUpdateOne { + if i != nil { + uuo.SetCp(*i) + } + return uuo +} + +// AddCp adds i to the "cp" field. +func (uuo *UeUpdateOne) AddCp(i int) *UeUpdateOne { + uuo.mutation.AddCp(i) + return uuo +} + +// ClearCp clears the value of the "cp" field. +func (uuo *UeUpdateOne) ClearCp() *UeUpdateOne { + uuo.mutation.ClearCp() + return uuo +} + +// SetCount sets the "count" field. +func (uuo *UeUpdateOne) SetCount(i int) *UeUpdateOne { + uuo.mutation.ResetCount() + uuo.mutation.SetCount(i) + return uuo +} + +// SetNillableCount sets the "count" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableCount(i *int) *UeUpdateOne { + if i != nil { + uuo.SetCount(*i) + } + return uuo +} + +// AddCount adds i to the "count" field. +func (uuo *UeUpdateOne) AddCount(i int) *UeUpdateOne { + uuo.mutation.AddCount(i) + return uuo +} + +// ClearCount clears the value of the "count" field. +func (uuo *UeUpdateOne) ClearCount() *UeUpdateOne { + uuo.mutation.ClearCount() + return uuo +} + +// SetLocationX sets the "location_x" field. +func (uuo *UeUpdateOne) SetLocationX(i int) *UeUpdateOne { + uuo.mutation.ResetLocationX() + uuo.mutation.SetLocationX(i) + return uuo +} + +// SetNillableLocationX sets the "location_x" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLocationX(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLocationX(*i) + } + return uuo +} + +// AddLocationX adds i to the "location_x" field. +func (uuo *UeUpdateOne) AddLocationX(i int) *UeUpdateOne { + uuo.mutation.AddLocationX(i) + return uuo +} + +// ClearLocationX clears the value of the "location_x" field. +func (uuo *UeUpdateOne) ClearLocationX() *UeUpdateOne { + uuo.mutation.ClearLocationX() + return uuo +} + +// SetLocationY sets the "location_y" field. +func (uuo *UeUpdateOne) SetLocationY(i int) *UeUpdateOne { + uuo.mutation.ResetLocationY() + uuo.mutation.SetLocationY(i) + return uuo +} + +// SetNillableLocationY sets the "location_y" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLocationY(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLocationY(*i) + } + return uuo +} + +// AddLocationY adds i to the "location_y" field. +func (uuo *UeUpdateOne) AddLocationY(i int) *UeUpdateOne { + uuo.mutation.AddLocationY(i) + return uuo +} + +// ClearLocationY clears the value of the "location_y" field. +func (uuo *UeUpdateOne) ClearLocationY() *UeUpdateOne { + uuo.mutation.ClearLocationY() + return uuo +} + +// SetLocationZ sets the "location_z" field. +func (uuo *UeUpdateOne) SetLocationZ(i int) *UeUpdateOne { + uuo.mutation.ResetLocationZ() + uuo.mutation.SetLocationZ(i) + return uuo +} + +// SetNillableLocationZ sets the "location_z" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLocationZ(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLocationZ(*i) + } + return uuo +} + +// AddLocationZ adds i to the "location_z" field. +func (uuo *UeUpdateOne) AddLocationZ(i int) *UeUpdateOne { + uuo.mutation.AddLocationZ(i) + return uuo +} + +// ClearLocationZ clears the value of the "location_z" field. +func (uuo *UeUpdateOne) ClearLocationZ() *UeUpdateOne { + uuo.mutation.ClearLocationZ() + return uuo +} + +// SetLocationN sets the "location_n" field. +func (uuo *UeUpdateOne) SetLocationN(i int) *UeUpdateOne { + uuo.mutation.ResetLocationN() + uuo.mutation.SetLocationN(i) + return uuo +} + +// SetNillableLocationN sets the "location_n" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableLocationN(i *int) *UeUpdateOne { + if i != nil { + uuo.SetLocationN(*i) + } + return uuo +} + +// AddLocationN adds i to the "location_n" field. +func (uuo *UeUpdateOne) AddLocationN(i int) *UeUpdateOne { + uuo.mutation.AddLocationN(i) + return uuo +} + +// ClearLocationN clears the value of the "location_n" field. +func (uuo *UeUpdateOne) ClearLocationN() *UeUpdateOne { + uuo.mutation.ClearLocationN() + return uuo +} + +// SetAuthor sets the "author" field. +func (uuo *UeUpdateOne) SetAuthor(s string) *UeUpdateOne { + uuo.mutation.SetAuthor(s) + return uuo +} + +// SetNillableAuthor sets the "author" field if the given value is not nil. +func (uuo *UeUpdateOne) SetNillableAuthor(s *string) *UeUpdateOne { + if s != nil { + uuo.SetAuthor(*s) + } + return uuo +} + +// ClearAuthor clears the value of the "author" field. +func (uuo *UeUpdateOne) ClearAuthor() *UeUpdateOne { + uuo.mutation.ClearAuthor() + return uuo +} + +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (uuo *UeUpdateOne) SetOwnerID(id int) *UeUpdateOne { + uuo.mutation.SetOwnerID(id) + return uuo +} + +// SetOwner sets the "owner" edge to the User entity. +func (uuo *UeUpdateOne) SetOwner(u *User) *UeUpdateOne { + return uuo.SetOwnerID(u.ID) +} + +// Mutation returns the UeMutation object of the builder. +func (uuo *UeUpdateOne) Mutation() *UeMutation { + return uuo.mutation +} + +// ClearOwner clears the "owner" edge to the User entity. +func (uuo *UeUpdateOne) ClearOwner() *UeUpdateOne { + uuo.mutation.ClearOwner() + return uuo +} + +// Where appends a list predicates to the UeUpdate builder. +func (uuo *UeUpdateOne) Where(ps ...predicate.Ue) *UeUpdateOne { + uuo.mutation.Where(ps...) + return uuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (uuo *UeUpdateOne) Select(field string, fields ...string) *UeUpdateOne { + uuo.fields = append([]string{field}, fields...) + return uuo +} + +// Save executes the query and returns the updated Ue entity. +func (uuo *UeUpdateOne) Save(ctx context.Context) (*Ue, error) { + return withHooks[*Ue, UeMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uuo *UeUpdateOne) SaveX(ctx context.Context) *Ue { + node, err := uuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uuo *UeUpdateOne) Exec(ctx context.Context) error { + _, err := uuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uuo *UeUpdateOne) ExecX(ctx context.Context) { + if err := uuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uuo *UeUpdateOne) check() error { + if _, ok := uuo.mutation.OwnerID(); uuo.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Ue.owner"`) + } + return nil +} + +func (uuo *UeUpdateOne) sqlSave(ctx context.Context) (_node *Ue, err error) { + if err := uuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(ue.Table, ue.Columns, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt)) + id, ok := uuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Ue.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := uuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, ue.FieldID) + for _, f := range fields { + if !ue.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != ue.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := uuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uuo.mutation.Limit(); ok { + _spec.SetField(ue.FieldLimit, field.TypeBool, value) + } + if uuo.mutation.LimitCleared() { + _spec.ClearField(ue.FieldLimit, field.TypeBool) + } + if value, ok := uuo.mutation.LimitBoss(); ok { + _spec.SetField(ue.FieldLimitBoss, field.TypeBool, value) + } + if uuo.mutation.LimitBossCleared() { + _spec.ClearField(ue.FieldLimitBoss, field.TypeBool) + } + if value, ok := uuo.mutation.LimitItem(); ok { + _spec.SetField(ue.FieldLimitItem, field.TypeBool, value) + } + if uuo.mutation.LimitItemCleared() { + _spec.ClearField(ue.FieldLimitItem, field.TypeBool) + } + if value, ok := uuo.mutation.Lv(); ok { + _spec.SetField(ue.FieldLv, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLv(); ok { + _spec.AddField(ue.FieldLv, field.TypeInt, value) + } + if uuo.mutation.LvCleared() { + _spec.ClearField(ue.FieldLv, field.TypeInt) + } + if value, ok := uuo.mutation.LvPoint(); ok { + _spec.SetField(ue.FieldLvPoint, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLvPoint(); ok { + _spec.AddField(ue.FieldLvPoint, field.TypeInt, value) + } + if uuo.mutation.LvPointCleared() { + _spec.ClearField(ue.FieldLvPoint, field.TypeInt) + } + if value, ok := uuo.mutation.Model(); ok { + _spec.SetField(ue.FieldModel, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedModel(); ok { + _spec.AddField(ue.FieldModel, field.TypeInt, value) + } + if uuo.mutation.ModelCleared() { + _spec.ClearField(ue.FieldModel, field.TypeInt) + } + if value, ok := uuo.mutation.Sword(); ok { + _spec.SetField(ue.FieldSword, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedSword(); ok { + _spec.AddField(ue.FieldSword, field.TypeInt, value) + } + if uuo.mutation.SwordCleared() { + _spec.ClearField(ue.FieldSword, field.TypeInt) + } + if value, ok := uuo.mutation.Card(); ok { + _spec.SetField(ue.FieldCard, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedCard(); ok { + _spec.AddField(ue.FieldCard, field.TypeInt, value) + } + if uuo.mutation.CardCleared() { + _spec.ClearField(ue.FieldCard, field.TypeInt) + } + if value, ok := uuo.mutation.Mode(); ok { + _spec.SetField(ue.FieldMode, field.TypeString, value) + } + if uuo.mutation.ModeCleared() { + _spec.ClearField(ue.FieldMode, field.TypeString) + } + if value, ok := uuo.mutation.Token(); ok { + _spec.SetField(ue.FieldToken, field.TypeString, value) + } + if uuo.mutation.TokenCleared() { + _spec.ClearField(ue.FieldToken, field.TypeString) + } + if value, ok := uuo.mutation.Cp(); ok { + _spec.SetField(ue.FieldCp, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedCp(); ok { + _spec.AddField(ue.FieldCp, field.TypeInt, value) + } + if uuo.mutation.CpCleared() { + _spec.ClearField(ue.FieldCp, field.TypeInt) + } + if value, ok := uuo.mutation.Count(); ok { + _spec.SetField(ue.FieldCount, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedCount(); ok { + _spec.AddField(ue.FieldCount, field.TypeInt, value) + } + if uuo.mutation.CountCleared() { + _spec.ClearField(ue.FieldCount, field.TypeInt) + } + if value, ok := uuo.mutation.LocationX(); ok { + _spec.SetField(ue.FieldLocationX, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLocationX(); ok { + _spec.AddField(ue.FieldLocationX, field.TypeInt, value) + } + if uuo.mutation.LocationXCleared() { + _spec.ClearField(ue.FieldLocationX, field.TypeInt) + } + if value, ok := uuo.mutation.LocationY(); ok { + _spec.SetField(ue.FieldLocationY, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLocationY(); ok { + _spec.AddField(ue.FieldLocationY, field.TypeInt, value) + } + if uuo.mutation.LocationYCleared() { + _spec.ClearField(ue.FieldLocationY, field.TypeInt) + } + if value, ok := uuo.mutation.LocationZ(); ok { + _spec.SetField(ue.FieldLocationZ, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLocationZ(); ok { + _spec.AddField(ue.FieldLocationZ, field.TypeInt, value) + } + if uuo.mutation.LocationZCleared() { + _spec.ClearField(ue.FieldLocationZ, field.TypeInt) + } + if value, ok := uuo.mutation.LocationN(); ok { + _spec.SetField(ue.FieldLocationN, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedLocationN(); ok { + _spec.AddField(ue.FieldLocationN, field.TypeInt, value) + } + if uuo.mutation.LocationNCleared() { + _spec.ClearField(ue.FieldLocationN, field.TypeInt) + } + if value, ok := uuo.mutation.Author(); ok { + _spec.SetField(ue.FieldAuthor, field.TypeString, value) + } + if uuo.mutation.AuthorCleared() { + _spec.ClearField(ue.FieldAuthor, field.TypeString) + } + if uuo.mutation.CreatedAtCleared() { + _spec.ClearField(ue.FieldCreatedAt, field.TypeTime) + } + if uuo.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: ue.OwnerTable, + Columns: []string{ue.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: ue.OwnerTable, + Columns: []string{ue.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Ue{config: uuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{ue.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + uuo.mutation.done = true + return _node, nil +} diff --git a/ent/user.go b/ent/user.go index 4d654a5..9bae624 100644 --- a/ent/user.go +++ b/ent/user.go @@ -120,9 +120,11 @@ type User struct { type UserEdges struct { // Card holds the value of the card edge. Card []*Card `json:"card,omitempty"` + // Ue holds the value of the ue edge. + Ue []*Ue `json:"ue,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [2]bool } // CardOrErr returns the Card value or an error if the edge @@ -134,6 +136,15 @@ func (e UserEdges) CardOrErr() ([]*Card, error) { return nil, &NotLoadedError{edge: "card"} } +// UeOrErr returns the Ue value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) UeOrErr() ([]*Ue, error) { + if e.loadedTypes[1] { + return e.Ue, nil + } + return nil, &NotLoadedError{edge: "ue"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -469,6 +480,11 @@ func (u *User) QueryCard() *CardQuery { return NewUserClient(u.config).QueryCard(u) } +// QueryUe queries the "ue" edge of the User entity. +func (u *User) QueryUe() *UeQuery { + return NewUserClient(u.config).QueryUe(u) +} + // Update returns a builder for updating this User. // Note that you need to call User.Unwrap() before calling this method if this User // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/ent/user/user.go b/ent/user/user.go index 41fbbc7..edfa0dc 100644 --- a/ent/user/user.go +++ b/ent/user/user.go @@ -107,6 +107,8 @@ const ( FieldGameLv = "game_lv" // EdgeCard holds the string denoting the card edge name in mutations. EdgeCard = "card" + // EdgeUe holds the string denoting the ue edge name in mutations. + EdgeUe = "ue" // Table holds the table name of the user in the database. Table = "users" // CardTable is the table that holds the card relation/edge. @@ -116,6 +118,13 @@ const ( CardInverseTable = "cards" // CardColumn is the table column denoting the card relation/edge. CardColumn = "user_card" + // UeTable is the table that holds the ue relation/edge. + UeTable = "ues" + // UeInverseTable is the table name for the Ue entity. + // It exists in this package in order to avoid circular dependency with the "ue" package. + UeInverseTable = "ues" + // UeColumn is the table column denoting the ue relation/edge. + UeColumn = "user_ue" ) // Columns holds all SQL columns for user fields. diff --git a/ent/user/where.go b/ent/user/where.go index c9684a5..1f1154b 100644 --- a/ent/user/where.go +++ b/ent/user/where.go @@ -2452,6 +2452,33 @@ func HasCardWith(preds ...predicate.Card) predicate.User { }) } +// HasUe applies the HasEdge predicate on the "ue" edge. +func HasUe() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUeWith applies the HasEdge predicate on the "ue" edge with a given conditions (other predicates). +func HasUeWith(preds ...predicate.Ue) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UeInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/ent/user_create.go b/ent/user_create.go index e5f7f35..0b46208 100644 --- a/ent/user_create.go +++ b/ent/user_create.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "t/ent/card" + "t/ent/ue" "t/ent/user" "time" @@ -678,6 +679,21 @@ func (uc *UserCreate) AddCard(c ...*Card) *UserCreate { return uc.AddCardIDs(ids...) } +// AddUeIDs adds the "ue" edge to the Ue entity by IDs. +func (uc *UserCreate) AddUeIDs(ids ...int) *UserCreate { + uc.mutation.AddUeIDs(ids...) + return uc +} + +// AddUe adds the "ue" edges to the Ue entity. +func (uc *UserCreate) AddUe(u ...*Ue) *UserCreate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uc.AddUeIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uc *UserCreate) Mutation() *UserMutation { return uc.mutation @@ -1051,6 +1067,22 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := uc.mutation.UeIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/ent/user_query.go b/ent/user_query.go index ac8123f..3833ac4 100644 --- a/ent/user_query.go +++ b/ent/user_query.go @@ -9,6 +9,7 @@ import ( "math" "t/ent/card" "t/ent/predicate" + "t/ent/ue" "t/ent/user" "entgo.io/ent/dialect/sql" @@ -24,6 +25,7 @@ type UserQuery struct { inters []Interceptor predicates []predicate.User withCard *CardQuery + withUe *UeQuery withFKs bool // intermediate query (i.e. traversal path). sql *sql.Selector @@ -83,6 +85,28 @@ func (uq *UserQuery) QueryCard() *CardQuery { return query } +// QueryUe chains the current query on the "ue" edge. +func (uq *UserQuery) QueryUe() *UeQuery { + query := (&UeClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(ue.Table, ue.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. func (uq *UserQuery) First(ctx context.Context) (*User, error) { @@ -276,6 +300,7 @@ func (uq *UserQuery) Clone() *UserQuery { inters: append([]Interceptor{}, uq.inters...), predicates: append([]predicate.User{}, uq.predicates...), withCard: uq.withCard.Clone(), + withUe: uq.withUe.Clone(), // clone intermediate query. sql: uq.sql.Clone(), path: uq.path, @@ -293,6 +318,17 @@ func (uq *UserQuery) WithCard(opts ...func(*CardQuery)) *UserQuery { return uq } +// WithUe tells the query-builder to eager-load the nodes that are connected to +// the "ue" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithUe(opts ...func(*UeQuery)) *UserQuery { + query := (&UeClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withUe = query + return uq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -372,8 +408,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e nodes = []*User{} withFKs = uq.withFKs _spec = uq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [2]bool{ uq.withCard != nil, + uq.withUe != nil, } ) if withFKs { @@ -404,6 +441,13 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nil, err } } + if query := uq.withUe; query != nil { + if err := uq.loadUe(ctx, query, nodes, + func(n *User) { n.Edges.Ue = []*Ue{} }, + func(n *User, e *Ue) { n.Edges.Ue = append(n.Edges.Ue, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -438,6 +482,37 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us } return nil } +func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User, init func(*User), assign func(*User, *Ue)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Ue(func(s *sql.Selector) { + s.Where(sql.InValues(user.UeColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_ue + if fk == nil { + return fmt.Errorf(`foreign-key "user_ue" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { _spec := uq.querySpec() diff --git a/ent/user_update.go b/ent/user_update.go index fa0d678..463de22 100644 --- a/ent/user_update.go +++ b/ent/user_update.go @@ -8,6 +8,7 @@ import ( "fmt" "t/ent/card" "t/ent/predicate" + "t/ent/ue" "t/ent/user" "time" @@ -1029,6 +1030,21 @@ func (uu *UserUpdate) AddCard(c ...*Card) *UserUpdate { return uu.AddCardIDs(ids...) } +// AddUeIDs adds the "ue" edge to the Ue entity by IDs. +func (uu *UserUpdate) AddUeIDs(ids ...int) *UserUpdate { + uu.mutation.AddUeIDs(ids...) + return uu +} + +// AddUe adds the "ue" edges to the Ue entity. +func (uu *UserUpdate) AddUe(u ...*Ue) *UserUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.AddUeIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation @@ -1055,6 +1071,27 @@ func (uu *UserUpdate) RemoveCard(c ...*Card) *UserUpdate { return uu.RemoveCardIDs(ids...) } +// ClearUe clears all "ue" edges to the Ue entity. +func (uu *UserUpdate) ClearUe() *UserUpdate { + uu.mutation.ClearUe() + return uu +} + +// RemoveUeIDs removes the "ue" edge to Ue entities by IDs. +func (uu *UserUpdate) RemoveUeIDs(ids ...int) *UserUpdate { + uu.mutation.RemoveUeIDs(ids...) + return uu +} + +// RemoveUe removes "ue" edges to Ue entities. +func (uu *UserUpdate) RemoveUe(u ...*Ue) *UserUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.RemoveUeIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) @@ -1448,6 +1485,51 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uu.mutation.UeCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedUeIDs(); len(nodes) > 0 && !uu.mutation.UeCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.UeIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} @@ -2468,6 +2550,21 @@ func (uuo *UserUpdateOne) AddCard(c ...*Card) *UserUpdateOne { return uuo.AddCardIDs(ids...) } +// AddUeIDs adds the "ue" edge to the Ue entity by IDs. +func (uuo *UserUpdateOne) AddUeIDs(ids ...int) *UserUpdateOne { + uuo.mutation.AddUeIDs(ids...) + return uuo +} + +// AddUe adds the "ue" edges to the Ue entity. +func (uuo *UserUpdateOne) AddUe(u ...*Ue) *UserUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.AddUeIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation @@ -2494,6 +2591,27 @@ func (uuo *UserUpdateOne) RemoveCard(c ...*Card) *UserUpdateOne { return uuo.RemoveCardIDs(ids...) } +// ClearUe clears all "ue" edges to the Ue entity. +func (uuo *UserUpdateOne) ClearUe() *UserUpdateOne { + uuo.mutation.ClearUe() + return uuo +} + +// RemoveUeIDs removes the "ue" edge to Ue entities by IDs. +func (uuo *UserUpdateOne) RemoveUeIDs(ids ...int) *UserUpdateOne { + uuo.mutation.RemoveUeIDs(ids...) + return uuo +} + +// RemoveUe removes "ue" edges to Ue entities. +func (uuo *UserUpdateOne) RemoveUe(u ...*Ue) *UserUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.RemoveUeIDs(ids...) +} + // Where appends a list predicates to the UserUpdate builder. func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { uuo.mutation.Where(ps...) @@ -2917,6 +3035,51 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uuo.mutation.UeCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedUeIDs(); len(nodes) > 0 && !uuo.mutation.UeCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.UeIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.UeTable, + Columns: []string{user.UeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &User{config: uuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/main.go b/main.go index 666c37f..382e82b 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,7 @@ func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) erro func main() { // Create ent client. - client, err := ent.Open(dialect.SQLite, "file:/data/new.sqlite?_fk=1") + client, err := ent.Open(dialect.SQLite, "file:/app/data/new.sqlite?_fk=1") //client, err := ent.Open(dialect.SQLite, "file:data/new.sqlite?_fk=1") //client, err := ent.Open(dialect.SQLite, "file:data?mode=memory&cache=shared&_fk=1") if err != nil { diff --git a/tmp/game_account.zsh b/tmp/game_account.zsh index 76d3d10..67d687d 100755 --- a/tmp/game_account.zsh +++ b/tmp/game_account.zsh @@ -8,6 +8,6 @@ id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$user curl -sL $host/users/$id read echo $id -o=false +o=true echo $o curl -X PATCH -H "Content-Type: application/json" -d "{\"game\":true, \"game_test\":$o, \"game_end\":$o, \"token\":\"$token\"}" -s $host/users/$id diff --git a/tmp/ogent/oas_response_encoders_gen.go b/tmp/ogent/oas_response_encoders_gen.go index 8d7c163..737e256 100644 --- a/tmp/ogent/oas_response_encoders_gen.go +++ b/tmp/ogent/oas_response_encoders_gen.go @@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s } } +func encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeCreate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeCreateUserResponse(response CreateUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *UserCreate: @@ -298,6 +353,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s } } +func encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *DeleteUeNoContent: + w.WriteHeader(204) + span.SetStatus(codes.Ok, http.StatusText(204)) + + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeDeleteUserResponse(response DeleteUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *DeleteUserNoContent: @@ -575,6 +691,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri } } +func encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListUeOKApplicationJSON: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai") switch response := response.(type) { @@ -711,6 +894,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter, } } +func encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListUserUeOKApplicationJSON: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai") switch response := response.(type) { @@ -914,6 +1164,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span } } +func encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeRead: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + +func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeOwnerRead: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Access-Control-Allow-Origin", "*") switch response := response.(type) { @@ -1116,6 +1500,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s } } +func encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UeUpdate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R404: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R409: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(409) + span.SetStatus(codes.Error, http.StatusText(409)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + case *R500: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + span.SetStatus(codes.Error, http.StatusText(500)) + + e := jx.GetEncoder() + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeUpdateUserResponse(response UpdateUserRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *UserUpdate: diff --git a/tmp/ogent/ogent.go b/tmp/ogent/ogent.go index 3dfede2..7c83275 100644 --- a/tmp/ogent/ogent.go +++ b/tmp/ogent/ogent.go @@ -9,10 +9,10 @@ import ( "t/ent" "t/ent/card" "t/ent/group" + "t/ent/ue" "t/ent/user" - - "github.com/go-faster/jx" "os" + "github.com/go-faster/jx" ) // origin-config @@ -48,29 +48,31 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea if v, ok := req.Status.Get(); ok { b.SetStatus(v) } + if v, ok := req.Token.Get(); ok { + b.SetToken(v) + } if v, ok := req.Cp.Get(); ok { b.SetCp(v) } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } if v, ok := req.Count.Get(); ok { b.SetCount(v) } if v, ok := req.Author.Get(); ok { b.SetAuthor(v) } - if v, ok := req.URL.Get(); ok { - b.SetURL(v) - } if v, ok := req.CreatedAt.Get(); ok { b.SetCreatedAt(v) } // Add all edges. - //b.SetOwnerID(req.Owner) - // origin-config if req.Password == password { b.SetOwnerID(req.Owner) } else { b.SetOwnerID(0) } + //b.SetOwnerID(req.Owner) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -131,33 +133,32 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea // UpdateCard handles PATCH /cards/{id} requests. func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) { b := h.client.Card.UpdateOneID(params.ID) + // Add all fields. + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Skill.Get(); ok { + b.SetSkill(v) + } + if v, ok := req.Status.Get(); ok { + b.SetStatus(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + // Add all edges. if v, ok := req.Token.Get(); ok { if v == token { b.SetToken(v) - if v, ok := req.Skill.Get(); ok { - b.SetSkill(v) - } - if v, ok := req.URL.Get(); ok { - b.SetURL(v) - } - if v, ok := req.Status.Get(); ok { - b.SetStatus(v) - } - if v, ok := req.Count.Get(); ok { - b.SetCount(v) - } - if v, ok := req.Author.Get(); ok { - b.SetAuthor(v) - } - if v, ok := req.Token.Get(); ok { - b.SetToken(v) - } - if v, ok := req.Cp.Get(); ok { - b.SetCp(v) - } - if v, ok := req.Card.Get(); ok { - b.SetCard(v) - } if v, ok := req.Owner.Get(); ok { b.SetOwnerID(v) } @@ -197,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param // DeleteCard handles DELETE /cards/{id} requests. func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) { - err := h.client.Card.DeleteOneID(0).Exec(ctx) //err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) + err := h.client.Card.DeleteOneID(0).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -289,7 +290,7 @@ func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerPa func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) { b := h.client.Group.Create() // Add all fields. - b.SetName("") + b.SetName(req.Name) b.SetPassword(req.Password) // Add all edges. b.AddUserIDs(req.Users...) @@ -353,6 +354,7 @@ func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (R // UpdateGroup handles PATCH /groups/{id} requests. func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) { b := h.client.Group.UpdateOneID(0) + //b := h.client.Group.UpdateOneID(params.ID) // Add all fields. if v, ok := req.Name.Get(); ok { b.SetName(v) @@ -395,6 +397,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par // DeleteGroup handles DELETE /groups/{id} requests. func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) { err := h.client.Group.DeleteOneID(0).Exec(ctx) + //err := h.client.Group.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -491,40 +494,318 @@ func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsers return (*ListGroupUsersOKApplicationJSON)(&r), nil } +// CreateUe handles POST /ues requests. +func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error) { + b := h.client.Ue.Create() + // Add all fields. + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.LimitBoss.Get(); ok { + b.SetLimitBoss(v) + } + if v, ok := req.LimitItem.Get(); ok { + b.SetLimitItem(v) + } + b.SetPassword(req.Password) + if v, ok := req.Lv.Get(); ok { + b.SetLv(v) + } + if v, ok := req.LvPoint.Get(); ok { + b.SetLvPoint(v) + } + if v, ok := req.Model.Get(); ok { + b.SetModel(v) + } + if v, ok := req.Sword.Get(); ok { + b.SetSword(v) + } + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Mode.Get(); ok { + b.SetMode(v) + } + if v, ok := req.Token.Get(); ok { + b.SetToken(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.LocationX.Get(); ok { + b.SetLocationX(v) + } + if v, ok := req.LocationY.Get(); ok { + b.SetLocationY(v) + } + if v, ok := req.LocationZ.Get(); ok { + b.SetLocationZ(v) + } + if v, ok := req.LocationN.Get(); ok { + b.SetLocationN(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + if v, ok := req.CreatedAt.Get(); ok { + b.SetCreatedAt(v) + } + // Add all edges. + //b.SetOwnerID(req.Owner) + if req.Password == password { + b.SetOwnerID(req.Owner) + } else { + b.SetOwnerID(0) + } + // Persist to storage. + e, err := b.Save(ctx) + if err != nil { + switch { + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + // Reload the entity to attach all eager-loaded edges. + q := h.client.Ue.Query().Where(ue.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUeCreate(e), nil +} + +// ReadUe handles GET /ues/{id} requests. +func (h *OgentHandler) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) { + q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)) + e, err := q.Only(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return NewUeRead(e), nil +} + +// UpdateUe handles PATCH /ues/{id} requests. +func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) { + b := h.client.Ue.UpdateOneID(params.ID) + // Add all fields. + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.LimitBoss.Get(); ok { + b.SetLimitBoss(v) + } + if v, ok := req.LimitItem.Get(); ok { + b.SetLimitItem(v) + } + if v, ok := req.Lv.Get(); ok { + b.SetLv(v) + } + if v, ok := req.LvPoint.Get(); ok { + b.SetLvPoint(v) + } + if v, ok := req.Model.Get(); ok { + b.SetModel(v) + } + if v, ok := req.Sword.Get(); ok { + b.SetSword(v) + } + if v, ok := req.Card.Get(); ok { + b.SetCard(v) + } + if v, ok := req.Mode.Get(); ok { + b.SetMode(v) + } + if v, ok := req.Cp.Get(); ok { + b.SetCp(v) + } + if v, ok := req.Count.Get(); ok { + b.SetCount(v) + } + if v, ok := req.LocationX.Get(); ok { + b.SetLocationX(v) + } + if v, ok := req.LocationY.Get(); ok { + b.SetLocationY(v) + } + if v, ok := req.LocationZ.Get(); ok { + b.SetLocationZ(v) + } + if v, ok := req.LocationN.Get(); ok { + b.SetLocationN(v) + } + if v, ok := req.Author.Get(); ok { + b.SetAuthor(v) + } + // Add all edges. + if v, ok := req.Token.Get(); ok { + if v == token { + b.SetToken(v) + if v, ok := req.Owner.Get(); ok { + b.SetOwnerID(v) + } + } + } + + // Persist to storage. + e, err := b.Save(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + // Reload the entity to attach all eager-loaded edges. + q := h.client.Ue.Query().Where(ue.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUeUpdate(e), nil +} + +// DeleteUe handles DELETE /ues/{id} requests. +func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) { + err := h.client.Ue.DeleteOneID(0).Exec(ctx) + //err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsConstraintError(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return new(DeleteUeNoContent), nil + +} + +// ListUe handles GET /ues requests. +func (h *OgentHandler) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) { + q := h.client.Ue.Query() + page := 1 + if v, ok := params.Page.Get(); ok { + page = v + } + itemsPerPage := 30 + if v, ok := params.ItemsPerPage.Get(); ok { + itemsPerPage = v + } + q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage) + + es, err := q.All(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + r := NewUeLists(es) + return (*ListUeOKApplicationJSON)(&r), nil +} + +// ReadUeOwner handles GET /ues/{id}/owner requests. +func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) { + q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)).QueryOwner() + e, err := q.Only(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + return NewUeOwnerRead(e), nil +} + // CreateUser handles POST /users requests. func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) { b := h.client.User.Create() - - // Add all fields. - //b.SetUsername(req.Username) - //origin-config - if req.Password == password { - b.SetUsername(req.Username) - } else { - b.SetUsername("") - } - - b.SetPassword(req.Password) - - if v, ok := req.ServerAt.Get(); ok { - b.SetServerAt(v) - } - - if v, ok := req.Room.Get(); ok { - b.SetRoom(v) - } - if v, ok := req.Fav.Get(); ok { - b.SetFav(v) - } - if v, ok := req.Did.Get(); ok { + if v, ok := req.Did.Get(); ok { b.SetDid(v) } - if v, ok := req.Bsky.Get(); ok { - b.SetBsky(v) - } - if v, ok := req.Mastodon.Get(); ok { - b.SetMastodon(v) - } if v, ok := req.Member.Get(); ok { b.SetMember(v) } @@ -537,6 +818,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Badge.Get(); ok { b.SetBadge(v) } + if v, ok := req.Bsky.Get(); ok { + b.SetBsky(v) + } + if v, ok := req.Mastodon.Get(); ok { + b.SetMastodon(v) + } if v, ok := req.Delete.Get(); ok { b.SetDelete(v) } @@ -546,9 +833,7 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Token.Get(); ok { b.SetToken(v) } - if v, ok := req.EggAt.Get(); ok { - b.SetEggAt(v) - } + b.SetPassword(req.Password) if v, ok := req.CreatedAt.Get(); ok { b.SetCreatedAt(v) } @@ -558,12 +843,15 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.RaidAt.Get(); ok { b.SetRaidAt(v) } + if v, ok := req.ServerAt.Get(); ok { + b.SetServerAt(v) + } + if v, ok := req.EggAt.Get(); ok { + b.SetEggAt(v) + } if v, ok := req.Luck.Get(); ok { b.SetLuck(v) } - if v, ok := req.Aiten.Get(); ok { - b.SetAiten(v) - } if v, ok := req.LuckAt.Get(); ok { b.SetLuckAt(v) } @@ -576,6 +864,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.LikeAt.Get(); ok { b.SetLikeAt(v) } + if v, ok := req.Fav.Get(); ok { + b.SetFav(v) + } if v, ok := req.Ten.Get(); ok { b.SetTen(v) } @@ -585,6 +876,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.TenKai.Get(); ok { b.SetTenKai(v) } + if v, ok := req.Aiten.Get(); ok { + b.SetAiten(v) + } if v, ok := req.TenCard.Get(); ok { b.SetTenCard(v) } @@ -603,6 +897,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.Next.Get(); ok { b.SetNext(v) } + if v, ok := req.Room.Get(); ok { + b.SetRoom(v) + } if v, ok := req.Model.Get(); ok { b.SetModel(v) } @@ -612,12 +909,6 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.ModelAttack.Get(); ok { b.SetModelAttack(v) } - if v, ok := req.ModelCriticalD.Get(); ok { - b.SetModelCriticalD(v) - } - if v, ok := req.ModelCritical.Get(); ok { - b.SetModelCritical(v) - } if v, ok := req.ModelLimit.Get(); ok { b.SetModelLimit(v) } @@ -627,6 +918,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea if v, ok := req.ModelMode.Get(); ok { b.SetModelMode(v) } + if v, ok := req.ModelCritical.Get(); ok { + b.SetModelCritical(v) + } + if v, ok := req.ModelCriticalD.Get(); ok { + b.SetModelCriticalD(v) + } if v, ok := req.Game.Get(); ok { b.SetGame(v) } @@ -643,8 +940,16 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea b.SetGameLv(v) } + // Add all fields. + //b.SetUsername(req.Username) + if req.Password == password { + b.SetUsername(req.Username) + } else { + b.SetUsername("") + } // Add all edges. b.AddCardIDs(req.Card...) + b.AddUeIDs(req.Ue...) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -705,20 +1010,9 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea // UpdateUser handles PATCH /users/{id} requests. func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) { b := h.client.User.UpdateOneID(params.ID) - if v, ok := req.Token.Get(); ok { if v == token { - b.SetToken(v) - - if v, ok := req.ServerAt.Get(); ok { - b.SetServerAt(v) - } - if v, ok := req.Room.Get(); ok { - b.SetRoom(v) - } - if v, ok := req.Fav.Get(); ok { - b.SetFav(v) - } + // Add all fields. if v, ok := req.Did.Get(); ok { b.SetDid(v) } @@ -746,17 +1040,17 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.Handle.Get(); ok { b.SetHandle(v) } - if v, ok := req.EggAt.Get(); ok { - b.SetEggAt(v) - } if v, ok := req.UpdatedAt.Get(); ok { b.SetUpdatedAt(v) } if v, ok := req.RaidAt.Get(); ok { b.SetRaidAt(v) } - if v, ok := req.Aiten.Get(); ok { - b.SetAiten(v) + if v, ok := req.ServerAt.Get(); ok { + b.SetServerAt(v) + } + if v, ok := req.EggAt.Get(); ok { + b.SetEggAt(v) } if v, ok := req.Luck.Get(); ok { b.SetLuck(v) @@ -773,6 +1067,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.LikeAt.Get(); ok { b.SetLikeAt(v) } + if v, ok := req.Fav.Get(); ok { + b.SetFav(v) + } if v, ok := req.Ten.Get(); ok { b.SetTen(v) } @@ -782,6 +1079,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.TenKai.Get(); ok { b.SetTenKai(v) } + if v, ok := req.Aiten.Get(); ok { + b.SetAiten(v) + } if v, ok := req.TenCard.Get(); ok { b.SetTenCard(v) } @@ -800,6 +1100,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.Next.Get(); ok { b.SetNext(v) } + if v, ok := req.Room.Get(); ok { + b.SetRoom(v) + } if v, ok := req.Model.Get(); ok { b.SetModel(v) } @@ -809,12 +1112,6 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.ModelAttack.Get(); ok { b.SetModelAttack(v) } - if v, ok := req.ModelCriticalD.Get(); ok { - b.SetModelCriticalD(v) - } - if v, ok := req.ModelCritical.Get(); ok { - b.SetModelCritical(v) - } if v, ok := req.ModelLimit.Get(); ok { b.SetModelLimit(v) } @@ -824,6 +1121,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if v, ok := req.ModelMode.Get(); ok { b.SetModelMode(v) } + if v, ok := req.ModelCritical.Get(); ok { + b.SetModelCritical(v) + } + if v, ok := req.ModelCriticalD.Get(); ok { + b.SetModelCriticalD(v) + } if v, ok := req.Game.Get(); ok { b.SetGame(v) } @@ -843,9 +1146,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param if req.Card != nil { b.ClearCard().AddCardIDs(req.Card...) } + if req.Ue != nil { + b.ClearUe().AddUeIDs(req.Ue...) + } + b.SetToken(v) } } - // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -880,6 +1186,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param // DeleteUser handles DELETE /users/{id} requests. func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) { err := h.client.User.DeleteOneID(0).Exec(ctx) + //err := h.client.User.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -975,3 +1282,39 @@ func (h *OgentHandler) ListUserCard(ctx context.Context, params ListUserCardPara r := NewUserCardLists(es) return (*ListUserCardOKApplicationJSON)(&r), nil } + +// ListUserUe handles GET /users/{id}/ue requests. +func (h *OgentHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) { + q := h.client.User.Query().Where(user.IDEQ(params.ID)).QueryUe() + page := 1 + if v, ok := params.Page.Get(); ok { + page = v + } + itemsPerPage := 30 + if v, ok := params.ItemsPerPage.Get(); ok { + itemsPerPage = v + } + q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage) + es, err := q.All(ctx) + if err != nil { + switch { + case ent.IsNotFound(err): + return &R404{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: rawError(err), + }, nil + case ent.IsNotSingular(err): + return &R409{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: rawError(err), + }, nil + default: + // Let the server handle the error. + return nil, err + } + } + r := NewUserUeLists(es) + return (*ListUserUeOKApplicationJSON)(&r), nil +} diff --git a/tmp/ue_add_test.zsh b/tmp/ue_add_test.zsh new file mode 100755 index 0000000..2c67681 --- /dev/null +++ b/tmp/ue_add_test.zsh @@ -0,0 +1,18 @@ +#!/bin/zsh + +host=https://api.syui.ai +pass=`cat ~/.config/atr/api_card.json|jq -r .password` +if [ -z "$1" ];then + exit +fi + +echo username +read +id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id` + +card=0 +model=0 +sword=0 +curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card, \"model\":$model,\"sword\":$sword,\"password\":\"$pass\"}" -sL $host/ues + +curl -sL api.syui.ai/users/$id/ue diff --git a/tmp/user_json.zsh b/tmp/user_json.zsh index 670705f..2bc81d7 100755 --- a/tmp/user_json.zsh +++ b/tmp/user_json.zsh @@ -12,7 +12,7 @@ data=`curl -sL "$host_users"|jq .` n=`echo $data|jq length` n=$((n - 1)) -f=/Volumes/ssd/project/yui/Content/user.json +f=~/ai/card/public/json/user.json if [ -f $f ];then rm $f fi @@ -33,3 +33,5 @@ do done echo "}" >> $f + + cat $f|jq .