commit d40e30944ba2f53fc2d8a4d52ace764857d44608 Author: syui Date: Wed Aug 31 15:18:14 2022 +0900 first diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..718f4d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +t diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..26a0787 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bin/t diff --git a/ent/client.go b/ent/client.go new file mode 100644 index 0000000..e9f5a9b --- /dev/null +++ b/ent/client.go @@ -0,0 +1,213 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "log" + + "t/ent/migrate" + + "t/ent/users" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // Users is the client for interacting with the Users builders. + Users *UsersClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + cfg := config{log: log.Println, hooks: &hooks{}} + cfg.options(opts...) + client := &Client{config: cfg} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.Users = NewUsersClient(c.config) +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + Users: NewUsersClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + Users: NewUsersClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Users. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.Users.Use(hooks...) +} + +// UsersClient is a client for the Users schema. +type UsersClient struct { + config +} + +// NewUsersClient returns a client for the Users from the given config. +func NewUsersClient(c config) *UsersClient { + return &UsersClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `users.Hooks(f(g(h())))`. +func (c *UsersClient) Use(hooks ...Hook) { + c.hooks.Users = append(c.hooks.Users, hooks...) +} + +// Create returns a create builder for Users. +func (c *UsersClient) Create() *UsersCreate { + mutation := newUsersMutation(c.config, OpCreate) + return &UsersCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Users entities. +func (c *UsersClient) CreateBulk(builders ...*UsersCreate) *UsersCreateBulk { + return &UsersCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Users. +func (c *UsersClient) Update() *UsersUpdate { + mutation := newUsersMutation(c.config, OpUpdate) + return &UsersUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UsersClient) UpdateOne(u *Users) *UsersUpdateOne { + mutation := newUsersMutation(c.config, OpUpdateOne, withUsers(u)) + return &UsersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UsersClient) UpdateOneID(id int) *UsersUpdateOne { + mutation := newUsersMutation(c.config, OpUpdateOne, withUsersID(id)) + return &UsersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Users. +func (c *UsersClient) Delete() *UsersDelete { + mutation := newUsersMutation(c.config, OpDelete) + return &UsersDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a delete builder for the given entity. +func (c *UsersClient) DeleteOne(u *Users) *UsersDeleteOne { + return c.DeleteOneID(u.ID) +} + +// DeleteOneID returns a delete builder for the given id. +func (c *UsersClient) DeleteOneID(id int) *UsersDeleteOne { + builder := c.Delete().Where(users.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UsersDeleteOne{builder} +} + +// Query returns a query builder for Users. +func (c *UsersClient) Query() *UsersQuery { + return &UsersQuery{ + config: c.config, + } +} + +// Get returns a Users entity by its id. +func (c *UsersClient) Get(ctx context.Context, id int) (*Users, error) { + return c.Query().Where(users.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UsersClient) GetX(ctx context.Context, id int) *Users { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UsersClient) Hooks() []Hook { + return c.hooks.Users +} diff --git a/ent/config.go b/ent/config.go new file mode 100644 index 0000000..50fd3be --- /dev/null +++ b/ent/config.go @@ -0,0 +1,59 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect" +) + +// Option function to configure the client. +type Option func(*config) + +// Config is the configuration for the client and its builder. +type config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...interface{}) + // hooks to execute on mutations. + hooks *hooks +} + +// hooks per client, for fast access. +type hooks struct { + Users []ent.Hook +} + +// Options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...interface{})) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} diff --git a/ent/context.go b/ent/context.go new file mode 100644 index 0000000..0840726 --- /dev/null +++ b/ent/context.go @@ -0,0 +1,33 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} diff --git a/ent/ent.go b/ent/ent.go new file mode 100644 index 0000000..71f1693 --- /dev/null +++ b/ent/ent.go @@ -0,0 +1,259 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "errors" + "fmt" + "t/ent/users" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +// OrderFunc applies an ordering on the sql selector. +type OrderFunc func(*sql.Selector) + +// columnChecker returns a function indicates if the column exists in the given column. +func columnChecker(table string) func(string) error { + checks := map[string]func(string) bool{ + users.Table: users.ValidColumn, + } + check, ok := checks[table] + if !ok { + return func(string) error { + return fmt.Errorf("unknown table %q", table) + } + } + return func(column string) error { + if !check(column) { + return fmt.Errorf("unknown column %q for table %q", column, table) + } + return nil + } +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) OrderFunc { + return func(s *sql.Selector) { + check := columnChecker(s.TableName()) + for _, f := range fields { + if err := check(f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) OrderFunc { + return func(s *sql.Selector) { + check := columnChecker(s.TableName()) + for _, f := range fields { + if err := check(f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +// +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} diff --git a/ent/entc.go b/ent/entc.go new file mode 100644 index 0000000..225644e --- /dev/null +++ b/ent/entc.go @@ -0,0 +1,85 @@ +//go:build ignore + +package main + +import ( + "log" + + "entgo.io/contrib/entoas" + "entgo.io/ent/entc" + "entgo.io/ent/entc/gen" + "github.com/ariga/ogent" + "github.com/ogen-go/ogen" +) + +func main() { + spec := new(ogen.Spec) + + //oas, err := entoas.NewExtension(entoas.Spec(spec)) + oas, err := entoas.NewExtension( + entoas.Spec(spec), + entoas.Mutations(func(_ *gen.Graph, spec *ogen.Spec) error { + spec.AddPathItem("/users/{id}/start", ogen.NewPathItem(). + SetDescription("Start an draw as done"). + SetPatch(ogen.NewOperation(). + SetOperationID("drawStart"). + SetSummary("Draws a card item as done."). + AddTags("Users"). + AddResponse("204", ogen.NewResponse().SetDescription("Item marked as done")), + ). + AddParameters(ogen.NewParameter(). + InPath(). + SetName("id"). + SetRequired(true). + SetSchema(ogen.Int()), + ), +) +return nil + }), + +// entoas.Mutations(func(_ *gen.Graph, spec *ogen.Spec) error { +// spec.AddPathItem( +// "/syui", +// ogen.NewPathItem(). +// SetGet( +// ogen.NewOperation(). +// SetOperationID("customReadUser"). +// +// AddResponse("204", ogen.NewResponse().SetDescription("Item marked as done")), +// ), +// ) +// return nil +// }), + entoas.Mutations(func(_ *gen.Graph, spec *ogen.Spec) error { + spec.AddPathItem("/users/{id}/d", ogen.NewPathItem(). + SetDescription("Start an draw as done"). + SetPut(ogen.NewOperation(). + SetOperationID("drawDone"). + SetSummary("Draws a card item as done."). + AddTags("Users"). + AddResponse("204", ogen.NewResponse().SetDescription("Item marked as done")), + //AddResponse("204", ogen.NewResponse().SetDescription("Item marked as done").SetSchema("test")), + ). + AddParameters(ogen.NewParameter(). + InPath(). + SetName("id"). + SetRequired(true). + SetSchema(ogen.Int()), + ), + ) + return nil + }), + ) + + if err != nil { + log.Fatalf("creating entoas extension: %v", err) + } + ogent, err := ogent.NewExtension(spec) + if err != nil { + log.Fatalf("creating ogent extension: %v", err) + } + err = entc.Generate("./schema", &gen.Config{}, entc.Extensions(ogent, oas)) + if err != nil { + log.Fatalf("running ent codegen: %v", err) + } + } diff --git a/ent/enttest/enttest.go b/ent/enttest/enttest.go new file mode 100644 index 0000000..e777ef9 --- /dev/null +++ b/ent/enttest/enttest.go @@ -0,0 +1,77 @@ +// Code generated by entc, DO NOT EDIT. + +package enttest + +import ( + "context" + "t/ent" + // required by schema hooks. + _ "t/ent/runtime" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...interface{}) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } + return c +} diff --git a/ent/generate.go b/ent/generate.go new file mode 100644 index 0000000..c6bc305 --- /dev/null +++ b/ent/generate.go @@ -0,0 +1,4 @@ +package ent + +//go:generate go run -mod=mod entc.go + diff --git a/ent/hook/hook.go b/ent/hook/hook.go new file mode 100644 index 0000000..d50076d --- /dev/null +++ b/ent/hook/hook.go @@ -0,0 +1,203 @@ +// Code generated by entc, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "t/ent" +) + +// The UsersFunc type is an adapter to allow the use of ordinary +// function as Users mutator. +type UsersFunc func(context.Context, *ent.UsersMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UsersFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.UsersMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UsersMutation", m) + } + return f(ctx, mv) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +// +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +// +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +// +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +// +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/ent/http/create.go b/ent/http/create.go new file mode 100644 index 0000000..178975d --- /dev/null +++ b/ent/http/create.go @@ -0,0 +1,224 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strings" + "t/ent" + "t/ent/compartment" + "t/ent/entry" + "t/ent/fridge" + "t/ent/item" + + "github.com/mailru/easyjson" + "go.uber.org/zap" +) + +// Create creates a new ent.Compartment and stores it in the database. +func (h CompartmentHandler) Create(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Create")) + // Get the post data. + var d CompartmentCreateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Compartment.Create() + e, err := b.Save(r.Context()) + if err != nil { + switch { + default: + l.Error("could not create compartment", zap.Error(err)) + InternalServerError(w, nil) + } + return + } + // Store id of fresh entity to log errors for the reload. + id := e.ID + // Reload entry. + q := h.client.Compartment.Query().Where(compartment.ID(e.ID)) + ret, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read compartment", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("compartment rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewCompartment3324871446View(ret), w) +} + +// Create creates a new ent.Entry and stores it in the database. +func (h EntryHandler) Create(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Create")) + // Get the post data. + var d EntryCreateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Validate the data. + errs := make(map[string]string) + if d.User == nil { + errs["user"] = `missing required field: "user"` + } else if err := entry.UserValidator(*d.User); err != nil { + errs["user"] = strings.TrimPrefix(err.Error(), "entry: ") + } + if d.First == nil { + errs["first"] = `missing required field: "first"` + } + if len(errs) > 0 { + l.Info("validation failed", zapFields(errs)...) + BadRequest(w, errs) + return + } + // Save the data. + b := h.client.Entry.Create() + if d.User != nil { + b.SetUser(*d.User) + } + if d.First != nil { + b.SetFirst(*d.First) + } + if d.CreatedAt != nil { + b.SetCreatedAt(*d.CreatedAt) + } + e, err := b.Save(r.Context()) + if err != nil { + switch { + default: + l.Error("could not create entry", zap.Error(err)) + InternalServerError(w, nil) + } + return + } + // Store id of fresh entity to log errors for the reload. + id := e.ID + // Reload entry. + q := h.client.Entry.Query().Where(entry.ID(e.ID)) + ret, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.String("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.String("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read entry", zap.Error(err), zap.String("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("entry rendered", zap.String("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewEntry2675665849View(ret), w) +} + +// Create creates a new ent.Fridge and stores it in the database. +func (h FridgeHandler) Create(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Create")) + // Get the post data. + var d FridgeCreateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Fridge.Create() + e, err := b.Save(r.Context()) + if err != nil { + switch { + default: + l.Error("could not create fridge", zap.Error(err)) + InternalServerError(w, nil) + } + return + } + // Store id of fresh entity to log errors for the reload. + id := e.ID + // Reload entry. + q := h.client.Fridge.Query().Where(fridge.ID(e.ID)) + ret, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read fridge", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("fridge rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewFridge2211356377View(ret), w) +} + +// Create creates a new ent.Item and stores it in the database. +func (h ItemHandler) Create(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Create")) + // Get the post data. + var d ItemCreateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Item.Create() + e, err := b.Save(r.Context()) + if err != nil { + switch { + default: + l.Error("could not create item", zap.Error(err)) + InternalServerError(w, nil) + } + return + } + // Store id of fresh entity to log errors for the reload. + id := e.ID + // Reload entry. + q := h.client.Item.Query().Where(item.ID(e.ID)) + ret, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read item", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("item rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewItem1548468123View(ret), w) +} diff --git a/ent/http/delete.go b/ent/http/delete.go new file mode 100644 index 0000000..c182aee --- /dev/null +++ b/ent/http/delete.go @@ -0,0 +1,116 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strconv" + "t/ent" + + "github.com/go-chi/chi/v5" + "go.uber.org/zap" +) + +// Delete removes a ent.Compartment from the database. +func (h CompartmentHandler) Delete(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Delete")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + err = h.client.Compartment.DeleteOneID(id).Exec(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + default: + l.Error("could-not-delete-compartment", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("compartment deleted", zap.Int("id", id)) + w.WriteHeader(http.StatusNoContent) +} + +// Delete removes a ent.Entry from the database. +func (h EntryHandler) Delete(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Delete")) + // ID is URL parameter. + var err error + id := chi.URLParam(r, "id") + err = h.client.Entry.DeleteOneID(id).Exec(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.String("id", id)) + NotFound(w, msg) + default: + l.Error("could-not-delete-entry", zap.Error(err), zap.String("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("entry deleted", zap.String("id", id)) + w.WriteHeader(http.StatusNoContent) +} + +// Delete removes a ent.Fridge from the database. +func (h FridgeHandler) Delete(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Delete")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + err = h.client.Fridge.DeleteOneID(id).Exec(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + default: + l.Error("could-not-delete-fridge", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("fridge deleted", zap.Int("id", id)) + w.WriteHeader(http.StatusNoContent) +} + +// Delete removes a ent.Item from the database. +func (h ItemHandler) Delete(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Delete")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + err = h.client.Item.DeleteOneID(id).Exec(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + default: + l.Error("could-not-delete-item", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("item deleted", zap.Int("id", id)) + w.WriteHeader(http.StatusNoContent) +} diff --git a/ent/http/easyjson.go b/ent/http/easyjson.go new file mode 100644 index 0000000..31e313b --- /dev/null +++ b/ent/http/easyjson.go @@ -0,0 +1,1075 @@ +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. + +package http + +import ( + json "encoding/json" + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" + time "time" +) + +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) + +func easyjsonC5a4559bDecodeTEntHttp(in *jlexer.Lexer, out *ItemUpdateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp(out *jwriter.Writer, in ItemUpdateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v ItemUpdateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *ItemUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp1(in *jlexer.Lexer, out *ItemCreateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp1(out *jwriter.Writer, in ItemCreateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v ItemCreateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp1(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *ItemCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp1(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp2(in *jlexer.Lexer, out *Item1548468123Views) { + isTopLevel := in.IsStart() + if in.IsNull() { + in.Skip() + *out = nil + } else { + in.Delim('[') + if *out == nil { + if !in.IsDelim(']') { + *out = make(Item1548468123Views, 0, 8) + } else { + *out = Item1548468123Views{} + } + } else { + *out = (*out)[:0] + } + for !in.IsDelim(']') { + var v1 *Item1548468123View + if in.IsNull() { + in.Skip() + v1 = nil + } else { + if v1 == nil { + v1 = new(Item1548468123View) + } + (*v1).UnmarshalEasyJSON(in) + } + *out = append(*out, v1) + in.WantComma() + } + in.Delim(']') + } + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp2(out *jwriter.Writer, in Item1548468123Views) { + if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v2, v3 := range in { + if v2 > 0 { + out.RawByte(',') + } + if v3 == nil { + out.RawString("null") + } else { + (*v3).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Item1548468123Views) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp2(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Item1548468123Views) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp2(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp3(in *jlexer.Lexer, out *Item1548468123View) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "id": + out.ID = int(in.Int()) + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp3(out *jwriter.Writer, in Item1548468123View) { + out.RawByte('{') + first := true + _ = first + if in.ID != 0 { + const prefix string = ",\"id\":" + first = false + out.RawString(prefix[1:]) + out.Int(int(in.ID)) + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Item1548468123View) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp3(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Item1548468123View) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp3(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp4(in *jlexer.Lexer, out *FridgeUpdateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp4(out *jwriter.Writer, in FridgeUpdateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FridgeUpdateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp4(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FridgeUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp4(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp5(in *jlexer.Lexer, out *FridgeCreateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp5(out *jwriter.Writer, in FridgeCreateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FridgeCreateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp5(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FridgeCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp5(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp6(in *jlexer.Lexer, out *Fridge2211356377Views) { + isTopLevel := in.IsStart() + if in.IsNull() { + in.Skip() + *out = nil + } else { + in.Delim('[') + if *out == nil { + if !in.IsDelim(']') { + *out = make(Fridge2211356377Views, 0, 8) + } else { + *out = Fridge2211356377Views{} + } + } else { + *out = (*out)[:0] + } + for !in.IsDelim(']') { + var v4 *Fridge2211356377View + if in.IsNull() { + in.Skip() + v4 = nil + } else { + if v4 == nil { + v4 = new(Fridge2211356377View) + } + (*v4).UnmarshalEasyJSON(in) + } + *out = append(*out, v4) + in.WantComma() + } + in.Delim(']') + } + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp6(out *jwriter.Writer, in Fridge2211356377Views) { + if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v5, v6 := range in { + if v5 > 0 { + out.RawByte(',') + } + if v6 == nil { + out.RawString("null") + } else { + (*v6).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Fridge2211356377Views) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp6(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Fridge2211356377Views) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp6(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp7(in *jlexer.Lexer, out *Fridge2211356377View) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "id": + out.ID = int(in.Int()) + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp7(out *jwriter.Writer, in Fridge2211356377View) { + out.RawByte('{') + first := true + _ = first + if in.ID != 0 { + const prefix string = ",\"id\":" + first = false + out.RawString(prefix[1:]) + out.Int(int(in.ID)) + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Fridge2211356377View) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp7(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Fridge2211356377View) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp7(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp8(in *jlexer.Lexer, out *ErrResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "code": + out.Code = int(in.Int()) + case "status": + out.Status = string(in.String()) + case "errors": + if m, ok := out.Errors.(easyjson.Unmarshaler); ok { + m.UnmarshalEasyJSON(in) + } else if m, ok := out.Errors.(json.Unmarshaler); ok { + _ = m.UnmarshalJSON(in.Raw()) + } else { + out.Errors = in.Interface() + } + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp8(out *jwriter.Writer, in ErrResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"code\":" + out.RawString(prefix[1:]) + out.Int(int(in.Code)) + } + { + const prefix string = ",\"status\":" + out.RawString(prefix) + out.String(string(in.Status)) + } + if in.Errors != nil { + const prefix string = ",\"errors\":" + out.RawString(prefix) + if m, ok := in.Errors.(easyjson.Marshaler); ok { + m.MarshalEasyJSON(out) + } else if m, ok := in.Errors.(json.Marshaler); ok { + out.Raw(m.MarshalJSON()) + } else { + out.Raw(json.Marshal(in.Errors)) + } + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v ErrResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp8(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *ErrResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp8(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp9(in *jlexer.Lexer, out *EntryUpdateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp9(out *jwriter.Writer, in EntryUpdateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v EntryUpdateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp9(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *EntryUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp9(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp10(in *jlexer.Lexer, out *EntryCreateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "user": + if in.IsNull() { + in.Skip() + out.User = nil + } else { + if out.User == nil { + out.User = new(string) + } + *out.User = string(in.String()) + } + case "first": + if in.IsNull() { + in.Skip() + out.First = nil + } else { + if out.First == nil { + out.First = new(int) + } + *out.First = int(in.Int()) + } + case "created_at": + if in.IsNull() { + in.Skip() + out.CreatedAt = nil + } else { + if out.CreatedAt == nil { + out.CreatedAt = new(time.Time) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.CreatedAt).UnmarshalJSON(data)) + } + } + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp10(out *jwriter.Writer, in EntryCreateRequest) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"user\":" + out.RawString(prefix[1:]) + if in.User == nil { + out.RawString("null") + } else { + out.String(string(*in.User)) + } + } + { + const prefix string = ",\"first\":" + out.RawString(prefix) + if in.First == nil { + out.RawString("null") + } else { + out.Int(int(*in.First)) + } + } + { + const prefix string = ",\"created_at\":" + out.RawString(prefix) + if in.CreatedAt == nil { + out.RawString("null") + } else { + out.Raw((*in.CreatedAt).MarshalJSON()) + } + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v EntryCreateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp10(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *EntryCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp10(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp11(in *jlexer.Lexer, out *Entry2675665849Views) { + isTopLevel := in.IsStart() + if in.IsNull() { + in.Skip() + *out = nil + } else { + in.Delim('[') + if *out == nil { + if !in.IsDelim(']') { + *out = make(Entry2675665849Views, 0, 8) + } else { + *out = Entry2675665849Views{} + } + } else { + *out = (*out)[:0] + } + for !in.IsDelim(']') { + var v7 *Entry2675665849View + if in.IsNull() { + in.Skip() + v7 = nil + } else { + if v7 == nil { + v7 = new(Entry2675665849View) + } + (*v7).UnmarshalEasyJSON(in) + } + *out = append(*out, v7) + in.WantComma() + } + in.Delim(']') + } + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp11(out *jwriter.Writer, in Entry2675665849Views) { + if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v8, v9 := range in { + if v8 > 0 { + out.RawByte(',') + } + if v9 == nil { + out.RawString("null") + } else { + (*v9).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Entry2675665849Views) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp11(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Entry2675665849Views) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp11(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp12(in *jlexer.Lexer, out *Entry2675665849View) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "id": + out.ID = string(in.String()) + case "user": + out.User = string(in.String()) + case "first": + out.First = int(in.Int()) + case "created_at": + if data := in.Raw(); in.Ok() { + in.AddError((out.CreatedAt).UnmarshalJSON(data)) + } + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp12(out *jwriter.Writer, in Entry2675665849View) { + out.RawByte('{') + first := true + _ = first + if in.ID != "" { + const prefix string = ",\"id\":" + first = false + out.RawString(prefix[1:]) + out.String(string(in.ID)) + } + if in.User != "" { + const prefix string = ",\"user\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.User)) + } + if in.First != 0 { + const prefix string = ",\"first\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.Int(int(in.First)) + } + if true { + const prefix string = ",\"created_at\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.Raw((in.CreatedAt).MarshalJSON()) + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Entry2675665849View) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp12(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Entry2675665849View) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp12(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp13(in *jlexer.Lexer, out *CompartmentUpdateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp13(out *jwriter.Writer, in CompartmentUpdateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v CompartmentUpdateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp13(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *CompartmentUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp13(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp14(in *jlexer.Lexer, out *CompartmentCreateRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp14(out *jwriter.Writer, in CompartmentCreateRequest) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v CompartmentCreateRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp14(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *CompartmentCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp14(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp15(in *jlexer.Lexer, out *Compartment3324871446Views) { + isTopLevel := in.IsStart() + if in.IsNull() { + in.Skip() + *out = nil + } else { + in.Delim('[') + if *out == nil { + if !in.IsDelim(']') { + *out = make(Compartment3324871446Views, 0, 8) + } else { + *out = Compartment3324871446Views{} + } + } else { + *out = (*out)[:0] + } + for !in.IsDelim(']') { + var v10 *Compartment3324871446View + if in.IsNull() { + in.Skip() + v10 = nil + } else { + if v10 == nil { + v10 = new(Compartment3324871446View) + } + (*v10).UnmarshalEasyJSON(in) + } + *out = append(*out, v10) + in.WantComma() + } + in.Delim(']') + } + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp15(out *jwriter.Writer, in Compartment3324871446Views) { + if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v11, v12 := range in { + if v11 > 0 { + out.RawByte(',') + } + if v12 == nil { + out.RawString("null") + } else { + (*v12).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Compartment3324871446Views) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp15(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Compartment3324871446Views) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp15(l, v) +} +func easyjsonC5a4559bDecodeTEntHttp16(in *jlexer.Lexer, out *Compartment3324871446View) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "id": + out.ID = int(in.Int()) + default: + in.AddError(&jlexer.LexerError{ + Offset: in.GetPos(), + Reason: "unknown field", + Data: key, + }) + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeTEntHttp16(out *jwriter.Writer, in Compartment3324871446View) { + out.RawByte('{') + first := true + _ = first + if in.ID != 0 { + const prefix string = ",\"id\":" + first = false + out.RawString(prefix[1:]) + out.Int(int(in.ID)) + } + out.RawByte('}') +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Compartment3324871446View) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeTEntHttp16(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Compartment3324871446View) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeTEntHttp16(l, v) +} diff --git a/ent/http/handler.go b/ent/http/handler.go new file mode 100644 index 0000000..6cc8b74 --- /dev/null +++ b/ent/http/handler.go @@ -0,0 +1,185 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "strings" + "t/ent" + + "github.com/go-chi/chi/v5" + "go.uber.org/zap" +) + +// NewHandler returns a ready to use handler with all generated endpoints mounted. +func NewHandler(c *ent.Client, l *zap.Logger) chi.Router { + r := chi.NewRouter() + MountRoutes(c, l, r) + return r +} + +// MountRoutes mounts all generated routes on the given router. +func MountRoutes(c *ent.Client, l *zap.Logger, r chi.Router) { + NewCompartmentHandler(c, l).MountRoutes(r) + NewEntryHandler(c, l).MountRoutes(r) + NewFridgeHandler(c, l).MountRoutes(r) + NewItemHandler(c, l).MountRoutes(r) +} + +// CompartmentHandler handles http crud operations on ent.Compartment. +type CompartmentHandler struct { + client *ent.Client + log *zap.Logger +} + +func NewCompartmentHandler(c *ent.Client, l *zap.Logger) *CompartmentHandler { + return &CompartmentHandler{ + client: c, + log: l.With(zap.String("handler", "CompartmentHandler")), + } +} +func (h *CompartmentHandler) MountCreateRoute(r chi.Router) *CompartmentHandler { + r.Post("/compartments", h.Create) + return h +} +func (h *CompartmentHandler) MountReadRoute(r chi.Router) *CompartmentHandler { + r.Get("/compartments/{id}", h.Read) + return h +} +func (h *CompartmentHandler) MountUpdateRoute(r chi.Router) *CompartmentHandler { + r.Patch("/compartments/{id}", h.Update) + return h +} +func (h *CompartmentHandler) MountDeleteRoute(r chi.Router) *CompartmentHandler { + r.Delete("/compartments/{id}", h.Delete) + return h +} +func (h *CompartmentHandler) MountListRoute(r chi.Router) *CompartmentHandler { + r.Get("/compartments", h.List) + return h +} +func (h *CompartmentHandler) MountRoutes(r chi.Router) { + h.MountCreateRoute(r).MountReadRoute(r).MountUpdateRoute(r).MountDeleteRoute(r).MountListRoute(r) +} + +// EntryHandler handles http crud operations on ent.Entry. +type EntryHandler struct { + client *ent.Client + log *zap.Logger +} + +func NewEntryHandler(c *ent.Client, l *zap.Logger) *EntryHandler { + return &EntryHandler{ + client: c, + log: l.With(zap.String("handler", "EntryHandler")), + } +} +func (h *EntryHandler) MountCreateRoute(r chi.Router) *EntryHandler { + r.Post("/entries", h.Create) + return h +} +func (h *EntryHandler) MountReadRoute(r chi.Router) *EntryHandler { + r.Get("/entries/{id}", h.Read) + return h +} +func (h *EntryHandler) MountUpdateRoute(r chi.Router) *EntryHandler { + r.Patch("/entries/{id}", h.Update) + return h +} +func (h *EntryHandler) MountDeleteRoute(r chi.Router) *EntryHandler { + r.Delete("/entries/{id}", h.Delete) + return h +} +func (h *EntryHandler) MountListRoute(r chi.Router) *EntryHandler { + r.Get("/entries", h.List) + return h +} +func (h *EntryHandler) MountRoutes(r chi.Router) { + h.MountCreateRoute(r).MountReadRoute(r).MountUpdateRoute(r).MountDeleteRoute(r).MountListRoute(r) +} + +// FridgeHandler handles http crud operations on ent.Fridge. +type FridgeHandler struct { + client *ent.Client + log *zap.Logger +} + +func NewFridgeHandler(c *ent.Client, l *zap.Logger) *FridgeHandler { + return &FridgeHandler{ + client: c, + log: l.With(zap.String("handler", "FridgeHandler")), + } +} +func (h *FridgeHandler) MountCreateRoute(r chi.Router) *FridgeHandler { + r.Post("/fridges", h.Create) + return h +} +func (h *FridgeHandler) MountReadRoute(r chi.Router) *FridgeHandler { + r.Get("/fridges/{id}", h.Read) + return h +} +func (h *FridgeHandler) MountUpdateRoute(r chi.Router) *FridgeHandler { + r.Patch("/fridges/{id}", h.Update) + return h +} +func (h *FridgeHandler) MountDeleteRoute(r chi.Router) *FridgeHandler { + r.Delete("/fridges/{id}", h.Delete) + return h +} +func (h *FridgeHandler) MountListRoute(r chi.Router) *FridgeHandler { + r.Get("/fridges", h.List) + return h +} +func (h *FridgeHandler) MountRoutes(r chi.Router) { + h.MountCreateRoute(r).MountReadRoute(r).MountUpdateRoute(r).MountDeleteRoute(r).MountListRoute(r) +} + +// ItemHandler handles http crud operations on ent.Item. +type ItemHandler struct { + client *ent.Client + log *zap.Logger +} + +func NewItemHandler(c *ent.Client, l *zap.Logger) *ItemHandler { + return &ItemHandler{ + client: c, + log: l.With(zap.String("handler", "ItemHandler")), + } +} +func (h *ItemHandler) MountCreateRoute(r chi.Router) *ItemHandler { + r.Post("/items", h.Create) + return h +} +func (h *ItemHandler) MountReadRoute(r chi.Router) *ItemHandler { + r.Get("/items/{id}", h.Read) + return h +} +func (h *ItemHandler) MountUpdateRoute(r chi.Router) *ItemHandler { + r.Patch("/items/{id}", h.Update) + return h +} +func (h *ItemHandler) MountDeleteRoute(r chi.Router) *ItemHandler { + r.Delete("/items/{id}", h.Delete) + return h +} +func (h *ItemHandler) MountListRoute(r chi.Router) *ItemHandler { + r.Get("/items", h.List) + return h +} +func (h *ItemHandler) MountRoutes(r chi.Router) { + h.MountCreateRoute(r).MountReadRoute(r).MountUpdateRoute(r).MountDeleteRoute(r).MountListRoute(r) +} + +func stripEntError(err error) string { + return strings.TrimPrefix(err.Error(), "ent: ") +} + +func zapFields(errs map[string]string) []zap.Field { + if errs == nil || len(errs) == 0 { + return nil + } + r := make([]zap.Field, 0) + for k, v := range errs { + r = append(r, zap.String(k, v)) + } + return r +} diff --git a/ent/http/list.go b/ent/http/list.go new file mode 100644 index 0000000..e79fa63 --- /dev/null +++ b/ent/http/list.go @@ -0,0 +1,147 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strconv" + + "github.com/mailru/easyjson" + "go.uber.org/zap" +) + +// Read fetches the ent.Compartment identified by a given url-parameter from the +// database and returns it to the client. +func (h *CompartmentHandler) List(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "List")) + q := h.client.Compartment.Query() + var err error + page := 1 + if d := r.URL.Query().Get("page"); d != "" { + page, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'page'", zap.String("page", d), zap.Error(err)) + BadRequest(w, "page must be an integer greater zero") + return + } + } + itemsPerPage := 30 + if d := r.URL.Query().Get("itemsPerPage"); d != "" { + itemsPerPage, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'itemsPerPage'", zap.String("itemsPerPage", d), zap.Error(err)) + BadRequest(w, "itemsPerPage must be an integer greater zero") + return + } + } + es, err := q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage).All(r.Context()) + if err != nil { + l.Error("error fetching compartments from db", zap.Error(err)) + InternalServerError(w, nil) + return + } + l.Info("compartments rendered", zap.Int("amount", len(es))) + easyjson.MarshalToHTTPResponseWriter(NewCompartment3324871446Views(es), w) +} + +// Read fetches the ent.Entry identified by a given url-parameter from the +// database and returns it to the client. +func (h *EntryHandler) List(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "List")) + q := h.client.Entry.Query() + var err error + page := 1 + if d := r.URL.Query().Get("page"); d != "" { + page, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'page'", zap.String("page", d), zap.Error(err)) + BadRequest(w, "page must be an integer greater zero") + return + } + } + itemsPerPage := 30 + if d := r.URL.Query().Get("itemsPerPage"); d != "" { + itemsPerPage, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'itemsPerPage'", zap.String("itemsPerPage", d), zap.Error(err)) + BadRequest(w, "itemsPerPage must be an integer greater zero") + return + } + } + es, err := q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage).All(r.Context()) + if err != nil { + l.Error("error fetching entries from db", zap.Error(err)) + InternalServerError(w, nil) + return + } + l.Info("entries rendered", zap.Int("amount", len(es))) + easyjson.MarshalToHTTPResponseWriter(NewEntry2675665849Views(es), w) +} + +// Read fetches the ent.Fridge identified by a given url-parameter from the +// database and returns it to the client. +func (h *FridgeHandler) List(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "List")) + q := h.client.Fridge.Query() + var err error + page := 1 + if d := r.URL.Query().Get("page"); d != "" { + page, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'page'", zap.String("page", d), zap.Error(err)) + BadRequest(w, "page must be an integer greater zero") + return + } + } + itemsPerPage := 30 + if d := r.URL.Query().Get("itemsPerPage"); d != "" { + itemsPerPage, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'itemsPerPage'", zap.String("itemsPerPage", d), zap.Error(err)) + BadRequest(w, "itemsPerPage must be an integer greater zero") + return + } + } + es, err := q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage).All(r.Context()) + if err != nil { + l.Error("error fetching fridges from db", zap.Error(err)) + InternalServerError(w, nil) + return + } + l.Info("fridges rendered", zap.Int("amount", len(es))) + easyjson.MarshalToHTTPResponseWriter(NewFridge2211356377Views(es), w) +} + +// Read fetches the ent.Item identified by a given url-parameter from the +// database and returns it to the client. +func (h *ItemHandler) List(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "List")) + q := h.client.Item.Query() + var err error + page := 1 + if d := r.URL.Query().Get("page"); d != "" { + page, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'page'", zap.String("page", d), zap.Error(err)) + BadRequest(w, "page must be an integer greater zero") + return + } + } + itemsPerPage := 30 + if d := r.URL.Query().Get("itemsPerPage"); d != "" { + itemsPerPage, err = strconv.Atoi(d) + if err != nil { + l.Info("error parsing query parameter 'itemsPerPage'", zap.String("itemsPerPage", d), zap.Error(err)) + BadRequest(w, "itemsPerPage must be an integer greater zero") + return + } + } + es, err := q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage).All(r.Context()) + if err != nil { + l.Error("error fetching items from db", zap.Error(err)) + InternalServerError(w, nil) + return + } + l.Info("items rendered", zap.Int("amount", len(es))) + easyjson.MarshalToHTTPResponseWriter(NewItem1548468123Views(es), w) +} diff --git a/ent/http/read.go b/ent/http/read.go new file mode 100644 index 0000000..457f1e7 --- /dev/null +++ b/ent/http/read.go @@ -0,0 +1,149 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strconv" + "t/ent" + "t/ent/compartment" + "t/ent/entry" + "t/ent/fridge" + "t/ent/item" + + "github.com/go-chi/chi/v5" + "github.com/mailru/easyjson" + "go.uber.org/zap" +) + +// Read fetches the ent.Compartment identified by a given url-parameter from the +// database and renders it to the client. +func (h *CompartmentHandler) Read(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Read")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Create the query to fetch the Compartment + q := h.client.Compartment.Query().Where(compartment.ID(id)) + e, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read compartment", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("compartment rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewCompartment3324871446View(e), w) +} + +// Read fetches the ent.Entry identified by a given url-parameter from the +// database and renders it to the client. +func (h *EntryHandler) Read(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Read")) + // ID is URL parameter. + var err error + id := chi.URLParam(r, "id") + // Create the query to fetch the Entry + q := h.client.Entry.Query().Where(entry.ID(id)) + e, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.String("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.String("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read entry", zap.Error(err), zap.String("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("entry rendered", zap.String("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewEntry2675665849View(e), w) +} + +// Read fetches the ent.Fridge identified by a given url-parameter from the +// database and renders it to the client. +func (h *FridgeHandler) Read(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Read")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Create the query to fetch the Fridge + q := h.client.Fridge.Query().Where(fridge.ID(id)) + e, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read fridge", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("fridge rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewFridge2211356377View(e), w) +} + +// Read fetches the ent.Item identified by a given url-parameter from the +// database and renders it to the client. +func (h *ItemHandler) Read(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Read")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Create the query to fetch the Item + q := h.client.Item.Query().Where(item.ID(id)) + e, err := q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could not read item", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("item rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewItem1548468123View(e), w) +} diff --git a/ent/http/relations.go b/ent/http/relations.go new file mode 100644 index 0000000..2e1e102 --- /dev/null +++ b/ent/http/relations.go @@ -0,0 +1,3 @@ +// Code generated by entc, DO NOT EDIT. + +package http diff --git a/ent/http/request.go b/ent/http/request.go new file mode 100644 index 0000000..ed56bab --- /dev/null +++ b/ent/http/request.go @@ -0,0 +1,42 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "time" +) + +// Payload of a ent.Compartment create request. +type CompartmentCreateRequest struct { +} + +// Payload of a ent.Compartment update request. +type CompartmentUpdateRequest struct { +} + +// Payload of a ent.Entry create request. +type EntryCreateRequest struct { + User *string `json:"user"` + First *int `json:"first"` + CreatedAt *time.Time `json:"created_at"` +} + +// Payload of a ent.Entry update request. +type EntryUpdateRequest struct { +} + +// Payload of a ent.Fridge create request. +type FridgeCreateRequest struct { +} + +// Payload of a ent.Fridge update request. +type FridgeUpdateRequest struct { +} + +// Payload of a ent.Item create request. +type ItemCreateRequest struct { +} + +// Payload of a ent.Item update request. +type ItemUpdateRequest struct { +} diff --git a/ent/http/response.go b/ent/http/response.go new file mode 100644 index 0000000..3099d93 --- /dev/null +++ b/ent/http/response.go @@ -0,0 +1,200 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strconv" + "t/ent" + "time" + + "github.com/mailru/easyjson" +) + +// Basic HTTP Error Response +type ErrResponse struct { + Code int `json:"code"` // http response status code + Status string `json:"status"` // user-level status message + Errors interface{} `json:"errors,omitempty"` // application-level error +} + +func (e ErrResponse) MarshalToHTTPResponseWriter(w http.ResponseWriter) (int, error) { + d, err := easyjson.Marshal(e) + if err != nil { + return 0, err + } + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Length", strconv.Itoa(len(d))) + w.WriteHeader(e.Code) + return w.Write(d) +} + +func BadRequest(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusBadRequest, + Status: http.StatusText(http.StatusBadRequest), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +func Conflict(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusConflict, + Status: http.StatusText(http.StatusConflict), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +func Forbidden(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusForbidden, + Status: http.StatusText(http.StatusForbidden), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +func InternalServerError(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusInternalServerError, + Status: http.StatusText(http.StatusInternalServerError), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +func NotFound(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusNotFound, + Status: http.StatusText(http.StatusNotFound), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +func Unauthorized(w http.ResponseWriter, msg interface{}) (int, error) { + return ErrResponse{ + Code: http.StatusUnauthorized, + Status: http.StatusText(http.StatusUnauthorized), + Errors: msg, + }.MarshalToHTTPResponseWriter(w) +} + +type ( + // Compartment3324871446View represents the data serialized for the following serialization group combinations: + // [] + Compartment3324871446View struct { + ID int `json:"id,omitempty"` + } + Compartment3324871446Views []*Compartment3324871446View +) + +func NewCompartment3324871446View(e *ent.Compartment) *Compartment3324871446View { + if e == nil { + return nil + } + return &Compartment3324871446View{ + ID: e.ID, + } +} + +func NewCompartment3324871446Views(es []*ent.Compartment) Compartment3324871446Views { + if len(es) == 0 { + return nil + } + r := make(Compartment3324871446Views, len(es)) + for i, e := range es { + r[i] = NewCompartment3324871446View(e) + } + return r +} + +type ( + // Entry2675665849View represents the data serialized for the following serialization group combinations: + // [] + Entry2675665849View struct { + ID string `json:"id,omitempty"` + User string `json:"user,omitempty"` + First int `json:"first,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + } + Entry2675665849Views []*Entry2675665849View +) + +func NewEntry2675665849View(e *ent.Entry) *Entry2675665849View { + if e == nil { + return nil + } + return &Entry2675665849View{ + ID: e.ID, + User: e.User, + First: e.First, + CreatedAt: e.CreatedAt, + } +} + +func NewEntry2675665849Views(es []*ent.Entry) Entry2675665849Views { + if len(es) == 0 { + return nil + } + r := make(Entry2675665849Views, len(es)) + for i, e := range es { + r[i] = NewEntry2675665849View(e) + } + return r +} + +type ( + // Fridge2211356377View represents the data serialized for the following serialization group combinations: + // [] + Fridge2211356377View struct { + ID int `json:"id,omitempty"` + } + Fridge2211356377Views []*Fridge2211356377View +) + +func NewFridge2211356377View(e *ent.Fridge) *Fridge2211356377View { + if e == nil { + return nil + } + return &Fridge2211356377View{ + ID: e.ID, + } +} + +func NewFridge2211356377Views(es []*ent.Fridge) Fridge2211356377Views { + if len(es) == 0 { + return nil + } + r := make(Fridge2211356377Views, len(es)) + for i, e := range es { + r[i] = NewFridge2211356377View(e) + } + return r +} + +type ( + // Item1548468123View represents the data serialized for the following serialization group combinations: + // [] + Item1548468123View struct { + ID int `json:"id,omitempty"` + } + Item1548468123Views []*Item1548468123View +) + +func NewItem1548468123View(e *ent.Item) *Item1548468123View { + if e == nil { + return nil + } + return &Item1548468123View{ + ID: e.ID, + } +} + +func NewItem1548468123Views(es []*ent.Item) Item1548468123Views { + if len(es) == 0 { + return nil + } + r := make(Item1548468123Views, len(es)) + for i, e := range es { + r[i] = NewItem1548468123View(e) + } + return r +} diff --git a/ent/http/update.go b/ent/http/update.go new file mode 100644 index 0000000..8bd6197 --- /dev/null +++ b/ent/http/update.go @@ -0,0 +1,260 @@ +// Code generated by entc, DO NOT EDIT. + +package http + +import ( + "net/http" + "strconv" + "t/ent" + "t/ent/compartment" + "t/ent/entry" + "t/ent/fridge" + "t/ent/item" + + "github.com/go-chi/chi/v5" + "github.com/mailru/easyjson" + "go.uber.org/zap" +) + +// Update updates a given ent.Compartment and saves the changes to the database. +func (h CompartmentHandler) Update(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Update")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Get the post data. + var d CompartmentUpdateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Compartment.UpdateOneID(id) + // Store in database. + e, err := b.Save(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-update-compartment", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + // Reload entry. + q := h.client.Compartment.Query().Where(compartment.ID(e.ID)) + e, err = q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-read-compartment", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("compartment rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewCompartment3324871446View(e), w) +} + +// Update updates a given ent.Entry and saves the changes to the database. +func (h EntryHandler) Update(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Update")) + // ID is URL parameter. + var err error + id := chi.URLParam(r, "id") + // Get the post data. + var d EntryUpdateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Validate the data. + errs := make(map[string]string) + if len(errs) > 0 { + l.Info("validation failed", zapFields(errs)...) + BadRequest(w, errs) + return + } + // Save the data. + b := h.client.Entry.UpdateOneID(id) + // Store in database. + e, err := b.Save(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.String("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.String("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-update-entry", zap.Error(err), zap.String("id", id)) + InternalServerError(w, nil) + } + return + } + // Reload entry. + q := h.client.Entry.Query().Where(entry.ID(e.ID)) + e, err = q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.String("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.String("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-read-entry", zap.Error(err), zap.String("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("entry rendered", zap.String("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewEntry2675665849View(e), w) +} + +// Update updates a given ent.Fridge and saves the changes to the database. +func (h FridgeHandler) Update(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Update")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Get the post data. + var d FridgeUpdateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Fridge.UpdateOneID(id) + // Store in database. + e, err := b.Save(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-update-fridge", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + // Reload entry. + q := h.client.Fridge.Query().Where(fridge.ID(e.ID)) + e, err = q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-read-fridge", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("fridge rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewFridge2211356377View(e), w) +} + +// Update updates a given ent.Item and saves the changes to the database. +func (h ItemHandler) Update(w http.ResponseWriter, r *http.Request) { + l := h.log.With(zap.String("method", "Update")) + // ID is URL parameter. + id, err := strconv.Atoi(chi.URLParam(r, "id")) + if err != nil { + l.Error("error getting id from url parameter", zap.String("id", chi.URLParam(r, "id")), zap.Error(err)) + BadRequest(w, "id must be an integer") + return + } + // Get the post data. + var d ItemUpdateRequest + if err := easyjson.UnmarshalFromReader(r.Body, &d); err != nil { + l.Error("error decoding json", zap.Error(err)) + BadRequest(w, "invalid json string") + return + } + // Save the data. + b := h.client.Item.UpdateOneID(id) + // Store in database. + e, err := b.Save(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-update-item", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + // Reload entry. + q := h.client.Item.Query().Where(item.ID(e.ID)) + e, err = q.Only(r.Context()) + if err != nil { + switch { + case ent.IsNotFound(err): + msg := stripEntError(err) + l.Info(msg, zap.Error(err), zap.Int("id", id)) + NotFound(w, msg) + case ent.IsNotSingular(err): + msg := stripEntError(err) + l.Error(msg, zap.Error(err), zap.Int("id", id)) + BadRequest(w, msg) + default: + l.Error("could-not-read-item", zap.Error(err), zap.Int("id", id)) + InternalServerError(w, nil) + } + return + } + l.Info("item rendered", zap.Int("id", id)) + easyjson.MarshalToHTTPResponseWriter(NewItem1548468123View(e), w) +} diff --git a/ent/migrate/migrate.go b/ent/migrate/migrate.go new file mode 100644 index 0000000..9bdaf52 --- /dev/null +++ b/ent/migrate/migrate.go @@ -0,0 +1,71 @@ +// Code generated by entc, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithFixture sets the foreign-key renaming option to the migration when upgrading + // ent from v0.1.0 (issue-#285). Defaults to false. + WithFixture = schema.WithFixture + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, Tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +// +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + drv := &schema.WriteDriver{ + Writer: w, + Driver: s.drv, + } + migrate, err := schema.NewMigrate(drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, Tables...) +} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go new file mode 100644 index 0000000..86e62d0 --- /dev/null +++ b/ent/migrate/schema.go @@ -0,0 +1,46 @@ +// Code generated by entc, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // UsersColumns holds the columns for the "users" table. + UsersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "user", Type: field.TypeString, Unique: true, Size: 7}, + {Name: "chara", Type: field.TypeString, Nullable: true, Default: "ponta"}, + {Name: "skill", Type: field.TypeInt, Nullable: true, Default: 7}, + {Name: "hp", Type: field.TypeInt, Nullable: true, Default: 7}, + {Name: "attack", Type: field.TypeInt, Nullable: true, Default: 8}, + {Name: "defense", Type: field.TypeInt, Nullable: true, Default: 19}, + {Name: "critical", Type: field.TypeInt, Nullable: true, Default: 7}, + {Name: "battle", Type: field.TypeInt, Nullable: true, Default: 1}, + {Name: "win", Type: field.TypeInt, Nullable: true, Default: 0}, + {Name: "day", Type: field.TypeInt, Nullable: true, Default: 0}, + {Name: "percentage", Type: field.TypeFloat64, Nullable: true, Default: 0}, + {Name: "limit", Type: field.TypeBool, Nullable: true, Default: false}, + {Name: "status", Type: field.TypeString, Nullable: true, Default: "normal"}, + {Name: "comment", Type: field.TypeString, Nullable: true, Default: ""}, + {Name: "created_at", Type: field.TypeTime, Nullable: true}, + {Name: "next", Type: field.TypeString, Nullable: true, Default: "20220617"}, + {Name: "updated_at", Type: field.TypeTime, Nullable: true}, + {Name: "url", Type: field.TypeString, Nullable: true, Default: "https://syui.cf/api"}, + } + // UsersTable holds the schema information for the "users" table. + UsersTable = &schema.Table{ + Name: "users", + Columns: UsersColumns, + PrimaryKey: []*schema.Column{UsersColumns[0]}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + UsersTable, + } +) + +func init() { +} diff --git a/ent/mutation.go b/ent/mutation.go new file mode 100644 index 0000000..978c5b5 --- /dev/null +++ b/ent/mutation.go @@ -0,0 +1,1891 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "sync" + "t/ent/predicate" + "t/ent/users" + "time" + + "entgo.io/ent" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeUsers = "Users" +) + +// UsersMutation represents an operation that mutates the Users nodes in the graph. +type UsersMutation struct { + config + op Op + typ string + id *int + user *string + chara *string + skill *int + addskill *int + hp *int + addhp *int + attack *int + addattack *int + defense *int + adddefense *int + critical *int + addcritical *int + battle *int + addbattle *int + win *int + addwin *int + day *int + addday *int + percentage *float64 + addpercentage *float64 + _limit *bool + status *string + comment *string + created_at *time.Time + next *string + updated_at *time.Time + url *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Users, error) + predicates []predicate.Users +} + +var _ ent.Mutation = (*UsersMutation)(nil) + +// usersOption allows management of the mutation configuration using functional options. +type usersOption func(*UsersMutation) + +// newUsersMutation creates new mutation for the Users entity. +func newUsersMutation(c config, op Op, opts ...usersOption) *UsersMutation { + m := &UsersMutation{ + config: c, + op: op, + typ: TypeUsers, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUsersID sets the ID field of the mutation. +func withUsersID(id int) usersOption { + return func(m *UsersMutation) { + var ( + err error + once sync.Once + value *Users + ) + m.oldValue = func(ctx context.Context) (*Users, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Users.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUsers sets the old Users of the mutation. +func withUsers(node *Users) usersOption { + return func(m *UsersMutation) { + m.oldValue = func(context.Context) (*Users, 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 UsersMutation) 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 UsersMutation) 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 *UsersMutation) 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 *UsersMutation) 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().Users.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUser sets the "user" field. +func (m *UsersMutation) SetUser(s string) { + m.user = &s +} + +// User returns the value of the "user" field in the mutation. +func (m *UsersMutation) User() (r string, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUser returns the old "user" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldUser(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUser is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUser requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUser: %w", err) + } + return oldValue.User, nil +} + +// ResetUser resets all changes to the "user" field. +func (m *UsersMutation) ResetUser() { + m.user = nil +} + +// SetChara sets the "chara" field. +func (m *UsersMutation) SetChara(s string) { + m.chara = &s +} + +// Chara returns the value of the "chara" field in the mutation. +func (m *UsersMutation) Chara() (r string, exists bool) { + v := m.chara + if v == nil { + return + } + return *v, true +} + +// OldChara returns the old "chara" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldChara(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChara is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChara requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChara: %w", err) + } + return oldValue.Chara, nil +} + +// ClearChara clears the value of the "chara" field. +func (m *UsersMutation) ClearChara() { + m.chara = nil + m.clearedFields[users.FieldChara] = struct{}{} +} + +// CharaCleared returns if the "chara" field was cleared in this mutation. +func (m *UsersMutation) CharaCleared() bool { + _, ok := m.clearedFields[users.FieldChara] + return ok +} + +// ResetChara resets all changes to the "chara" field. +func (m *UsersMutation) ResetChara() { + m.chara = nil + delete(m.clearedFields, users.FieldChara) +} + +// SetSkill sets the "skill" field. +func (m *UsersMutation) SetSkill(i int) { + m.skill = &i + m.addskill = nil +} + +// Skill returns the value of the "skill" field in the mutation. +func (m *UsersMutation) Skill() (r int, exists bool) { + v := m.skill + if v == nil { + return + } + return *v, true +} + +// OldSkill returns the old "skill" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldSkill(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSkill is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSkill requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSkill: %w", err) + } + return oldValue.Skill, nil +} + +// AddSkill adds i to the "skill" field. +func (m *UsersMutation) AddSkill(i int) { + if m.addskill != nil { + *m.addskill += i + } else { + m.addskill = &i + } +} + +// AddedSkill returns the value that was added to the "skill" field in this mutation. +func (m *UsersMutation) AddedSkill() (r int, exists bool) { + v := m.addskill + if v == nil { + return + } + return *v, true +} + +// ClearSkill clears the value of the "skill" field. +func (m *UsersMutation) ClearSkill() { + m.skill = nil + m.addskill = nil + m.clearedFields[users.FieldSkill] = struct{}{} +} + +// SkillCleared returns if the "skill" field was cleared in this mutation. +func (m *UsersMutation) SkillCleared() bool { + _, ok := m.clearedFields[users.FieldSkill] + return ok +} + +// ResetSkill resets all changes to the "skill" field. +func (m *UsersMutation) ResetSkill() { + m.skill = nil + m.addskill = nil + delete(m.clearedFields, users.FieldSkill) +} + +// SetHp sets the "hp" field. +func (m *UsersMutation) SetHp(i int) { + m.hp = &i + m.addhp = nil +} + +// Hp returns the value of the "hp" field in the mutation. +func (m *UsersMutation) Hp() (r int, exists bool) { + v := m.hp + if v == nil { + return + } + return *v, true +} + +// OldHp returns the old "hp" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldHp(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHp: %w", err) + } + return oldValue.Hp, nil +} + +// AddHp adds i to the "hp" field. +func (m *UsersMutation) AddHp(i int) { + if m.addhp != nil { + *m.addhp += i + } else { + m.addhp = &i + } +} + +// AddedHp returns the value that was added to the "hp" field in this mutation. +func (m *UsersMutation) AddedHp() (r int, exists bool) { + v := m.addhp + if v == nil { + return + } + return *v, true +} + +// ClearHp clears the value of the "hp" field. +func (m *UsersMutation) ClearHp() { + m.hp = nil + m.addhp = nil + m.clearedFields[users.FieldHp] = struct{}{} +} + +// HpCleared returns if the "hp" field was cleared in this mutation. +func (m *UsersMutation) HpCleared() bool { + _, ok := m.clearedFields[users.FieldHp] + return ok +} + +// ResetHp resets all changes to the "hp" field. +func (m *UsersMutation) ResetHp() { + m.hp = nil + m.addhp = nil + delete(m.clearedFields, users.FieldHp) +} + +// SetAttack sets the "attack" field. +func (m *UsersMutation) SetAttack(i int) { + m.attack = &i + m.addattack = nil +} + +// Attack returns the value of the "attack" field in the mutation. +func (m *UsersMutation) Attack() (r int, exists bool) { + v := m.attack + if v == nil { + return + } + return *v, true +} + +// OldAttack returns the old "attack" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldAttack(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAttack is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAttack requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAttack: %w", err) + } + return oldValue.Attack, nil +} + +// AddAttack adds i to the "attack" field. +func (m *UsersMutation) AddAttack(i int) { + if m.addattack != nil { + *m.addattack += i + } else { + m.addattack = &i + } +} + +// AddedAttack returns the value that was added to the "attack" field in this mutation. +func (m *UsersMutation) AddedAttack() (r int, exists bool) { + v := m.addattack + if v == nil { + return + } + return *v, true +} + +// ClearAttack clears the value of the "attack" field. +func (m *UsersMutation) ClearAttack() { + m.attack = nil + m.addattack = nil + m.clearedFields[users.FieldAttack] = struct{}{} +} + +// AttackCleared returns if the "attack" field was cleared in this mutation. +func (m *UsersMutation) AttackCleared() bool { + _, ok := m.clearedFields[users.FieldAttack] + return ok +} + +// ResetAttack resets all changes to the "attack" field. +func (m *UsersMutation) ResetAttack() { + m.attack = nil + m.addattack = nil + delete(m.clearedFields, users.FieldAttack) +} + +// SetDefense sets the "defense" field. +func (m *UsersMutation) SetDefense(i int) { + m.defense = &i + m.adddefense = nil +} + +// Defense returns the value of the "defense" field in the mutation. +func (m *UsersMutation) Defense() (r int, exists bool) { + v := m.defense + if v == nil { + return + } + return *v, true +} + +// OldDefense returns the old "defense" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldDefense(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefense is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefense requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefense: %w", err) + } + return oldValue.Defense, nil +} + +// AddDefense adds i to the "defense" field. +func (m *UsersMutation) AddDefense(i int) { + if m.adddefense != nil { + *m.adddefense += i + } else { + m.adddefense = &i + } +} + +// AddedDefense returns the value that was added to the "defense" field in this mutation. +func (m *UsersMutation) AddedDefense() (r int, exists bool) { + v := m.adddefense + if v == nil { + return + } + return *v, true +} + +// ClearDefense clears the value of the "defense" field. +func (m *UsersMutation) ClearDefense() { + m.defense = nil + m.adddefense = nil + m.clearedFields[users.FieldDefense] = struct{}{} +} + +// DefenseCleared returns if the "defense" field was cleared in this mutation. +func (m *UsersMutation) DefenseCleared() bool { + _, ok := m.clearedFields[users.FieldDefense] + return ok +} + +// ResetDefense resets all changes to the "defense" field. +func (m *UsersMutation) ResetDefense() { + m.defense = nil + m.adddefense = nil + delete(m.clearedFields, users.FieldDefense) +} + +// SetCritical sets the "critical" field. +func (m *UsersMutation) SetCritical(i int) { + m.critical = &i + m.addcritical = nil +} + +// Critical returns the value of the "critical" field in the mutation. +func (m *UsersMutation) Critical() (r int, exists bool) { + v := m.critical + if v == nil { + return + } + return *v, true +} + +// OldCritical returns the old "critical" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldCritical(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCritical is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCritical requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCritical: %w", err) + } + return oldValue.Critical, nil +} + +// AddCritical adds i to the "critical" field. +func (m *UsersMutation) AddCritical(i int) { + if m.addcritical != nil { + *m.addcritical += i + } else { + m.addcritical = &i + } +} + +// AddedCritical returns the value that was added to the "critical" field in this mutation. +func (m *UsersMutation) AddedCritical() (r int, exists bool) { + v := m.addcritical + if v == nil { + return + } + return *v, true +} + +// ClearCritical clears the value of the "critical" field. +func (m *UsersMutation) ClearCritical() { + m.critical = nil + m.addcritical = nil + m.clearedFields[users.FieldCritical] = struct{}{} +} + +// CriticalCleared returns if the "critical" field was cleared in this mutation. +func (m *UsersMutation) CriticalCleared() bool { + _, ok := m.clearedFields[users.FieldCritical] + return ok +} + +// ResetCritical resets all changes to the "critical" field. +func (m *UsersMutation) ResetCritical() { + m.critical = nil + m.addcritical = nil + delete(m.clearedFields, users.FieldCritical) +} + +// SetBattle sets the "battle" field. +func (m *UsersMutation) SetBattle(i int) { + m.battle = &i + m.addbattle = nil +} + +// Battle returns the value of the "battle" field in the mutation. +func (m *UsersMutation) Battle() (r int, exists bool) { + v := m.battle + if v == nil { + return + } + return *v, true +} + +// OldBattle returns the old "battle" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldBattle(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBattle is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBattle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBattle: %w", err) + } + return oldValue.Battle, nil +} + +// AddBattle adds i to the "battle" field. +func (m *UsersMutation) AddBattle(i int) { + if m.addbattle != nil { + *m.addbattle += i + } else { + m.addbattle = &i + } +} + +// AddedBattle returns the value that was added to the "battle" field in this mutation. +func (m *UsersMutation) AddedBattle() (r int, exists bool) { + v := m.addbattle + if v == nil { + return + } + return *v, true +} + +// ClearBattle clears the value of the "battle" field. +func (m *UsersMutation) ClearBattle() { + m.battle = nil + m.addbattle = nil + m.clearedFields[users.FieldBattle] = struct{}{} +} + +// BattleCleared returns if the "battle" field was cleared in this mutation. +func (m *UsersMutation) BattleCleared() bool { + _, ok := m.clearedFields[users.FieldBattle] + return ok +} + +// ResetBattle resets all changes to the "battle" field. +func (m *UsersMutation) ResetBattle() { + m.battle = nil + m.addbattle = nil + delete(m.clearedFields, users.FieldBattle) +} + +// SetWin sets the "win" field. +func (m *UsersMutation) SetWin(i int) { + m.win = &i + m.addwin = nil +} + +// Win returns the value of the "win" field in the mutation. +func (m *UsersMutation) Win() (r int, exists bool) { + v := m.win + if v == nil { + return + } + return *v, true +} + +// OldWin returns the old "win" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldWin(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWin is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWin requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWin: %w", err) + } + return oldValue.Win, nil +} + +// AddWin adds i to the "win" field. +func (m *UsersMutation) AddWin(i int) { + if m.addwin != nil { + *m.addwin += i + } else { + m.addwin = &i + } +} + +// AddedWin returns the value that was added to the "win" field in this mutation. +func (m *UsersMutation) AddedWin() (r int, exists bool) { + v := m.addwin + if v == nil { + return + } + return *v, true +} + +// ClearWin clears the value of the "win" field. +func (m *UsersMutation) ClearWin() { + m.win = nil + m.addwin = nil + m.clearedFields[users.FieldWin] = struct{}{} +} + +// WinCleared returns if the "win" field was cleared in this mutation. +func (m *UsersMutation) WinCleared() bool { + _, ok := m.clearedFields[users.FieldWin] + return ok +} + +// ResetWin resets all changes to the "win" field. +func (m *UsersMutation) ResetWin() { + m.win = nil + m.addwin = nil + delete(m.clearedFields, users.FieldWin) +} + +// SetDay sets the "day" field. +func (m *UsersMutation) SetDay(i int) { + m.day = &i + m.addday = nil +} + +// Day returns the value of the "day" field in the mutation. +func (m *UsersMutation) Day() (r int, exists bool) { + v := m.day + if v == nil { + return + } + return *v, true +} + +// OldDay returns the old "day" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldDay(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDay is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDay requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDay: %w", err) + } + return oldValue.Day, nil +} + +// AddDay adds i to the "day" field. +func (m *UsersMutation) AddDay(i int) { + if m.addday != nil { + *m.addday += i + } else { + m.addday = &i + } +} + +// AddedDay returns the value that was added to the "day" field in this mutation. +func (m *UsersMutation) AddedDay() (r int, exists bool) { + v := m.addday + if v == nil { + return + } + return *v, true +} + +// ClearDay clears the value of the "day" field. +func (m *UsersMutation) ClearDay() { + m.day = nil + m.addday = nil + m.clearedFields[users.FieldDay] = struct{}{} +} + +// DayCleared returns if the "day" field was cleared in this mutation. +func (m *UsersMutation) DayCleared() bool { + _, ok := m.clearedFields[users.FieldDay] + return ok +} + +// ResetDay resets all changes to the "day" field. +func (m *UsersMutation) ResetDay() { + m.day = nil + m.addday = nil + delete(m.clearedFields, users.FieldDay) +} + +// SetPercentage sets the "percentage" field. +func (m *UsersMutation) SetPercentage(f float64) { + m.percentage = &f + m.addpercentage = nil +} + +// Percentage returns the value of the "percentage" field in the mutation. +func (m *UsersMutation) Percentage() (r float64, exists bool) { + v := m.percentage + if v == nil { + return + } + return *v, true +} + +// OldPercentage returns the old "percentage" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldPercentage(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPercentage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPercentage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPercentage: %w", err) + } + return oldValue.Percentage, nil +} + +// AddPercentage adds f to the "percentage" field. +func (m *UsersMutation) AddPercentage(f float64) { + if m.addpercentage != nil { + *m.addpercentage += f + } else { + m.addpercentage = &f + } +} + +// AddedPercentage returns the value that was added to the "percentage" field in this mutation. +func (m *UsersMutation) AddedPercentage() (r float64, exists bool) { + v := m.addpercentage + if v == nil { + return + } + return *v, true +} + +// ClearPercentage clears the value of the "percentage" field. +func (m *UsersMutation) ClearPercentage() { + m.percentage = nil + m.addpercentage = nil + m.clearedFields[users.FieldPercentage] = struct{}{} +} + +// PercentageCleared returns if the "percentage" field was cleared in this mutation. +func (m *UsersMutation) PercentageCleared() bool { + _, ok := m.clearedFields[users.FieldPercentage] + return ok +} + +// ResetPercentage resets all changes to the "percentage" field. +func (m *UsersMutation) ResetPercentage() { + m.percentage = nil + m.addpercentage = nil + delete(m.clearedFields, users.FieldPercentage) +} + +// SetLimit sets the "limit" field. +func (m *UsersMutation) SetLimit(b bool) { + m._limit = &b +} + +// Limit returns the value of the "limit" field in the mutation. +func (m *UsersMutation) 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 Users entity. +// If the Users 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 *UsersMutation) 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 *UsersMutation) ClearLimit() { + m._limit = nil + m.clearedFields[users.FieldLimit] = struct{}{} +} + +// LimitCleared returns if the "limit" field was cleared in this mutation. +func (m *UsersMutation) LimitCleared() bool { + _, ok := m.clearedFields[users.FieldLimit] + return ok +} + +// ResetLimit resets all changes to the "limit" field. +func (m *UsersMutation) ResetLimit() { + m._limit = nil + delete(m.clearedFields, users.FieldLimit) +} + +// SetStatus sets the "status" field. +func (m *UsersMutation) SetStatus(s string) { + m.status = &s +} + +// Status returns the value of the "status" field in the mutation. +func (m *UsersMutation) Status() (r string, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ClearStatus clears the value of the "status" field. +func (m *UsersMutation) ClearStatus() { + m.status = nil + m.clearedFields[users.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *UsersMutation) StatusCleared() bool { + _, ok := m.clearedFields[users.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *UsersMutation) ResetStatus() { + m.status = nil + delete(m.clearedFields, users.FieldStatus) +} + +// SetComment sets the "comment" field. +func (m *UsersMutation) SetComment(s string) { + m.comment = &s +} + +// Comment returns the value of the "comment" field in the mutation. +func (m *UsersMutation) Comment() (r string, exists bool) { + v := m.comment + if v == nil { + return + } + return *v, true +} + +// OldComment returns the old "comment" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldComment(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldComment is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldComment requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldComment: %w", err) + } + return oldValue.Comment, nil +} + +// ClearComment clears the value of the "comment" field. +func (m *UsersMutation) ClearComment() { + m.comment = nil + m.clearedFields[users.FieldComment] = struct{}{} +} + +// CommentCleared returns if the "comment" field was cleared in this mutation. +func (m *UsersMutation) CommentCleared() bool { + _, ok := m.clearedFields[users.FieldComment] + return ok +} + +// ResetComment resets all changes to the "comment" field. +func (m *UsersMutation) ResetComment() { + m.comment = nil + delete(m.clearedFields, users.FieldComment) +} + +// SetCreatedAt sets the "created_at" field. +func (m *UsersMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UsersMutation) 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 Users entity. +// If the Users 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 *UsersMutation) 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 *UsersMutation) ClearCreatedAt() { + m.created_at = nil + m.clearedFields[users.FieldCreatedAt] = struct{}{} +} + +// CreatedAtCleared returns if the "created_at" field was cleared in this mutation. +func (m *UsersMutation) CreatedAtCleared() bool { + _, ok := m.clearedFields[users.FieldCreatedAt] + return ok +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *UsersMutation) ResetCreatedAt() { + m.created_at = nil + delete(m.clearedFields, users.FieldCreatedAt) +} + +// SetNext sets the "next" field. +func (m *UsersMutation) SetNext(s string) { + m.next = &s +} + +// Next returns the value of the "next" field in the mutation. +func (m *UsersMutation) Next() (r string, exists bool) { + v := m.next + if v == nil { + return + } + return *v, true +} + +// OldNext returns the old "next" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldNext(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNext is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNext requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNext: %w", err) + } + return oldValue.Next, nil +} + +// ClearNext clears the value of the "next" field. +func (m *UsersMutation) ClearNext() { + m.next = nil + m.clearedFields[users.FieldNext] = struct{}{} +} + +// NextCleared returns if the "next" field was cleared in this mutation. +func (m *UsersMutation) NextCleared() bool { + _, ok := m.clearedFields[users.FieldNext] + return ok +} + +// ResetNext resets all changes to the "next" field. +func (m *UsersMutation) ResetNext() { + m.next = nil + delete(m.clearedFields, users.FieldNext) +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UsersMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UsersMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ClearUpdatedAt clears the value of the "updated_at" field. +func (m *UsersMutation) ClearUpdatedAt() { + m.updated_at = nil + m.clearedFields[users.FieldUpdatedAt] = struct{}{} +} + +// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation. +func (m *UsersMutation) UpdatedAtCleared() bool { + _, ok := m.clearedFields[users.FieldUpdatedAt] + return ok +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *UsersMutation) ResetUpdatedAt() { + m.updated_at = nil + delete(m.clearedFields, users.FieldUpdatedAt) +} + +// SetURL sets the "url" field. +func (m *UsersMutation) SetURL(s string) { + m.url = &s +} + +// URL returns the value of the "url" field in the mutation. +func (m *UsersMutation) URL() (r string, exists bool) { + v := m.url + if v == nil { + return + } + return *v, true +} + +// OldURL returns the old "url" field's value of the Users entity. +// If the Users 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 *UsersMutation) OldURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldURL: %w", err) + } + return oldValue.URL, nil +} + +// ClearURL clears the value of the "url" field. +func (m *UsersMutation) ClearURL() { + m.url = nil + m.clearedFields[users.FieldURL] = struct{}{} +} + +// URLCleared returns if the "url" field was cleared in this mutation. +func (m *UsersMutation) URLCleared() bool { + _, ok := m.clearedFields[users.FieldURL] + return ok +} + +// ResetURL resets all changes to the "url" field. +func (m *UsersMutation) ResetURL() { + m.url = nil + delete(m.clearedFields, users.FieldURL) +} + +// Where appends a list predicates to the UsersMutation builder. +func (m *UsersMutation) Where(ps ...predicate.Users) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *UsersMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Users). +func (m *UsersMutation) 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 *UsersMutation) Fields() []string { + fields := make([]string, 0, 18) + if m.user != nil { + fields = append(fields, users.FieldUser) + } + if m.chara != nil { + fields = append(fields, users.FieldChara) + } + if m.skill != nil { + fields = append(fields, users.FieldSkill) + } + if m.hp != nil { + fields = append(fields, users.FieldHp) + } + if m.attack != nil { + fields = append(fields, users.FieldAttack) + } + if m.defense != nil { + fields = append(fields, users.FieldDefense) + } + if m.critical != nil { + fields = append(fields, users.FieldCritical) + } + if m.battle != nil { + fields = append(fields, users.FieldBattle) + } + if m.win != nil { + fields = append(fields, users.FieldWin) + } + if m.day != nil { + fields = append(fields, users.FieldDay) + } + if m.percentage != nil { + fields = append(fields, users.FieldPercentage) + } + if m._limit != nil { + fields = append(fields, users.FieldLimit) + } + if m.status != nil { + fields = append(fields, users.FieldStatus) + } + if m.comment != nil { + fields = append(fields, users.FieldComment) + } + if m.created_at != nil { + fields = append(fields, users.FieldCreatedAt) + } + if m.next != nil { + fields = append(fields, users.FieldNext) + } + if m.updated_at != nil { + fields = append(fields, users.FieldUpdatedAt) + } + if m.url != nil { + fields = append(fields, users.FieldURL) + } + 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 *UsersMutation) Field(name string) (ent.Value, bool) { + switch name { + case users.FieldUser: + return m.User() + case users.FieldChara: + return m.Chara() + case users.FieldSkill: + return m.Skill() + case users.FieldHp: + return m.Hp() + case users.FieldAttack: + return m.Attack() + case users.FieldDefense: + return m.Defense() + case users.FieldCritical: + return m.Critical() + case users.FieldBattle: + return m.Battle() + case users.FieldWin: + return m.Win() + case users.FieldDay: + return m.Day() + case users.FieldPercentage: + return m.Percentage() + case users.FieldLimit: + return m.Limit() + case users.FieldStatus: + return m.Status() + case users.FieldComment: + return m.Comment() + case users.FieldCreatedAt: + return m.CreatedAt() + case users.FieldNext: + return m.Next() + case users.FieldUpdatedAt: + return m.UpdatedAt() + case users.FieldURL: + return m.URL() + } + 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 *UsersMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case users.FieldUser: + return m.OldUser(ctx) + case users.FieldChara: + return m.OldChara(ctx) + case users.FieldSkill: + return m.OldSkill(ctx) + case users.FieldHp: + return m.OldHp(ctx) + case users.FieldAttack: + return m.OldAttack(ctx) + case users.FieldDefense: + return m.OldDefense(ctx) + case users.FieldCritical: + return m.OldCritical(ctx) + case users.FieldBattle: + return m.OldBattle(ctx) + case users.FieldWin: + return m.OldWin(ctx) + case users.FieldDay: + return m.OldDay(ctx) + case users.FieldPercentage: + return m.OldPercentage(ctx) + case users.FieldLimit: + return m.OldLimit(ctx) + case users.FieldStatus: + return m.OldStatus(ctx) + case users.FieldComment: + return m.OldComment(ctx) + case users.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case users.FieldNext: + return m.OldNext(ctx) + case users.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case users.FieldURL: + return m.OldURL(ctx) + } + return nil, fmt.Errorf("unknown Users 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 *UsersMutation) SetField(name string, value ent.Value) error { + switch name { + case users.FieldUser: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUser(v) + return nil + case users.FieldChara: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChara(v) + return nil + case users.FieldSkill: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSkill(v) + return nil + case users.FieldHp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHp(v) + return nil + case users.FieldAttack: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAttack(v) + return nil + case users.FieldDefense: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefense(v) + return nil + case users.FieldCritical: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCritical(v) + return nil + case users.FieldBattle: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBattle(v) + return nil + case users.FieldWin: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWin(v) + return nil + case users.FieldDay: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDay(v) + return nil + case users.FieldPercentage: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPercentage(v) + return nil + case users.FieldLimit: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLimit(v) + return nil + case users.FieldStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case users.FieldComment: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetComment(v) + return nil + case users.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case users.FieldNext: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNext(v) + return nil + case users.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case users.FieldURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetURL(v) + return nil + } + return fmt.Errorf("unknown Users field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UsersMutation) AddedFields() []string { + var fields []string + if m.addskill != nil { + fields = append(fields, users.FieldSkill) + } + if m.addhp != nil { + fields = append(fields, users.FieldHp) + } + if m.addattack != nil { + fields = append(fields, users.FieldAttack) + } + if m.adddefense != nil { + fields = append(fields, users.FieldDefense) + } + if m.addcritical != nil { + fields = append(fields, users.FieldCritical) + } + if m.addbattle != nil { + fields = append(fields, users.FieldBattle) + } + if m.addwin != nil { + fields = append(fields, users.FieldWin) + } + if m.addday != nil { + fields = append(fields, users.FieldDay) + } + if m.addpercentage != nil { + fields = append(fields, users.FieldPercentage) + } + 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 *UsersMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case users.FieldSkill: + return m.AddedSkill() + case users.FieldHp: + return m.AddedHp() + case users.FieldAttack: + return m.AddedAttack() + case users.FieldDefense: + return m.AddedDefense() + case users.FieldCritical: + return m.AddedCritical() + case users.FieldBattle: + return m.AddedBattle() + case users.FieldWin: + return m.AddedWin() + case users.FieldDay: + return m.AddedDay() + case users.FieldPercentage: + return m.AddedPercentage() + } + 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 *UsersMutation) AddField(name string, value ent.Value) error { + switch name { + case users.FieldSkill: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSkill(v) + return nil + case users.FieldHp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHp(v) + return nil + case users.FieldAttack: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAttack(v) + return nil + case users.FieldDefense: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDefense(v) + return nil + case users.FieldCritical: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCritical(v) + return nil + case users.FieldBattle: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddBattle(v) + return nil + case users.FieldWin: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddWin(v) + return nil + case users.FieldDay: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDay(v) + return nil + case users.FieldPercentage: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPercentage(v) + return nil + } + return fmt.Errorf("unknown Users numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UsersMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(users.FieldChara) { + fields = append(fields, users.FieldChara) + } + if m.FieldCleared(users.FieldSkill) { + fields = append(fields, users.FieldSkill) + } + if m.FieldCleared(users.FieldHp) { + fields = append(fields, users.FieldHp) + } + if m.FieldCleared(users.FieldAttack) { + fields = append(fields, users.FieldAttack) + } + if m.FieldCleared(users.FieldDefense) { + fields = append(fields, users.FieldDefense) + } + if m.FieldCleared(users.FieldCritical) { + fields = append(fields, users.FieldCritical) + } + if m.FieldCleared(users.FieldBattle) { + fields = append(fields, users.FieldBattle) + } + if m.FieldCleared(users.FieldWin) { + fields = append(fields, users.FieldWin) + } + if m.FieldCleared(users.FieldDay) { + fields = append(fields, users.FieldDay) + } + if m.FieldCleared(users.FieldPercentage) { + fields = append(fields, users.FieldPercentage) + } + if m.FieldCleared(users.FieldLimit) { + fields = append(fields, users.FieldLimit) + } + if m.FieldCleared(users.FieldStatus) { + fields = append(fields, users.FieldStatus) + } + if m.FieldCleared(users.FieldComment) { + fields = append(fields, users.FieldComment) + } + if m.FieldCleared(users.FieldCreatedAt) { + fields = append(fields, users.FieldCreatedAt) + } + if m.FieldCleared(users.FieldNext) { + fields = append(fields, users.FieldNext) + } + if m.FieldCleared(users.FieldUpdatedAt) { + fields = append(fields, users.FieldUpdatedAt) + } + if m.FieldCleared(users.FieldURL) { + fields = append(fields, users.FieldURL) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UsersMutation) 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 *UsersMutation) ClearField(name string) error { + switch name { + case users.FieldChara: + m.ClearChara() + return nil + case users.FieldSkill: + m.ClearSkill() + return nil + case users.FieldHp: + m.ClearHp() + return nil + case users.FieldAttack: + m.ClearAttack() + return nil + case users.FieldDefense: + m.ClearDefense() + return nil + case users.FieldCritical: + m.ClearCritical() + return nil + case users.FieldBattle: + m.ClearBattle() + return nil + case users.FieldWin: + m.ClearWin() + return nil + case users.FieldDay: + m.ClearDay() + return nil + case users.FieldPercentage: + m.ClearPercentage() + return nil + case users.FieldLimit: + m.ClearLimit() + return nil + case users.FieldStatus: + m.ClearStatus() + return nil + case users.FieldComment: + m.ClearComment() + return nil + case users.FieldCreatedAt: + m.ClearCreatedAt() + return nil + case users.FieldNext: + m.ClearNext() + return nil + case users.FieldUpdatedAt: + m.ClearUpdatedAt() + return nil + case users.FieldURL: + m.ClearURL() + return nil + } + return fmt.Errorf("unknown Users 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 *UsersMutation) ResetField(name string) error { + switch name { + case users.FieldUser: + m.ResetUser() + return nil + case users.FieldChara: + m.ResetChara() + return nil + case users.FieldSkill: + m.ResetSkill() + return nil + case users.FieldHp: + m.ResetHp() + return nil + case users.FieldAttack: + m.ResetAttack() + return nil + case users.FieldDefense: + m.ResetDefense() + return nil + case users.FieldCritical: + m.ResetCritical() + return nil + case users.FieldBattle: + m.ResetBattle() + return nil + case users.FieldWin: + m.ResetWin() + return nil + case users.FieldDay: + m.ResetDay() + return nil + case users.FieldPercentage: + m.ResetPercentage() + return nil + case users.FieldLimit: + m.ResetLimit() + return nil + case users.FieldStatus: + m.ResetStatus() + return nil + case users.FieldComment: + m.ResetComment() + return nil + case users.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case users.FieldNext: + m.ResetNext() + return nil + case users.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case users.FieldURL: + m.ResetURL() + return nil + } + return fmt.Errorf("unknown Users field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UsersMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UsersMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UsersMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UsersMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UsersMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UsersMutation) EdgeCleared(name string) bool { + 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 *UsersMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Users 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 *UsersMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Users edge %s", name) +} diff --git a/ent/ogent/oas_cfg_gen.go b/ent/ogent/oas_cfg_gen.go new file mode 100644 index 0000000..f48a967 --- /dev/null +++ b/ent/ogent/oas_cfg_gen.go @@ -0,0 +1,165 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +// bufPool is pool of bytes.Buffer for encoding and decoding. +var bufPool = &sync.Pool{ + New: func() interface{} { + return new(bytes.Buffer) + }, +} + +// getBuf returns buffer from pool. +func getBuf() *bytes.Buffer { + return bufPool.Get().(*bytes.Buffer) +} + +// putBuf puts buffer to pool. +func putBuf(b *bytes.Buffer) { + b.Reset() + bufPool.Put(b) +} + +type config struct { + TracerProvider trace.TracerProvider + Tracer trace.Tracer + MeterProvider metric.MeterProvider + Meter metric.Meter + Client ht.Client + NotFound http.HandlerFunc +} + +func newConfig(opts ...Option) config { + cfg := config{ + TracerProvider: otel.GetTracerProvider(), + MeterProvider: metric.NewNoopMeterProvider(), + Client: http.DefaultClient, + NotFound: http.NotFound, + } + for _, opt := range opts { + opt.apply(&cfg) + } + cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name, + trace.WithInstrumentationVersion(otelogen.SemVersion()), + ) + cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name) + return cfg +} + +type Option interface { + apply(*config) +} + +type optionFunc func(*config) + +func (o optionFunc) apply(c *config) { + o(c) +} + +// WithTracerProvider specifies a tracer provider to use for creating a tracer. +// +// If none is specified, the global provider is used. +func WithTracerProvider(provider trace.TracerProvider) Option { + return optionFunc(func(cfg *config) { + if provider != nil { + cfg.TracerProvider = provider + } + }) +} + +// WithMeterProvider specifies a meter provider to use for creating a meter. +// +// If none is specified, the metric.NewNoopMeterProvider is used. +func WithMeterProvider(provider metric.MeterProvider) Option { + return optionFunc(func(cfg *config) { + if provider != nil { + cfg.MeterProvider = provider + } + }) +} + +// WithClient specifies http client to use. +func WithClient(client ht.Client) Option { + return optionFunc(func(cfg *config) { + if client != nil { + cfg.Client = client + } + }) +} + +// WithNotFound specifies http handler to use. +func WithNotFound(notFound http.HandlerFunc) Option { + return optionFunc(func(cfg *config) { + if notFound != nil { + cfg.NotFound = notFound + } + }) +} diff --git a/ent/ogent/oas_client_gen.go b/ent/ogent/oas_client_gen.go new file mode 100644 index 0000000..5380c2a --- /dev/null +++ b/ent/ogent/oas_client_gen.go @@ -0,0 +1,564 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +// Client implements OAS client. +type Client struct { + serverURL *url.URL + cfg config + requests metric.Int64Counter + errors metric.Int64Counter + duration metric.Int64Histogram +} + +// NewClient initializes new Client defined by OAS. +func NewClient(serverURL string, opts ...Option) (*Client, error) { + u, err := url.Parse(serverURL) + if err != nil { + return nil, err + } + c := &Client{ + cfg: newConfig(opts...), + serverURL: u, + } + if c.requests, err = c.cfg.Meter.NewInt64Counter(otelogen.ClientRequestCount); err != nil { + return nil, err + } + if c.errors, err = c.cfg.Meter.NewInt64Counter(otelogen.ClientErrorsCount); err != nil { + return nil, err + } + if c.duration, err = c.cfg.Meter.NewInt64Histogram(otelogen.ClientDuration); err != nil { + return nil, err + } + return c, nil +} + +// CreateUsers invokes createUsers operation. +// +// Creates a new Users and persists it to storage. +// +// POST /users +func (c *Client) CreateUsers(ctx context.Context, request CreateUsersReq) (res CreateUsersRes, err error) { + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createUsers"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "CreateUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + var ( + contentType string + reqBody io.Reader + ) + contentType = "application/json" + buf, err := encodeCreateUsersRequestJSON(request, span) + if err != nil { + return res, err + } + defer jx.PutEncoder(buf) + reqBody = bytes.NewReader(buf.Bytes()) + + u := uri.Clone(c.serverURL) + u.Path += "/users" + + r := ht.NewRequest(ctx, "POST", u, reqBody) + defer ht.PutRequest(r) + + r.Header.Set("Content-Type", contentType) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeCreateUsersResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// DeleteUsers invokes deleteUsers operation. +// +// Deletes the Users with the requested ID. +// +// DELETE /users/{id} +func (c *Client) DeleteUsers(ctx context.Context, params DeleteUsersParams) (res DeleteUsersRes, err error) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("deleteUsers"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "DeleteUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + u := uri.Clone(c.serverURL) + 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() + } + + r := ht.NewRequest(ctx, "DELETE", u, nil) + defer ht.PutRequest(r) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeDeleteUsersResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// DrawDone invokes drawDone operation. +// +// PUT /users/{id}/d +func (c *Client) DrawDone(ctx context.Context, params DrawDoneParams) (res DrawDoneNoContent, err error) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("drawDone"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "DrawDone", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + u := uri.Clone(c.serverURL) + 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 += "/d" + + r := ht.NewRequest(ctx, "PUT", u, nil) + defer ht.PutRequest(r) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeDrawDoneResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// DrawStart invokes drawStart operation. +// +// PATCH /users/{id}/start +func (c *Client) DrawStart(ctx context.Context, params DrawStartParams) (res DrawStartNoContent, err error) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("drawStart"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "DrawStart", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + u := uri.Clone(c.serverURL) + 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 += "/start" + + r := ht.NewRequest(ctx, "PATCH", u, nil) + defer ht.PutRequest(r) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeDrawStartResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// ListUsers invokes listUsers operation. +// +// List Users. +// +// GET /users +func (c *Client) ListUsers(ctx context.Context, params ListUsersParams) (res ListUsersRes, err error) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUsers"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "ListUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + u := uri.Clone(c.serverURL) + u.Path += "/users" + + q := u.Query() + { + // Encode "page" parameter. + e := uri.NewQueryEncoder(uri.QueryEncoderConfig{ + Style: uri.QueryStyleForm, + Explode: true, + }) + if err := func() 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") + } + q["page"] = e.Result() + } + { + // Encode "itemsPerPage" parameter. + e := uri.NewQueryEncoder(uri.QueryEncoderConfig{ + Style: uri.QueryStyleForm, + Explode: true, + }) + if err := func() 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") + } + q["itemsPerPage"] = e.Result() + } + u.RawQuery = q.Encode() + + r := ht.NewRequest(ctx, "GET", u, nil) + defer ht.PutRequest(r) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeListUsersResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// ReadUsers invokes readUsers operation. +// +// Finds the Users with the requested ID and returns it. +// +// GET /users/{id} +func (c *Client) ReadUsers(ctx context.Context, params ReadUsersParams) (res ReadUsersRes, err error) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUsers"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "ReadUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + u := uri.Clone(c.serverURL) + 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() + } + + r := ht.NewRequest(ctx, "GET", u, nil) + defer ht.PutRequest(r) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeReadUsersResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// UpdateUsers invokes updateUsers operation. +// +// Updates a Users and persists changes to storage. +// +// PATCH /users/{id} +func (c *Client) UpdateUsers(ctx context.Context, request UpdateUsersReq, params UpdateUsersParams) (res UpdateUsersRes, err error) { + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateUsers"), + } + ctx, span := c.cfg.Tracer.Start(ctx, "UpdateUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindClient), + ) + defer func() { + if err != nil { + span.RecordError(err) + c.errors.Add(ctx, 1, otelAttrs...) + } else { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + } + span.End() + }() + c.requests.Add(ctx, 1, otelAttrs...) + var ( + contentType string + reqBody io.Reader + ) + contentType = "application/json" + buf, err := encodeUpdateUsersRequestJSON(request, span) + if err != nil { + return res, err + } + defer jx.PutEncoder(buf) + reqBody = bytes.NewReader(buf.Bytes()) + + u := uri.Clone(c.serverURL) + 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() + } + + r := ht.NewRequest(ctx, "PATCH", u, reqBody) + defer ht.PutRequest(r) + + r.Header.Set("Content-Type", contentType) + + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + result, err := decodeUpdateUsersResponse(resp, span) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} diff --git a/ent/ogent/oas_defaults_gen.go b/ent/ogent/oas_defaults_gen.go new file mode 100644 index 0000000..384bf65 --- /dev/null +++ b/ent/ogent/oas_defaults_gen.go @@ -0,0 +1,71 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) diff --git a/ent/ogent/oas_handlers_gen.go b/ent/ogent/oas_handlers_gen.go new file mode 100644 index 0000000..55e1034 --- /dev/null +++ b/ent/ogent/oas_handlers_gen.go @@ -0,0 +1,390 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +// HandleCreateUsersRequest handles createUsers operation. +// +// POST /users +func (s *Server) handleCreateUsersRequest(args [0]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createUsers"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + request, err := decodeCreateUsersRequest(r, span) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.CreateUsers(ctx, request) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeCreateUsersResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleDeleteUsersRequest handles deleteUsers operation. +// +// DELETE /users/{id} +func (s *Server) handleDeleteUsersRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("deleteUsers"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeDeleteUsersParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.DeleteUsers(ctx, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeDeleteUsersResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleDrawDoneRequest handles drawDone operation. +// +// PUT /users/{id}/d +func (s *Server) handleDrawDoneRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("drawDone"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "DrawDone", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeDrawDoneParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.DrawDone(ctx, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeDrawDoneResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleDrawStartRequest handles drawStart operation. +// +// PATCH /users/{id}/start +func (s *Server) handleDrawStartRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("drawStart"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "DrawStart", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeDrawStartParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.DrawStart(ctx, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeDrawStartResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleListUsersRequest handles listUsers operation. +// +// GET /users +func (s *Server) handleListUsersRequest(args [0]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listUsers"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeListUsersParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.ListUsers(ctx, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeListUsersResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleReadUsersRequest handles readUsers operation. +// +// GET /users/{id} +func (s *Server) handleReadUsersRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readUsers"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeReadUsersParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.ReadUsers(ctx, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeReadUsersResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +// HandleUpdateUsersRequest handles updateUsers operation. +// +// PATCH /users/{id} +func (s *Server) handleUpdateUsersRequest(args [1]string, w http.ResponseWriter, r *http.Request) { + startTime := time.Now() + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateUsers"), + } + ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateUsers", + trace.WithAttributes(otelAttrs...), + trace.WithSpanKind(trace.SpanKindServer), + ) + s.requests.Add(ctx, 1, otelAttrs...) + defer span.End() + + var err error + params, err := decodeUpdateUsersParams(args, r) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + request, err := decodeUpdateUsersRequest(r, span) + if err != nil { + s.badRequest(ctx, w, span, otelAttrs, err) + return + } + + response, err := s.h.UpdateUsers(ctx, request, params) + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Internal") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusInternalServerError, err) + return + } + + if err := encodeUpdateUsersResponse(response, w, span); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, "Response") + s.errors.Add(ctx, 1, otelAttrs...) + return + } + span.SetStatus(codes.Ok, "Ok") + elapsedDuration := time.Since(startTime) + s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) +} + +func (s *Server) badRequest(ctx context.Context, w http.ResponseWriter, span trace.Span, otelAttrs []attribute.KeyValue, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, "BadRequest") + s.errors.Add(ctx, 1, otelAttrs...) + respondError(w, http.StatusBadRequest, err) +} + +func respondError(w http.ResponseWriter, code int, err error) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(code) + data, writeErr := json.Marshal(struct { + ErrorMessage string `json:"error_message"` + }{ + ErrorMessage: err.Error(), + }) + if writeErr == nil { + w.Write(data) + } +} diff --git a/ent/ogent/oas_interfaces_gen.go b/ent/ogent/oas_interfaces_gen.go new file mode 100644 index 0000000..c9afc96 --- /dev/null +++ b/ent/ogent/oas_interfaces_gen.go @@ -0,0 +1,22 @@ +// Code generated by ogen, DO NOT EDIT. +package ogent + +type CreateUsersRes interface { + createUsersRes() +} + +type DeleteUsersRes interface { + deleteUsersRes() +} + +type ListUsersRes interface { + listUsersRes() +} + +type ReadUsersRes interface { + readUsersRes() +} + +type UpdateUsersRes interface { + updateUsersRes() +} diff --git a/ent/ogent/oas_json_gen.go b/ent/ogent/oas_json_gen.go new file mode 100644 index 0000000..79344dd --- /dev/null +++ b/ent/ogent/oas_json_gen.go @@ -0,0 +1,2885 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +// Encode implements json.Marshaler. +func (s CreateUsersReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s CreateUsersReq) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("user") + e.Str(s.User) + } + { + if s.Chara.Set { + e.FieldStart("chara") + s.Chara.Encode(e) + } + } + { + if s.Skill.Set { + e.FieldStart("skill") + s.Skill.Encode(e) + } + } + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } +} + +var jsonFieldsNameOfCreateUsersReq = [18]string{ + 0: "user", + 1: "chara", + 2: "skill", + 3: "hp", + 4: "attack", + 5: "defense", + 6: "critical", + 7: "battle", + 8: "win", + 9: "day", + 10: "percentage", + 11: "limit", + 12: "status", + 13: "comment", + 14: "created_at", + 15: "next", + 16: "updated_at", + 17: "url", +} + +// Decode decodes CreateUsersReq from json. +func (s *CreateUsersReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateUsersReq to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "user": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.User = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"user\"") + } + case "chara": + if err := func() error { + s.Chara.Reset() + if err := s.Chara.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"chara\"") + } + case "skill": + if err := func() error { + s.Skill.Reset() + if err := s.Skill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill\"") + } + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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 "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 "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CreateUsersReq") + } + // 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(jsonFieldsNameOfCreateUsersReq) { + name = jsonFieldsNameOfCreateUsersReq[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 +} + +// Encode encodes ListUsersOKApplicationJSON as json. +func (s ListUsersOKApplicationJSON) Encode(e *jx.Encoder) { + unwrapped := []UsersList(s) + e.ArrStart() + for _, elem := range unwrapped { + elem.Encode(e) + } + e.ArrEnd() +} + +// Decode decodes ListUsersOKApplicationJSON from json. +func (s *ListUsersOKApplicationJSON) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListUsersOKApplicationJSON to nil") + } + var unwrapped []UsersList + if err := func() error { + unwrapped = make([]UsersList, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem UsersList + 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 = ListUsersOKApplicationJSON(unwrapped) + return nil +} + +// Encode encodes bool as json. +func (o OptBool) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Bool(bool(o.Value)) +} + +// Decode decodes bool from json. +func (o *OptBool) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBool to nil") + } + o.Set = true + v, err := d.Bool() + if err != nil { + return err + } + o.Value = bool(v) + return nil +} + +// Encode encodes time.Time as json. +func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time)) { + if !o.Set { + return + } + format(e, o.Value) +} + +// Decode decodes time.Time from json. +func (o *OptDateTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error { + if o == nil { + return errors.New("invalid: unable to decode OptDateTime to nil") + } + o.Set = true + v, err := format(d) + if err != nil { + return err + } + o.Value = v + return nil +} + +// Encode encodes float64 as json. +func (o OptFloat64) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Float64(float64(o.Value)) +} + +// Decode decodes float64 from json. +func (o *OptFloat64) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptFloat64 to nil") + } + o.Set = true + v, err := d.Float64() + if err != nil { + return err + } + o.Value = float64(v) + return nil +} + +// Encode encodes int as json. +func (o OptInt) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Int(int(o.Value)) +} + +// Decode decodes int from json. +func (o *OptInt) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptInt to nil") + } + o.Set = true + v, err := d.Int() + if err != nil { + return err + } + o.Value = int(v) + return nil +} + +// Encode encodes string as json. +func (o OptString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptString to nil") + } + o.Set = true + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// Encode implements json.Marshaler. +func (s R400) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s R400) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("code") + e.Int(s.Code) + } + { + + e.FieldStart("status") + e.Str(s.Status) + } + { + + if len(s.Errors) != 0 { + e.FieldStart("errors") + e.Raw(s.Errors) + } + } +} + +var jsonFieldsNameOfR400 = [3]string{ + 0: "code", + 1: "status", + 2: "errors", +} + +// Decode decodes R400 from json. +func (s *R400) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode R400 to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.Code = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Status = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "errors": + if err := func() error { + v, err := d.RawAppend(nil) + s.Errors = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"errors\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode R400") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + 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(jsonFieldsNameOfR400) { + name = jsonFieldsNameOfR400[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 +} + +// Encode implements json.Marshaler. +func (s R404) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s R404) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("code") + e.Int(s.Code) + } + { + + e.FieldStart("status") + e.Str(s.Status) + } + { + + if len(s.Errors) != 0 { + e.FieldStart("errors") + e.Raw(s.Errors) + } + } +} + +var jsonFieldsNameOfR404 = [3]string{ + 0: "code", + 1: "status", + 2: "errors", +} + +// Decode decodes R404 from json. +func (s *R404) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode R404 to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.Code = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Status = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "errors": + if err := func() error { + v, err := d.RawAppend(nil) + s.Errors = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"errors\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode R404") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + 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(jsonFieldsNameOfR404) { + name = jsonFieldsNameOfR404[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 +} + +// Encode implements json.Marshaler. +func (s R409) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s R409) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("code") + e.Int(s.Code) + } + { + + e.FieldStart("status") + e.Str(s.Status) + } + { + + if len(s.Errors) != 0 { + e.FieldStart("errors") + e.Raw(s.Errors) + } + } +} + +var jsonFieldsNameOfR409 = [3]string{ + 0: "code", + 1: "status", + 2: "errors", +} + +// Decode decodes R409 from json. +func (s *R409) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode R409 to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.Code = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Status = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "errors": + if err := func() error { + v, err := d.RawAppend(nil) + s.Errors = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"errors\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode R409") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + 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(jsonFieldsNameOfR409) { + name = jsonFieldsNameOfR409[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 +} + +// Encode implements json.Marshaler. +func (s R500) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s R500) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("code") + e.Int(s.Code) + } + { + + e.FieldStart("status") + e.Str(s.Status) + } + { + + if len(s.Errors) != 0 { + e.FieldStart("errors") + e.Raw(s.Errors) + } + } +} + +var jsonFieldsNameOfR500 = [3]string{ + 0: "code", + 1: "status", + 2: "errors", +} + +// Decode decodes R500 from json. +func (s *R500) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode R500 to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.Code = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Status = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "errors": + if err := func() error { + v, err := d.RawAppend(nil) + s.Errors = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"errors\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode R500") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + 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(jsonFieldsNameOfR500) { + name = jsonFieldsNameOfR500[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 +} + +// Encode implements json.Marshaler. +func (s UpdateUsersReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s UpdateUsersReq) encodeFields(e *jx.Encoder) { + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } +} + +var jsonFieldsNameOfUpdateUsersReq = [12]string{ + 0: "hp", + 1: "attack", + 2: "defense", + 3: "critical", + 4: "battle", + 5: "win", + 6: "day", + 7: "percentage", + 8: "limit", + 9: "comment", + 10: "next", + 11: "updated_at", +} + +// Decode decodes UpdateUsersReq from json. +func (s *UpdateUsersReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateUsersReq to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UpdateUsersReq") + } + + return nil +} + +// Encode implements json.Marshaler. +func (s UsersCreate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s UsersCreate) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + + e.FieldStart("user") + e.Str(s.User) + } + { + if s.Chara.Set { + e.FieldStart("chara") + s.Chara.Encode(e) + } + } + { + if s.Skill.Set { + e.FieldStart("skill") + s.Skill.Encode(e) + } + } + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } +} + +var jsonFieldsNameOfUsersCreate = [19]string{ + 0: "id", + 1: "user", + 2: "chara", + 3: "skill", + 4: "hp", + 5: "attack", + 6: "defense", + 7: "critical", + 8: "battle", + 9: "win", + 10: "day", + 11: "percentage", + 12: "limit", + 13: "status", + 14: "comment", + 15: "created_at", + 16: "next", + 17: "updated_at", + 18: "url", +} + +// Decode decodes UsersCreate from json. +func (s *UsersCreate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UsersCreate 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 "user": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.User = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"user\"") + } + case "chara": + if err := func() error { + s.Chara.Reset() + if err := s.Chara.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"chara\"") + } + case "skill": + if err := func() error { + s.Skill.Reset() + if err := s.Skill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill\"") + } + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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 "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 "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UsersCreate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000011, + 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(jsonFieldsNameOfUsersCreate) { + name = jsonFieldsNameOfUsersCreate[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 +} + +// Encode implements json.Marshaler. +func (s UsersList) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s UsersList) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + + e.FieldStart("user") + e.Str(s.User) + } + { + if s.Chara.Set { + e.FieldStart("chara") + s.Chara.Encode(e) + } + } + { + if s.Skill.Set { + e.FieldStart("skill") + s.Skill.Encode(e) + } + } + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } +} + +var jsonFieldsNameOfUsersList = [19]string{ + 0: "id", + 1: "user", + 2: "chara", + 3: "skill", + 4: "hp", + 5: "attack", + 6: "defense", + 7: "critical", + 8: "battle", + 9: "win", + 10: "day", + 11: "percentage", + 12: "limit", + 13: "status", + 14: "comment", + 15: "created_at", + 16: "next", + 17: "updated_at", + 18: "url", +} + +// Decode decodes UsersList from json. +func (s *UsersList) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UsersList 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 "user": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.User = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"user\"") + } + case "chara": + if err := func() error { + s.Chara.Reset() + if err := s.Chara.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"chara\"") + } + case "skill": + if err := func() error { + s.Skill.Reset() + if err := s.Skill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill\"") + } + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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 "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 "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UsersList") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000011, + 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(jsonFieldsNameOfUsersList) { + name = jsonFieldsNameOfUsersList[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 +} + +// Encode implements json.Marshaler. +func (s UsersRead) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s UsersRead) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + + e.FieldStart("user") + e.Str(s.User) + } + { + if s.Chara.Set { + e.FieldStart("chara") + s.Chara.Encode(e) + } + } + { + if s.Skill.Set { + e.FieldStart("skill") + s.Skill.Encode(e) + } + } + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } +} + +var jsonFieldsNameOfUsersRead = [19]string{ + 0: "id", + 1: "user", + 2: "chara", + 3: "skill", + 4: "hp", + 5: "attack", + 6: "defense", + 7: "critical", + 8: "battle", + 9: "win", + 10: "day", + 11: "percentage", + 12: "limit", + 13: "status", + 14: "comment", + 15: "created_at", + 16: "next", + 17: "updated_at", + 18: "url", +} + +// Decode decodes UsersRead from json. +func (s *UsersRead) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UsersRead 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 "user": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.User = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"user\"") + } + case "chara": + if err := func() error { + s.Chara.Reset() + if err := s.Chara.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"chara\"") + } + case "skill": + if err := func() error { + s.Skill.Reset() + if err := s.Skill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill\"") + } + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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 "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 "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UsersRead") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000011, + 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(jsonFieldsNameOfUsersRead) { + name = jsonFieldsNameOfUsersRead[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 +} + +// Encode implements json.Marshaler. +func (s UsersUpdate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s UsersUpdate) encodeFields(e *jx.Encoder) { + { + + e.FieldStart("id") + e.Int(s.ID) + } + { + + e.FieldStart("user") + e.Str(s.User) + } + { + if s.Chara.Set { + e.FieldStart("chara") + s.Chara.Encode(e) + } + } + { + if s.Skill.Set { + e.FieldStart("skill") + s.Skill.Encode(e) + } + } + { + if s.Hp.Set { + e.FieldStart("hp") + s.Hp.Encode(e) + } + } + { + if s.Attack.Set { + e.FieldStart("attack") + s.Attack.Encode(e) + } + } + { + if s.Defense.Set { + e.FieldStart("defense") + s.Defense.Encode(e) + } + } + { + if s.Critical.Set { + e.FieldStart("critical") + s.Critical.Encode(e) + } + } + { + if s.Battle.Set { + e.FieldStart("battle") + s.Battle.Encode(e) + } + } + { + if s.Win.Set { + e.FieldStart("win") + s.Win.Encode(e) + } + } + { + if s.Day.Set { + e.FieldStart("day") + s.Day.Encode(e) + } + } + { + if s.Percentage.Set { + e.FieldStart("percentage") + s.Percentage.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Comment.Set { + e.FieldStart("comment") + s.Comment.Encode(e) + } + } + { + if s.CreatedAt.Set { + e.FieldStart("created_at") + s.CreatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.Next.Set { + e.FieldStart("next") + s.Next.Encode(e) + } + } + { + if s.UpdatedAt.Set { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e, json.EncodeDateTime) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } +} + +var jsonFieldsNameOfUsersUpdate = [19]string{ + 0: "id", + 1: "user", + 2: "chara", + 3: "skill", + 4: "hp", + 5: "attack", + 6: "defense", + 7: "critical", + 8: "battle", + 9: "win", + 10: "day", + 11: "percentage", + 12: "limit", + 13: "status", + 14: "comment", + 15: "created_at", + 16: "next", + 17: "updated_at", + 18: "url", +} + +// Decode decodes UsersUpdate from json. +func (s *UsersUpdate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UsersUpdate 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 "user": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.User = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"user\"") + } + case "chara": + if err := func() error { + s.Chara.Reset() + if err := s.Chara.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"chara\"") + } + case "skill": + if err := func() error { + s.Skill.Reset() + if err := s.Skill.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill\"") + } + case "hp": + if err := func() error { + s.Hp.Reset() + if err := s.Hp.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hp\"") + } + case "attack": + if err := func() error { + s.Attack.Reset() + if err := s.Attack.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"attack\"") + } + case "defense": + if err := func() error { + s.Defense.Reset() + if err := s.Defense.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defense\"") + } + case "critical": + if err := func() error { + s.Critical.Reset() + if err := s.Critical.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"critical\"") + } + case "battle": + if err := func() error { + s.Battle.Reset() + if err := s.Battle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"battle\"") + } + case "win": + if err := func() error { + s.Win.Reset() + if err := s.Win.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"win\"") + } + case "day": + if err := func() error { + s.Day.Reset() + if err := s.Day.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"day\"") + } + case "percentage": + if err := func() error { + s.Percentage.Reset() + if err := s.Percentage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"percentage\"") + } + 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 "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "comment": + if err := func() error { + s.Comment.Reset() + if err := s.Comment.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"comment\"") + } + 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 "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 "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 "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UsersUpdate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [3]uint8{ + 0b00000011, + 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(jsonFieldsNameOfUsersUpdate) { + name = jsonFieldsNameOfUsersUpdate[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 +} diff --git a/ent/ogent/oas_param_dec_gen.go b/ent/ogent/oas_param_dec_gen.go new file mode 100644 index 0000000..9ed9615 --- /dev/null +++ b/ent/ogent/oas_param_dec_gen.go @@ -0,0 +1,339 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func decodeDeleteUsersParams(args [1]string, r *http.Request) (DeleteUsersParams, error) { + var ( + params DeleteUsersParams + ) + // Decode path: id. + { + param := args[0] + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return params, err + } + } else { + return params, errors.New("path: id: not specified") + } + } + return params, nil +} + +func decodeDrawDoneParams(args [1]string, r *http.Request) (DrawDoneParams, error) { + var ( + params DrawDoneParams + ) + // Decode path: id. + { + param := args[0] + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return params, err + } + } else { + return params, errors.New("path: id: not specified") + } + } + return params, nil +} + +func decodeDrawStartParams(args [1]string, r *http.Request) (DrawStartParams, error) { + var ( + params DrawStartParams + ) + // Decode path: id. + { + param := args[0] + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return params, err + } + } else { + return params, errors.New("path: id: not specified") + } + } + return params, nil +} + +func decodeListUsersParams(args [0]string, r *http.Request) (ListUsersParams, error) { + var ( + params ListUsersParams + queryArgs = r.URL.Query() + ) + // Decode query: page. + { + values, ok := queryArgs["page"] + if ok { + d := uri.NewQueryDecoder(uri.QueryDecoderConfig{ + Values: values, + Style: uri.QueryStyleForm, + Explode: true, + }) + + if err := func() error { + var paramsDotPageVal int + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + paramsDotPageVal = c + return nil + }(); err != nil { + return err + } + params.Page.SetTo(paramsDotPageVal) + return nil + }(); err != nil { + return params, errors.Wrap(err, "query: page: parse") + } + } + } + // Decode query: itemsPerPage. + { + values, ok := queryArgs["itemsPerPage"] + if ok { + d := uri.NewQueryDecoder(uri.QueryDecoderConfig{ + Values: values, + Style: uri.QueryStyleForm, + Explode: true, + }) + + if err := func() error { + var paramsDotItemsPerPageVal int + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + paramsDotItemsPerPageVal = c + return nil + }(); err != nil { + return err + } + params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal) + return nil + }(); err != nil { + return params, errors.Wrap(err, "query: itemsPerPage: parse") + } + } + } + return params, nil +} + +func decodeReadUsersParams(args [1]string, r *http.Request) (ReadUsersParams, error) { + var ( + params ReadUsersParams + ) + // Decode path: id. + { + param := args[0] + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return params, err + } + } else { + return params, errors.New("path: id: not specified") + } + } + return params, nil +} + +func decodeUpdateUsersParams(args [1]string, r *http.Request) (UpdateUsersParams, error) { + var ( + params UpdateUsersParams + ) + // Decode path: id. + { + param := args[0] + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + s, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(s) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return params, err + } + } else { + return params, errors.New("path: id: not specified") + } + } + return params, nil +} diff --git a/ent/ogent/oas_param_gen.go b/ent/ogent/oas_param_gen.go new file mode 100644 index 0000000..695142e --- /dev/null +++ b/ent/ogent/oas_param_gen.go @@ -0,0 +1,101 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +type DeleteUsersParams struct { + // ID of the Users. + ID int +} + +type DrawDoneParams struct { + ID int +} + +type DrawStartParams struct { + ID int +} + +type ListUsersParams struct { + // What page to render. + Page OptInt + // Item count to render per page. + ItemsPerPage OptInt +} + +type ReadUsersParams struct { + // ID of the Users. + ID int +} + +type UpdateUsersParams struct { + // ID of the Users. + ID int +} diff --git a/ent/ogent/oas_req_dec_gen.go b/ent/ogent/oas_req_dec_gen.go new file mode 100644 index 0000000..34fea94 --- /dev/null +++ b/ent/ogent/oas_req_dec_gen.go @@ -0,0 +1,159 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func decodeCreateUsersRequest(r *http.Request, span trace.Span) (req CreateUsersReq, err error) { + switch ct := r.Header.Get("Content-Type"); ct { + case "application/json": + if r.ContentLength == 0 { + return req, validate.ErrBodyRequired + } + + var request CreateUsersReq + buf := getBuf() + defer putBuf(buf) + written, err := io.Copy(buf, r.Body) + if err != nil { + return req, err + } + + if written == 0 { + return req, validate.ErrBodyRequired + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return req, errors.Wrap(err, "decode CreateUsers:application/json request") + } + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return req, errors.Wrap(err, "validate CreateUsers request") + } + return request, nil + default: + return req, validate.InvalidContentType(ct) + } +} + +func decodeUpdateUsersRequest(r *http.Request, span trace.Span) (req UpdateUsersReq, err error) { + switch ct := r.Header.Get("Content-Type"); ct { + case "application/json": + if r.ContentLength == 0 { + return req, validate.ErrBodyRequired + } + + var request UpdateUsersReq + buf := getBuf() + defer putBuf(buf) + written, err := io.Copy(buf, r.Body) + if err != nil { + return req, err + } + + if written == 0 { + return req, validate.ErrBodyRequired + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return req, errors.Wrap(err, "decode UpdateUsers:application/json request") + } + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return req, errors.Wrap(err, "validate UpdateUsers request") + } + return request, nil + default: + return req, validate.InvalidContentType(ct) + } +} diff --git a/ent/ogent/oas_req_enc_gen.go b/ent/ogent/oas_req_enc_gen.go new file mode 100644 index 0000000..62b8e62 --- /dev/null +++ b/ent/ogent/oas_req_enc_gen.go @@ -0,0 +1,87 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func encodeCreateUsersRequestJSON(req CreateUsersReq, span trace.Span) (data *jx.Encoder, err error) { + e := jx.GetEncoder() + + req.Encode(e) + + return e, nil +} + +func encodeUpdateUsersRequestJSON(req UpdateUsersReq, span trace.Span) (data *jx.Encoder, err error) { + e := jx.GetEncoder() + + req.Encode(e) + + return e, nil +} diff --git a/ent/ogent/oas_res_dec_gen.go b/ent/ogent/oas_res_dec_gen.go new file mode 100644 index 0000000..b1fe3c1 --- /dev/null +++ b/ent/ogent/oas_res_dec_gen.go @@ -0,0 +1,747 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func decodeCreateUsersResponse(resp *http.Response, span trace.Span) (res CreateUsersRes, err error) { + switch resp.StatusCode { + case 200: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response UsersCreate + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeDeleteUsersResponse(resp *http.Response, span trace.Span) (res DeleteUsersRes, err error) { + switch resp.StatusCode { + case 204: + return &DeleteUsersNoContent{}, nil + case 400: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeDrawDoneResponse(resp *http.Response, span trace.Span) (res DrawDoneNoContent, err error) { + switch resp.StatusCode { + case 204: + return DrawDoneNoContent{}, nil + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeDrawStartResponse(resp *http.Response, span trace.Span) (res DrawStartNoContent, err error) { + switch resp.StatusCode { + case 204: + return DrawStartNoContent{}, nil + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeListUsersResponse(resp *http.Response, span trace.Span) (res ListUsersRes, err error) { + switch resp.StatusCode { + case 200: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response ListUsersOKApplicationJSON + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeReadUsersResponse(resp *http.Response, span trace.Span) (res ReadUsersRes, err error) { + switch resp.StatusCode { + case 200: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response UsersRead + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} + +func decodeUpdateUsersResponse(resp *http.Response, span trace.Span) (res UpdateUsersRes, err error) { + switch resp.StatusCode { + case 200: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response UsersUpdate + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R400 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R404 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 409: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R409 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 500: + switch ct := resp.Header.Get("Content-Type"); ct { + case "application/json": + buf := getBuf() + defer putBuf(buf) + if _, err := io.Copy(buf, resp.Body); err != nil { + return res, err + } + + d := jx.GetDecoder() + defer jx.PutDecoder(d) + d.ResetBytes(buf.Bytes()) + + var response R500 + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return res, err + } + + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + default: + return res, validate.UnexpectedStatusCode(resp.StatusCode) + } +} diff --git a/ent/ogent/oas_res_enc_gen.go b/ent/ogent/oas_res_enc_gen.go new file mode 100644 index 0000000..528f774 --- /dev/null +++ b/ent/ogent/oas_res_enc_gen.go @@ -0,0 +1,395 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func encodeCreateUsersResponse(response CreateUsersRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UsersCreate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + default: + return errors.Errorf("/users"+`: unexpected response type: %T`, response) + } +} + +func encodeDeleteUsersResponse(response DeleteUsersRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *DeleteUsersNoContent: + w.WriteHeader(204) + return nil + case *R400: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(400) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + default: + return errors.Errorf("/users/{id}"+`: unexpected response type: %T`, response) + } +} + +func encodeDrawDoneResponse(response DrawDoneNoContent, w http.ResponseWriter, span trace.Span) error { + w.WriteHeader(204) + return nil +} + +func encodeDrawStartResponse(response DrawStartNoContent, w http.ResponseWriter, span trace.Span) error { + w.WriteHeader(204) + return nil +} + +func encodeListUsersResponse(response ListUsersRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListUsersOKApplicationJSON: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + default: + return errors.Errorf("/users"+`: unexpected response type: %T`, response) + } +} + +func encodeReadUsersResponse(response ReadUsersRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UsersRead: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + default: + return errors.Errorf("/users/{id}"+`: unexpected response type: %T`, response) + } +} + +func encodeUpdateUsersResponse(response UpdateUsersRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *UsersUpdate: + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + 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) + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + default: + return errors.Errorf("/users/{id}"+`: unexpected response type: %T`, response) + } +} diff --git a/ent/ogent/oas_router_gen.go b/ent/ogent/oas_router_gen.go new file mode 100644 index 0000000..8ab74ec --- /dev/null +++ b/ent/ogent/oas_router_gen.go @@ -0,0 +1,467 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func (s *Server) notFound(w http.ResponseWriter, r *http.Request) { + s.cfg.NotFound(w, r) +} + +// ServeHTTP serves http request as defined by OpenAPI v3 specification, +// calling handler that matches the path or returning not found error. +func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + elem := r.URL.Path + if len(elem) == 0 { + s.notFound(w, r) + return + } + args := [1]string{} + // Static code generated router with unwrapped path search. + switch r.Method { + case "DELETE": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Leaf parameter + args[0] = elem + elem = "" + + if len(elem) == 0 { + // Leaf: DeleteUsers + s.handleDeleteUsersRequest([1]string{ + args[0], + }, w, r) + + return + } + } + case "GET": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users" + if l := len("/users"); len(elem) >= l && elem[0:l] == "/users" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + s.handleListUsersRequest([0]string{}, w, r) + + return + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Leaf parameter + args[0] = elem + elem = "" + + if len(elem) == 0 { + // Leaf: ReadUsers + s.handleReadUsersRequest([1]string{ + args[0], + }, w, r) + + return + } + } + } + case "PATCH": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + 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 { + s.handleUpdateUsersRequest([1]string{ + args[0], + }, w, r) + + 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: DrawStart + s.handleDrawStartRequest([1]string{ + args[0], + }, w, r) + + return + } + } + } + case "POST": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users" + if l := len("/users"); len(elem) >= l && elem[0:l] == "/users" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf: CreateUsers + s.handleCreateUsersRequest([0]string{}, w, r) + + return + } + } + case "PUT": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + 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 { + break + } + switch elem[0] { + case '/': // Prefix: "/d" + if l := len("/d"); len(elem) >= l && elem[0:l] == "/d" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf: DrawDone + s.handleDrawDoneRequest([1]string{ + args[0], + }, w, r) + + return + } + } + } + } + s.notFound(w, r) +} + +// Route is route object. +type Route struct { + name string + count int + args [1]string +} + +// OperationID returns OpenAPI operationId. +func (r Route) OperationID() string { + return r.name +} + +// Args returns parsed arguments. +func (r Route) Args() []string { + return r.args[:r.count] +} + +// FindRoute finds Route for given method and path. +func (s *Server) FindRoute(method, path string) (r Route, _ bool) { + var ( + args = [1]string{} + elem = path + ) + r.args = args + if elem == "" { + return r, false + } + + // Static code generated router with unwrapped path search. + switch method { + case "DELETE": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Leaf parameter + args[0] = elem + elem = "" + + if len(elem) == 0 { + // Leaf: DeleteUsers + r.name = "DeleteUsers" + r.args = args + r.count = 1 + return r, true + } + } + case "GET": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users" + if l := len("/users"); len(elem) >= l && elem[0:l] == "/users" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + r.name = "ListUsers" + r.args = args + r.count = 0 + return r, true + } + switch elem[0] { + case '/': // Prefix: "/" + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "id" + // Leaf parameter + args[0] = elem + elem = "" + + if len(elem) == 0 { + // Leaf: ReadUsers + r.name = "ReadUsers" + r.args = args + r.count = 1 + return r, true + } + } + } + case "PATCH": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + 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 { + r.name = "UpdateUsers" + r.args = args + r.count = 1 + return r, true + } + 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: DrawStart + r.name = "DrawStart" + r.args = args + r.count = 1 + return r, true + } + } + } + case "POST": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users" + if l := len("/users"); len(elem) >= l && elem[0:l] == "/users" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf: CreateUsers + r.name = "CreateUsers" + r.args = args + r.count = 0 + return r, true + } + } + case "PUT": + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/users/" + if l := len("/users/"); len(elem) >= l && elem[0:l] == "/users/" { + 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 { + break + } + switch elem[0] { + case '/': // Prefix: "/d" + if l := len("/d"); len(elem) >= l && elem[0:l] == "/d" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf: DrawDone + r.name = "DrawDone" + r.args = args + r.count = 1 + return r, true + } + } + } + } + return r, false +} diff --git a/ent/ogent/oas_schemas_gen.go b/ent/ogent/oas_schemas_gen.go new file mode 100644 index 0000000..008eeb5 --- /dev/null +++ b/ent/ogent/oas_schemas_gen.go @@ -0,0 +1,497 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +type CreateUsersReq struct { + User string "json:\"user\"" + Chara OptString "json:\"chara\"" + Skill OptInt "json:\"skill\"" + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Status OptString "json:\"status\"" + Comment OptString "json:\"comment\"" + CreatedAt OptDateTime "json:\"created_at\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" + URL OptString "json:\"url\"" +} + +// DeleteUsersNoContent is response for DeleteUsers operation. +type DeleteUsersNoContent struct{} + +func (*DeleteUsersNoContent) deleteUsersRes() {} + +// DrawDoneNoContent is response for DrawDone operation. +type DrawDoneNoContent struct{} + +// DrawStartNoContent is response for DrawStart operation. +type DrawStartNoContent struct{} + +type ListUsersOKApplicationJSON []UsersList + +func (ListUsersOKApplicationJSON) listUsersRes() {} + +// NewOptBool returns new OptBool with value set to v. +func NewOptBool(v bool) OptBool { + return OptBool{ + Value: v, + Set: true, + } +} + +// OptBool is optional bool. +type OptBool struct { + Value bool + Set bool +} + +// IsSet returns true if OptBool was set. +func (o OptBool) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBool) Reset() { + var v bool + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBool) SetTo(v bool) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBool) Get() (v bool, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBool) Or(d bool) bool { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptDateTime returns new OptDateTime with value set to v. +func NewOptDateTime(v time.Time) OptDateTime { + return OptDateTime{ + Value: v, + Set: true, + } +} + +// OptDateTime is optional time.Time. +type OptDateTime struct { + Value time.Time + Set bool +} + +// IsSet returns true if OptDateTime was set. +func (o OptDateTime) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptDateTime) Reset() { + var v time.Time + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptDateTime) SetTo(v time.Time) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptDateTime) Get() (v time.Time, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptDateTime) Or(d time.Time) time.Time { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptFloat64 returns new OptFloat64 with value set to v. +func NewOptFloat64(v float64) OptFloat64 { + return OptFloat64{ + Value: v, + Set: true, + } +} + +// OptFloat64 is optional float64. +type OptFloat64 struct { + Value float64 + Set bool +} + +// IsSet returns true if OptFloat64 was set. +func (o OptFloat64) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptFloat64) Reset() { + var v float64 + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptFloat64) SetTo(v float64) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptFloat64) Get() (v float64, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptFloat64) Or(d float64) float64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptInt returns new OptInt with value set to v. +func NewOptInt(v int) OptInt { + return OptInt{ + Value: v, + Set: true, + } +} + +// OptInt is optional int. +type OptInt struct { + Value int + Set bool +} + +// IsSet returns true if OptInt was set. +func (o OptInt) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptInt) Reset() { + var v int + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptInt) SetTo(v int) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptInt) Get() (v int, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptInt) Or(d int) int { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptString returns new OptString with value set to v. +func NewOptString(v string) OptString { + return OptString{ + Value: v, + Set: true, + } +} + +// OptString is optional string. +type OptString struct { + Value string + Set bool +} + +// IsSet returns true if OptString was set. +func (o OptString) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptString) Reset() { + var v string + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptString) SetTo(v string) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptString) Get() (v string, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + +type R400 struct { + Code int "json:\"code\"" + Status string "json:\"status\"" + Errors jx.Raw "json:\"errors\"" +} + +func (*R400) createUsersRes() {} +func (*R400) deleteUsersRes() {} +func (*R400) listUsersRes() {} +func (*R400) readUsersRes() {} +func (*R400) updateUsersRes() {} + +type R404 struct { + Code int "json:\"code\"" + Status string "json:\"status\"" + Errors jx.Raw "json:\"errors\"" +} + +func (*R404) deleteUsersRes() {} +func (*R404) listUsersRes() {} +func (*R404) readUsersRes() {} +func (*R404) updateUsersRes() {} + +type R409 struct { + Code int "json:\"code\"" + Status string "json:\"status\"" + Errors jx.Raw "json:\"errors\"" +} + +func (*R409) createUsersRes() {} +func (*R409) deleteUsersRes() {} +func (*R409) listUsersRes() {} +func (*R409) readUsersRes() {} +func (*R409) updateUsersRes() {} + +type R500 struct { + Code int "json:\"code\"" + Status string "json:\"status\"" + Errors jx.Raw "json:\"errors\"" +} + +func (*R500) createUsersRes() {} +func (*R500) deleteUsersRes() {} +func (*R500) listUsersRes() {} +func (*R500) readUsersRes() {} +func (*R500) updateUsersRes() {} + +type UpdateUsersReq struct { + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Comment OptString "json:\"comment\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" +} + +// Ref: #/components/schemas/UsersCreate +type UsersCreate struct { + ID int "json:\"id\"" + User string "json:\"user\"" + Chara OptString "json:\"chara\"" + Skill OptInt "json:\"skill\"" + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Status OptString "json:\"status\"" + Comment OptString "json:\"comment\"" + CreatedAt OptDateTime "json:\"created_at\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" + URL OptString "json:\"url\"" +} + +func (*UsersCreate) createUsersRes() {} + +// Ref: #/components/schemas/UsersList +type UsersList struct { + ID int "json:\"id\"" + User string "json:\"user\"" + Chara OptString "json:\"chara\"" + Skill OptInt "json:\"skill\"" + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Status OptString "json:\"status\"" + Comment OptString "json:\"comment\"" + CreatedAt OptDateTime "json:\"created_at\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" + URL OptString "json:\"url\"" +} + +// Ref: #/components/schemas/UsersRead +type UsersRead struct { + ID int "json:\"id\"" + User string "json:\"user\"" + Chara OptString "json:\"chara\"" + Skill OptInt "json:\"skill\"" + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Status OptString "json:\"status\"" + Comment OptString "json:\"comment\"" + CreatedAt OptDateTime "json:\"created_at\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" + URL OptString "json:\"url\"" +} + +func (*UsersRead) readUsersRes() {} + +// Ref: #/components/schemas/UsersUpdate +type UsersUpdate struct { + ID int "json:\"id\"" + User string "json:\"user\"" + Chara OptString "json:\"chara\"" + Skill OptInt "json:\"skill\"" + Hp OptInt "json:\"hp\"" + Attack OptInt "json:\"attack\"" + Defense OptInt "json:\"defense\"" + Critical OptInt "json:\"critical\"" + Battle OptInt "json:\"battle\"" + Win OptInt "json:\"win\"" + Day OptInt "json:\"day\"" + Percentage OptFloat64 "json:\"percentage\"" + Limit OptBool "json:\"limit\"" + Status OptString "json:\"status\"" + Comment OptString "json:\"comment\"" + CreatedAt OptDateTime "json:\"created_at\"" + Next OptString "json:\"next\"" + UpdatedAt OptDateTime "json:\"updated_at\"" + URL OptString "json:\"url\"" +} + +func (*UsersUpdate) updateUsersRes() {} diff --git a/ent/ogent/oas_security_gen.go b/ent/ogent/oas_security_gen.go new file mode 100644 index 0000000..384bf65 --- /dev/null +++ b/ent/ogent/oas_security_gen.go @@ -0,0 +1,71 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) diff --git a/ent/ogent/oas_server_gen.go b/ent/ogent/oas_server_gen.go new file mode 100644 index 0000000..3e65138 --- /dev/null +++ b/ent/ogent/oas_server_gen.go @@ -0,0 +1,142 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +// Handler handles operations described by OpenAPI v3 specification. +type Handler interface { + // CreateUsers implements createUsers operation. + // + // Creates a new Users and persists it to storage. + // + // POST /users + CreateUsers(ctx context.Context, req CreateUsersReq) (CreateUsersRes, error) + // DeleteUsers implements deleteUsers operation. + // + // Deletes the Users with the requested ID. + // + // DELETE /users/{id} + DeleteUsers(ctx context.Context, params DeleteUsersParams) (DeleteUsersRes, error) + // DrawDone implements drawDone operation. + // + // PUT /users/{id}/d + DrawDone(ctx context.Context, params DrawDoneParams) (DrawDoneNoContent, error) + // DrawStart implements drawStart operation. + // + // PATCH /users/{id}/start + DrawStart(ctx context.Context, params DrawStartParams) (DrawStartNoContent, error) + // ListUsers implements listUsers operation. + // + // List Users. + // + // GET /users + ListUsers(ctx context.Context, params ListUsersParams) (ListUsersRes, error) + // ReadUsers implements readUsers operation. + // + // Finds the Users with the requested ID and returns it. + // + // GET /users/{id} + ReadUsers(ctx context.Context, params ReadUsersParams) (ReadUsersRes, error) + // UpdateUsers implements updateUsers operation. + // + // Updates a Users and persists changes to storage. + // + // PATCH /users/{id} + UpdateUsers(ctx context.Context, req UpdateUsersReq, params UpdateUsersParams) (UpdateUsersRes, error) +} + +// Server implements http server based on OpenAPI v3 specification and +// calls Handler to handle requests. +type Server struct { + h Handler + cfg config + + requests metric.Int64Counter + errors metric.Int64Counter + duration metric.Int64Histogram +} + +func NewServer(h Handler, opts ...Option) (*Server, error) { + s := &Server{ + h: h, + cfg: newConfig(opts...), + } + var err error + if s.requests, err = s.cfg.Meter.NewInt64Counter(otelogen.ServerRequestCount); err != nil { + return nil, err + } + if s.errors, err = s.cfg.Meter.NewInt64Counter(otelogen.ServerErrorsCount); err != nil { + return nil, err + } + if s.duration, err = s.cfg.Meter.NewInt64Histogram(otelogen.ServerDuration); err != nil { + return nil, err + } + return s, nil +} diff --git a/ent/ogent/oas_unimplemented_gen.go b/ent/ogent/oas_unimplemented_gen.go new file mode 100644 index 0000000..fa6427a --- /dev/null +++ b/ent/ogent/oas_unimplemented_gen.go @@ -0,0 +1,135 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +var _ Handler = UnimplementedHandler{} + +// UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented. +type UnimplementedHandler struct{} + +// CreateUsers implements createUsers operation. +// +// Creates a new Users and persists it to storage. +// +// POST /users +func (UnimplementedHandler) CreateUsers(ctx context.Context, req CreateUsersReq) (r CreateUsersRes, _ error) { + return r, ht.ErrNotImplemented +} + +// DeleteUsers implements deleteUsers operation. +// +// Deletes the Users with the requested ID. +// +// DELETE /users/{id} +func (UnimplementedHandler) DeleteUsers(ctx context.Context, params DeleteUsersParams) (r DeleteUsersRes, _ error) { + return r, ht.ErrNotImplemented +} + +// DrawDone implements drawDone operation. +// +// PUT /users/{id}/d +func (UnimplementedHandler) DrawDone(ctx context.Context, params DrawDoneParams) (r DrawDoneNoContent, _ error) { + return r, ht.ErrNotImplemented +} + +// DrawStart implements drawStart operation. +// +// PATCH /users/{id}/start +func (UnimplementedHandler) DrawStart(ctx context.Context, params DrawStartParams) (r DrawStartNoContent, _ error) { + return r, ht.ErrNotImplemented +} + +// ListUsers implements listUsers operation. +// +// List Users. +// +// GET /users +func (UnimplementedHandler) ListUsers(ctx context.Context, params ListUsersParams) (r ListUsersRes, _ error) { + return r, ht.ErrNotImplemented +} + +// ReadUsers implements readUsers operation. +// +// Finds the Users with the requested ID and returns it. +// +// GET /users/{id} +func (UnimplementedHandler) ReadUsers(ctx context.Context, params ReadUsersParams) (r ReadUsersRes, _ error) { + return r, ht.ErrNotImplemented +} + +// UpdateUsers implements updateUsers operation. +// +// Updates a Users and persists changes to storage. +// +// PATCH /users/{id} +func (UnimplementedHandler) UpdateUsers(ctx context.Context, req UpdateUsersReq, params UpdateUsersParams) (r UpdateUsersRes, _ error) { + return r, ht.ErrNotImplemented +} diff --git a/ent/ogent/oas_validators_gen.go b/ent/ogent/oas_validators_gen.go new file mode 100644 index 0000000..d9d9bec --- /dev/null +++ b/ent/ogent/oas_validators_gen.go @@ -0,0 +1,252 @@ +// Code generated by ogen, DO NOT EDIT. + +package ogent + +import ( + "bytes" + "context" + "fmt" + "io" + "math" + "math/big" + "math/bits" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/google/uuid" + "github.com/ogen-go/ogen/conv" + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/json" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" + "github.com/ogen-go/ogen/validate" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + +// No-op definition for keeping imports. +var ( + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = sort.Ints + _ = http.MethodGet + _ = io.Copy + _ = json.Marshal + _ = bytes.NewReader + _ = strconv.ParseInt + _ = time.Time{} + _ = conv.ToInt32 + _ = uuid.UUID{} + _ = uri.PathEncoder{} + _ = url.URL{} + _ = math.Mod + _ = bits.LeadingZeros64 + _ = big.Rat{} + _ = validate.Int{} + _ = ht.NewRequest + _ = net.IP{} + _ = otelogen.Version + _ = attribute.KeyValue{} + _ = trace.TraceIDFromHex + _ = otel.GetTracerProvider + _ = metric.NewNoopMeterProvider + _ = regexp.MustCompile + _ = jx.Null + _ = sync.Pool{} + _ = codes.Unset +) + +func (s CreateUsersReq) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s ListUsersOKApplicationJSON) Validate() error { + if s == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s UpdateUsersReq) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s UsersCreate) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s UsersList) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s UsersRead) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s UsersUpdate) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Percentage.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Percentage.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "percentage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} diff --git a/ent/ogent/ogent.go b/ent/ogent/ogent.go new file mode 100644 index 0000000..d878170 --- /dev/null +++ b/ent/ogent/ogent.go @@ -0,0 +1,274 @@ +// Code generated by entc, DO NOT EDIT. + +package ogent + +import ( + "context" + "net/http" + + "t/ent" + "t/ent/users" + + "github.com/go-faster/jx" +) + +// OgentHandler implements the ogen generated Handler interface and uses Ent as data layer. +type OgentHandler struct { + client *ent.Client +} + +// NewOgentHandler returns a new OgentHandler. +func NewOgentHandler(c *ent.Client) *OgentHandler { return &OgentHandler{c} } + +// rawError renders err as json string. +func rawError(err error) jx.Raw { + var e jx.Encoder + e.Str(err.Error()) + return e.Bytes() +} + +// CreateUsers handles POST /users-slice requests. +func (h *OgentHandler) CreateUsers(ctx context.Context, req CreateUsersReq) (CreateUsersRes, error) { + b := h.client.Users.Create() + // Add all fields. + b.SetUser(req.User) + if v, ok := req.Chara.Get(); ok { + b.SetChara(v) + } + if v, ok := req.Skill.Get(); ok { + b.SetSkill(v) + } + if v, ok := req.Hp.Get(); ok { + b.SetHp(v) + } + if v, ok := req.Attack.Get(); ok { + b.SetAttack(v) + } + if v, ok := req.Defense.Get(); ok { + b.SetDefense(v) + } + if v, ok := req.Critical.Get(); ok { + b.SetCritical(v) + } + if v, ok := req.Battle.Get(); ok { + b.SetBattle(v) + } + if v, ok := req.Win.Get(); ok { + b.SetWin(v) + } + if v, ok := req.Day.Get(); ok { + b.SetDay(v) + } + if v, ok := req.Percentage.Get(); ok { + b.SetPercentage(v) + } + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.Status.Get(); ok { + b.SetStatus(v) + } + if v, ok := req.Comment.Get(); ok { + b.SetComment(v) + } + if v, ok := req.CreatedAt.Get(); ok { + b.SetCreatedAt(v) + } + if v, ok := req.Next.Get(); ok { + b.SetNext(v) + } + if v, ok := req.UpdatedAt.Get(); ok { + b.SetUpdatedAt(v) + } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } + // Add all edges. + // 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.Users.Query().Where(users.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUsersCreate(e), nil +} + +// ReadUsers handles GET /users-slice/{id} requests. +func (h *OgentHandler) ReadUsers(ctx context.Context, params ReadUsersParams) (ReadUsersRes, error) { + q := h.client.Users.Query().Where(users.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 NewUsersRead(e), nil +} + +// UpdateUsers handles PATCH /users-slice/{id} requests. +func (h *OgentHandler) UpdateUsers(ctx context.Context, req UpdateUsersReq, params UpdateUsersParams) (UpdateUsersRes, error) { + b := h.client.Users.UpdateOneID(params.ID) + // Add all fields. + if v, ok := req.Hp.Get(); ok { + b.SetHp(v) + } + if v, ok := req.Attack.Get(); ok { + b.SetAttack(v) + } + if v, ok := req.Defense.Get(); ok { + b.SetDefense(v) + } + if v, ok := req.Critical.Get(); ok { + b.SetCritical(v) + } + if v, ok := req.Battle.Get(); ok { + b.SetBattle(v) + } + if v, ok := req.Win.Get(); ok { + b.SetWin(v) + } + if v, ok := req.Day.Get(); ok { + b.SetDay(v) + } + if v, ok := req.Percentage.Get(); ok { + b.SetPercentage(v) + } + if v, ok := req.Limit.Get(); ok { + b.SetLimit(v) + } + if v, ok := req.Comment.Get(); ok { + b.SetComment(v) + } + if v, ok := req.Next.Get(); ok { + b.SetNext(v) + } + if v, ok := req.UpdatedAt.Get(); ok { + b.SetUpdatedAt(v) + } + // Add all edges. + // 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.Users.Query().Where(users.ID(e.ID)) + e, err = q.Only(ctx) + if err != nil { + // This should never happen. + return nil, err + } + return NewUsersUpdate(e), nil +} + +// DeleteUsers handles DELETE /users-slice/{id} requests. +func (h *OgentHandler) DeleteUsers(ctx context.Context, params DeleteUsersParams) (DeleteUsersRes, error) { + err := h.client.Users.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(DeleteUsersNoContent), nil + +} + +// ListUsers handles GET /users-slice requests. +func (h *OgentHandler) ListUsers(ctx context.Context, params ListUsersParams) (ListUsersRes, error) { + q := h.client.Users.Query() + page := 1 + if v, ok := params.Page.Get(); ok { + page = v + } + itemsPerPage := 30 + if v, ok := params.ItemsPerPage.Get(); ok { + itemsPerPage = v + } + es, err := q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage).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 + } + } + return ListUsersOKApplicationJSON(NewUsersLists(es)), nil +} diff --git a/ent/ogent/responses.go b/ent/ogent/responses.go new file mode 100644 index 0000000..80b766c --- /dev/null +++ b/ent/ogent/responses.go @@ -0,0 +1,185 @@ +// Code generated by entc, DO NOT EDIT. + +package ogent + +import "t/ent" + +func NewUsersCreate(e *ent.Users) *UsersCreate { + if e == nil { + return nil + } + return &UsersCreate{ + ID: e.ID, + User: e.User, + Chara: NewOptString(e.Chara), + Skill: NewOptInt(e.Skill), + Hp: NewOptInt(e.Hp), + Attack: NewOptInt(e.Attack), + Defense: NewOptInt(e.Defense), + Critical: NewOptInt(e.Critical), + Battle: NewOptInt(e.Battle), + Win: NewOptInt(e.Win), + Day: NewOptInt(e.Day), + Percentage: NewOptFloat64(e.Percentage), + Limit: NewOptBool(e.Limit), + Status: NewOptString(e.Status), + Comment: NewOptString(e.Comment), + CreatedAt: NewOptDateTime(e.CreatedAt), + Next: NewOptString(e.Next), + UpdatedAt: NewOptDateTime(e.UpdatedAt), + URL: NewOptString(e.URL), + } +} + +func NewUsersCreates(es []*ent.Users) []UsersCreate { + if len(es) == 0 { + return nil + } + r := make([]UsersCreate, len(es)) + for i, e := range es { + r[i] = NewUsersCreate(e).Elem() + } + return r +} + +func (u *UsersCreate) Elem() UsersCreate { + if u != nil { + return UsersCreate{} + } + return *u +} + +func NewUsersList(e *ent.Users) *UsersList { + if e == nil { + return nil + } + return &UsersList{ + ID: e.ID, + User: e.User, + Chara: NewOptString(e.Chara), + Skill: NewOptInt(e.Skill), + Hp: NewOptInt(e.Hp), + Attack: NewOptInt(e.Attack), + Defense: NewOptInt(e.Defense), + Critical: NewOptInt(e.Critical), + Battle: NewOptInt(e.Battle), + Win: NewOptInt(e.Win), + Day: NewOptInt(e.Day), + Percentage: NewOptFloat64(e.Percentage), + Limit: NewOptBool(e.Limit), + Status: NewOptString(e.Status), + Comment: NewOptString(e.Comment), + CreatedAt: NewOptDateTime(e.CreatedAt), + Next: NewOptString(e.Next), + UpdatedAt: NewOptDateTime(e.UpdatedAt), + URL: NewOptString(e.URL), + } +} + +func NewUsersLists(es []*ent.Users) []UsersList { + if len(es) == 0 { + return nil + } + r := make([]UsersList, len(es)) + for i, e := range es { + r[i] = NewUsersList(e).Elem() + } + return r +} + +func (u *UsersList) Elem() UsersList { + if u != nil { + return UsersList{} + } + return *u +} + +func NewUsersRead(e *ent.Users) *UsersRead { + if e == nil { + return nil + } + return &UsersRead{ + ID: e.ID, + User: e.User, + Chara: NewOptString(e.Chara), + Skill: NewOptInt(e.Skill), + Hp: NewOptInt(e.Hp), + Attack: NewOptInt(e.Attack), + Defense: NewOptInt(e.Defense), + Critical: NewOptInt(e.Critical), + Battle: NewOptInt(e.Battle), + Win: NewOptInt(e.Win), + Day: NewOptInt(e.Day), + Percentage: NewOptFloat64(e.Percentage), + Limit: NewOptBool(e.Limit), + Status: NewOptString(e.Status), + Comment: NewOptString(e.Comment), + CreatedAt: NewOptDateTime(e.CreatedAt), + Next: NewOptString(e.Next), + UpdatedAt: NewOptDateTime(e.UpdatedAt), + URL: NewOptString(e.URL), + } +} + +func NewUsersReads(es []*ent.Users) []UsersRead { + if len(es) == 0 { + return nil + } + r := make([]UsersRead, len(es)) + for i, e := range es { + r[i] = NewUsersRead(e).Elem() + } + return r +} + +func (u *UsersRead) Elem() UsersRead { + if u != nil { + return UsersRead{} + } + return *u +} + +func NewUsersUpdate(e *ent.Users) *UsersUpdate { + if e == nil { + return nil + } + return &UsersUpdate{ + ID: e.ID, + User: e.User, + Chara: NewOptString(e.Chara), + Skill: NewOptInt(e.Skill), + Hp: NewOptInt(e.Hp), + Attack: NewOptInt(e.Attack), + Defense: NewOptInt(e.Defense), + Critical: NewOptInt(e.Critical), + Battle: NewOptInt(e.Battle), + Win: NewOptInt(e.Win), + Day: NewOptInt(e.Day), + Percentage: NewOptFloat64(e.Percentage), + Limit: NewOptBool(e.Limit), + Status: NewOptString(e.Status), + Comment: NewOptString(e.Comment), + CreatedAt: NewOptDateTime(e.CreatedAt), + Next: NewOptString(e.Next), + UpdatedAt: NewOptDateTime(e.UpdatedAt), + URL: NewOptString(e.URL), + } +} + +func NewUsersUpdates(es []*ent.Users) []UsersUpdate { + if len(es) == 0 { + return nil + } + r := make([]UsersUpdate, len(es)) + for i, e := range es { + r[i] = NewUsersUpdate(e).Elem() + } + return r +} + +func (u *UsersUpdate) Elem() UsersUpdate { + if u != nil { + return UsersUpdate{} + } + return *u +} diff --git a/ent/openapi.json b/ent/openapi.json new file mode 100644 index 0000000..76222fb --- /dev/null +++ b/ent/openapi.json @@ -0,0 +1,858 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Ent Schema API", + "description": "This is an auto generated API description made out of an Ent schema definition", + "version": "0.1.0" + }, + "paths": { + "/users": { + "get": { + "tags": [ + "Users" + ], + "summary": "List Users", + "description": "List Users.", + "operationId": "listUsers", + "parameters": [ + { + "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/UsersList" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + }, + "post": { + "tags": [ + "Users" + ], + "summary": "Create a new Users", + "description": "Creates a new Users and persists it to storage.", + "operationId": "createUsers", + "requestBody": { + "description": "Users to create", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "user" + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Users created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersCreate" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } + }, + "/users/{id}": { + "get": { + "tags": [ + "Users" + ], + "summary": "Find a Users by ID", + "description": "Finds the Users with the requested ID and returns it.", + "operationId": "readUsers", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Users", + "schema": { + "type": "integer" + }, + "required": true + } + ], + "responses": { + "200": { + "description": "Users with requested ID was found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersRead" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + }, + "delete": { + "tags": [ + "Users" + ], + "summary": "Deletes a Users by ID", + "description": "Deletes the Users with the requested ID.", + "operationId": "deleteUsers", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Users", + "schema": { + "type": "integer" + }, + "required": true + } + ], + "responses": { + "204": { + "description": "Users 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": [ + "Users" + ], + "summary": "Updates a Users", + "description": "Updates a Users and persists changes to storage.", + "operationId": "updateUsers", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the Users", + "schema": { + "type": "integer" + }, + "required": true + } + ], + "requestBody": { + "description": "Users properties to update", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "comment": { + "type": "string" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Users updated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersUpdate" + } + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "409": { + "$ref": "#/components/responses/409" + }, + "500": { + "$ref": "#/components/responses/500" + } + } + } + }, + "/users/{id}/d": { + "description": "Start an draw as done", + "put": { + "tags": [ + "Users" + ], + "summary": "Draws a card item as done.", + "operationId": "drawDone", + "responses": { + "204": { + "description": "Item marked as done" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "schema": { + "type": "integer" + }, + "required": true + } + ] + }, + "/users/{id}/start": { + "description": "Start an draw as done", + "patch": { + "tags": [ + "Users" + ], + "summary": "Draws a card item as done.", + "operationId": "drawStart", + "responses": { + "204": { + "description": "Item marked as done" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "schema": { + "type": "integer" + }, + "required": true + } + ] + } + }, + "components": { + "schemas": { + "Users": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "id", + "user" + ] + }, + "UsersCreate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "id", + "user" + ] + }, + "UsersList": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "id", + "user" + ] + }, + "UsersRead": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "id", + "user" + ] + }, + "UsersUpdate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "user": { + "type": "string" + }, + "chara": { + "type": "string" + }, + "skill": { + "type": "integer" + }, + "hp": { + "type": "integer" + }, + "attack": { + "type": "integer" + }, + "defense": { + "type": "integer" + }, + "critical": { + "type": "integer" + }, + "battle": { + "type": "integer" + }, + "win": { + "type": "integer" + }, + "day": { + "type": "integer" + }, + "percentage": { + "type": "number", + "format": "double" + }, + "limit": { + "type": "boolean" + }, + "status": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "next": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "url": { + "type": "string" + } + }, + "required": [ + "id", + "user" + ] + } + }, + "responses": { + "400": { + "description": "invalid input, data invalid", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "errors": {} + }, + "required": [ + "code", + "status" + ] + } + } + } + }, + "403": { + "description": "insufficient permissions", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "errors": {} + }, + "required": [ + "code", + "status" + ] + } + } + } + }, + "404": { + "description": "resource not found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "errors": {} + }, + "required": [ + "code", + "status" + ] + } + } + } + }, + "409": { + "description": "conflicting resources", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "errors": {} + }, + "required": [ + "code", + "status" + ] + } + } + } + }, + "500": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "errors": {} + }, + "required": [ + "code", + "status" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go new file mode 100644 index 0000000..2aa82af --- /dev/null +++ b/ent/predicate/predicate.go @@ -0,0 +1,10 @@ +// Code generated by entc, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// Users is the predicate function for users builders. +type Users func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go new file mode 100644 index 0000000..56c94a7 --- /dev/null +++ b/ent/runtime.go @@ -0,0 +1,104 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "t/ent/schema" + "t/ent/users" + "time" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + usersFields := schema.Users{}.Fields() + _ = usersFields + // usersDescUser is the schema descriptor for user field. + usersDescUser := usersFields[0].Descriptor() + // users.UserValidator is a validator for the "user" field. It is called by the builders before save. + users.UserValidator = func() func(string) error { + validators := usersDescUser.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + validators[2].(func(string) error), + } + return func(user string) error { + for _, fn := range fns { + if err := fn(user); err != nil { + return err + } + } + return nil + } + }() + // usersDescChara is the schema descriptor for chara field. + usersDescChara := usersFields[1].Descriptor() + // users.DefaultChara holds the default value on creation for the chara field. + users.DefaultChara = usersDescChara.Default.(string) + // usersDescSkill is the schema descriptor for skill field. + usersDescSkill := usersFields[2].Descriptor() + // users.DefaultSkill holds the default value on creation for the skill field. + users.DefaultSkill = usersDescSkill.Default.(int) + // usersDescHp is the schema descriptor for hp field. + usersDescHp := usersFields[3].Descriptor() + // users.DefaultHp holds the default value on creation for the hp field. + users.DefaultHp = usersDescHp.Default.(int) + // usersDescAttack is the schema descriptor for attack field. + usersDescAttack := usersFields[4].Descriptor() + // users.DefaultAttack holds the default value on creation for the attack field. + users.DefaultAttack = usersDescAttack.Default.(int) + // usersDescDefense is the schema descriptor for defense field. + usersDescDefense := usersFields[5].Descriptor() + // users.DefaultDefense holds the default value on creation for the defense field. + users.DefaultDefense = usersDescDefense.Default.(int) + // usersDescCritical is the schema descriptor for critical field. + usersDescCritical := usersFields[6].Descriptor() + // users.DefaultCritical holds the default value on creation for the critical field. + users.DefaultCritical = usersDescCritical.Default.(int) + // usersDescBattle is the schema descriptor for battle field. + usersDescBattle := usersFields[7].Descriptor() + // users.DefaultBattle holds the default value on creation for the battle field. + users.DefaultBattle = usersDescBattle.Default.(int) + // usersDescWin is the schema descriptor for win field. + usersDescWin := usersFields[8].Descriptor() + // users.DefaultWin holds the default value on creation for the win field. + users.DefaultWin = usersDescWin.Default.(int) + // usersDescDay is the schema descriptor for day field. + usersDescDay := usersFields[9].Descriptor() + // users.DefaultDay holds the default value on creation for the day field. + users.DefaultDay = usersDescDay.Default.(int) + // usersDescPercentage is the schema descriptor for percentage field. + usersDescPercentage := usersFields[10].Descriptor() + // users.DefaultPercentage holds the default value on creation for the percentage field. + users.DefaultPercentage = usersDescPercentage.Default.(float64) + // usersDescLimit is the schema descriptor for limit field. + usersDescLimit := usersFields[11].Descriptor() + // users.DefaultLimit holds the default value on creation for the limit field. + users.DefaultLimit = usersDescLimit.Default.(bool) + // usersDescStatus is the schema descriptor for status field. + usersDescStatus := usersFields[12].Descriptor() + // users.DefaultStatus holds the default value on creation for the status field. + users.DefaultStatus = usersDescStatus.Default.(string) + // usersDescComment is the schema descriptor for comment field. + usersDescComment := usersFields[13].Descriptor() + // users.DefaultComment holds the default value on creation for the comment field. + users.DefaultComment = usersDescComment.Default.(string) + // usersDescCreatedAt is the schema descriptor for created_at field. + usersDescCreatedAt := usersFields[14].Descriptor() + // users.DefaultCreatedAt holds the default value on creation for the created_at field. + users.DefaultCreatedAt = usersDescCreatedAt.Default.(func() time.Time) + // usersDescNext is the schema descriptor for next field. + usersDescNext := usersFields[15].Descriptor() + // users.DefaultNext holds the default value on creation for the next field. + users.DefaultNext = usersDescNext.Default.(string) + // usersDescUpdatedAt is the schema descriptor for updated_at field. + usersDescUpdatedAt := usersFields[16].Descriptor() + // users.DefaultUpdatedAt holds the default value on creation for the updated_at field. + users.DefaultUpdatedAt = usersDescUpdatedAt.Default.(func() time.Time) + // usersDescURL is the schema descriptor for url field. + usersDescURL := usersFields[17].Descriptor() + // users.DefaultURL holds the default value on creation for the url field. + users.DefaultURL = usersDescURL.Default.(string) +} diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go new file mode 100644 index 0000000..0bf7c16 --- /dev/null +++ b/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by entc, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in t/ent/runtime.go + +const ( + Version = "v0.10.0" // Version of ent codegen. + Sum = "h1:9cBomE1fh+WX34DPYQL7tDNAIvhKa3tXvwxuLyhYCMo=" // Sum of ent codegen. +) diff --git a/ent/schema/users.go b/ent/schema/users.go new file mode 100644 index 0000000..ff29605 --- /dev/null +++ b/ent/schema/users.go @@ -0,0 +1,172 @@ +package schema + +import ( + "time" + "regexp" + "entgo.io/ent" + "math/rand" + "entgo.io/ent/schema/field" + "github.com/kyokomi/lottery" +) + +type Users struct { + ent.Schema +} + +func Random(i int) (l int){ + rand.Seed(time.Now().UnixNano()) + l = rand.Intn(20) + for l == 0 { + l = rand.Intn(20) + } + return +} + +func Kira(i int) (l bool){ + lot := lottery.New(rand.New(rand.NewSource(time.Now().UnixNano()))) + if lot.Lot(i) { + l = true + } else { + l = false + } + return +} + +var jst,err = time.LoadLocation("Asia/Tokyo") + +var a = Random(4) +var d = Random(20) +var h = Random(20) +var k = Random(20) +var s = Random(20) +var c = Random(20) +var battle = 2 + +func StatusR()(status string){ + if d == 1 { + var status = "super" + return status + } else { + var status = "normal" + return status + } + return +} + +func CharaR()(chara string){ +if a == 1 { + var chara = "drai" +return chara +} else if a == 2 { + var chara = "octkat" +return chara +} else if a == 3 { + var chara = "kyosuke" +return chara +} else { + var chara = "ponta" +return chara +} +return +} + +func Nextime() (tt string){ + t := time.Now().Add(time.Hour * 24 * 1).In(jst) + tt = t.Format("20060102") + return +} + +func (Users) Fields() []ent.Field { + return []ent.Field{ + + field.String("user"). + NotEmpty(). + Immutable(). + MaxLen(7). + Match(regexp.MustCompile("[a-z]+$")). + Unique(), + + field.String("chara"). + Immutable(). + Default(CharaR()). + Optional(), + + field.Int("skill"). + Immutable(). + Optional(). + Default(k), + + field.Int("hp"). + Optional(). + Default(h), + + field.Int("attack"). + Optional(). + Default(a), + + field.Int("defense"). + Optional(). + Default(d), + + field.Int("critical"). + Optional(). + Default(c), + + field.Int("battle"). + Optional(). + Default(1), + + field.Int("win"). + Optional(). + Default(0), + + field.Int("day"). + Optional(). + Default(0), + + field.Float("percentage"). + Optional(). + Default(0), + + field.Bool("limit"). + Optional(). + Default(false), + + field.String("status"). + Immutable(). + Optional(). + Default(StatusR()), + + field.String("comment"). + Optional(). + Default(""), + + field.Time("created_at"). + Immutable(). + Optional(). + Default(func() time.Time { + return time.Now().In(jst) + }), + + field.String("next"). + Default(Nextime()). + Optional(), + + field.Time("updated_at"). + Optional(). + Default(func() time.Time { + return time.Now().In(jst) + }), + + field.String("url"). + Immutable(). + Optional(). + Default("https://syui.cf/api"), + } + +} + +func (Users) Edges() []ent.Edge { + return []ent.Edge{} +} + diff --git a/ent/tx.go b/ent/tx.go new file mode 100644 index 0000000..276923f --- /dev/null +++ b/ent/tx.go @@ -0,0 +1,210 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // Users is the client for interacting with the Users builders. + Users *UsersClient + + // lazily loaded. + client *Client + clientOnce sync.Once + + // completion callbacks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook + + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + tx.mu.Lock() + hooks := append([]CommitHook(nil), tx.onCommit...) + tx.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + tx.mu.Lock() + defer tx.mu.Unlock() + tx.onCommit = append(tx.onCommit, f) +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + tx.mu.Lock() + hooks := append([]RollbackHook(nil), tx.onRollback...) + tx.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + tx.mu.Lock() + defer tx.mu.Unlock() + tx.onRollback = append(tx.onRollback, f) +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.Users = NewUsersClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: Users.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/ent/users.go b/ent/users.go new file mode 100644 index 0000000..621fdea --- /dev/null +++ b/ent/users.go @@ -0,0 +1,276 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "t/ent/users" + "time" + + "entgo.io/ent/dialect/sql" +) + +// Users is the model entity for the Users schema. +type Users struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // User holds the value of the "user" field. + User string `json:"user,omitempty"` + // Chara holds the value of the "chara" field. + Chara string `json:"chara,omitempty"` + // Skill holds the value of the "skill" field. + Skill int `json:"skill,omitempty"` + // Hp holds the value of the "hp" field. + Hp int `json:"hp,omitempty"` + // Attack holds the value of the "attack" field. + Attack int `json:"attack,omitempty"` + // Defense holds the value of the "defense" field. + Defense int `json:"defense,omitempty"` + // Critical holds the value of the "critical" field. + Critical int `json:"critical,omitempty"` + // Battle holds the value of the "battle" field. + Battle int `json:"battle,omitempty"` + // Win holds the value of the "win" field. + Win int `json:"win,omitempty"` + // Day holds the value of the "day" field. + Day int `json:"day,omitempty"` + // Percentage holds the value of the "percentage" field. + Percentage float64 `json:"percentage,omitempty"` + // Limit holds the value of the "limit" field. + Limit bool `json:"limit,omitempty"` + // Status holds the value of the "status" field. + Status string `json:"status,omitempty"` + // Comment holds the value of the "comment" field. + Comment string `json:"comment,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // Next holds the value of the "next" field. + Next string `json:"next,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // URL holds the value of the "url" field. + URL string `json:"url,omitempty"` +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Users) scanValues(columns []string) ([]interface{}, error) { + values := make([]interface{}, len(columns)) + for i := range columns { + switch columns[i] { + case users.FieldLimit: + values[i] = new(sql.NullBool) + case users.FieldPercentage: + values[i] = new(sql.NullFloat64) + case users.FieldID, users.FieldSkill, users.FieldHp, users.FieldAttack, users.FieldDefense, users.FieldCritical, users.FieldBattle, users.FieldWin, users.FieldDay: + values[i] = new(sql.NullInt64) + case users.FieldUser, users.FieldChara, users.FieldStatus, users.FieldComment, users.FieldNext, users.FieldURL: + values[i] = new(sql.NullString) + case users.FieldCreatedAt, users.FieldUpdatedAt: + values[i] = new(sql.NullTime) + default: + return nil, fmt.Errorf("unexpected column %q for type Users", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Users fields. +func (u *Users) assignValues(columns []string, values []interface{}) 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 users.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 users.FieldUser: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user", values[i]) + } else if value.Valid { + u.User = value.String + } + case users.FieldChara: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field chara", values[i]) + } else if value.Valid { + u.Chara = value.String + } + case users.FieldSkill: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field skill", values[i]) + } else if value.Valid { + u.Skill = int(value.Int64) + } + case users.FieldHp: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hp", values[i]) + } else if value.Valid { + u.Hp = int(value.Int64) + } + case users.FieldAttack: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field attack", values[i]) + } else if value.Valid { + u.Attack = int(value.Int64) + } + case users.FieldDefense: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field defense", values[i]) + } else if value.Valid { + u.Defense = int(value.Int64) + } + case users.FieldCritical: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field critical", values[i]) + } else if value.Valid { + u.Critical = int(value.Int64) + } + case users.FieldBattle: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field battle", values[i]) + } else if value.Valid { + u.Battle = int(value.Int64) + } + case users.FieldWin: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field win", values[i]) + } else if value.Valid { + u.Win = int(value.Int64) + } + case users.FieldDay: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field day", values[i]) + } else if value.Valid { + u.Day = int(value.Int64) + } + case users.FieldPercentage: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field percentage", values[i]) + } else if value.Valid { + u.Percentage = value.Float64 + } + case users.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 users.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + u.Status = value.String + } + case users.FieldComment: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field comment", values[i]) + } else if value.Valid { + u.Comment = value.String + } + case users.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 users.FieldNext: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field next", values[i]) + } else if value.Valid { + u.Next = value.String + } + case users.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + u.UpdatedAt = value.Time + } + case users.FieldURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field url", values[i]) + } else if value.Valid { + u.URL = value.String + } + } + } + return nil +} + +// Update returns a builder for updating this Users. +// Note that you need to call Users.Unwrap() before calling this method if this Users +// was returned from a transaction, and the transaction was committed or rolled back. +func (u *Users) Update() *UsersUpdateOne { + return (&UsersClient{config: u.config}).UpdateOne(u) +} + +// Unwrap unwraps the Users 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 *Users) Unwrap() *Users { + tx, ok := u.config.driver.(*txDriver) + if !ok { + panic("ent: Users is not a transactional entity") + } + u.config.driver = tx.drv + return u +} + +// String implements the fmt.Stringer. +func (u *Users) String() string { + var builder strings.Builder + builder.WriteString("Users(") + builder.WriteString(fmt.Sprintf("id=%v", u.ID)) + builder.WriteString(", user=") + builder.WriteString(u.User) + builder.WriteString(", chara=") + builder.WriteString(u.Chara) + builder.WriteString(", skill=") + builder.WriteString(fmt.Sprintf("%v", u.Skill)) + builder.WriteString(", hp=") + builder.WriteString(fmt.Sprintf("%v", u.Hp)) + builder.WriteString(", attack=") + builder.WriteString(fmt.Sprintf("%v", u.Attack)) + builder.WriteString(", defense=") + builder.WriteString(fmt.Sprintf("%v", u.Defense)) + builder.WriteString(", critical=") + builder.WriteString(fmt.Sprintf("%v", u.Critical)) + builder.WriteString(", battle=") + builder.WriteString(fmt.Sprintf("%v", u.Battle)) + builder.WriteString(", win=") + builder.WriteString(fmt.Sprintf("%v", u.Win)) + builder.WriteString(", day=") + builder.WriteString(fmt.Sprintf("%v", u.Day)) + builder.WriteString(", percentage=") + builder.WriteString(fmt.Sprintf("%v", u.Percentage)) + builder.WriteString(", limit=") + builder.WriteString(fmt.Sprintf("%v", u.Limit)) + builder.WriteString(", status=") + builder.WriteString(u.Status) + builder.WriteString(", comment=") + builder.WriteString(u.Comment) + builder.WriteString(", created_at=") + builder.WriteString(u.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", next=") + builder.WriteString(u.Next) + builder.WriteString(", updated_at=") + builder.WriteString(u.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", url=") + builder.WriteString(u.URL) + builder.WriteByte(')') + return builder.String() +} + +// UsersSlice is a parsable slice of Users. +type UsersSlice []*Users + +func (u UsersSlice) config(cfg config) { + for _i := range u { + u[_i].config = cfg + } +} diff --git a/ent/users/users.go b/ent/users/users.go new file mode 100644 index 0000000..70bb3d0 --- /dev/null +++ b/ent/users/users.go @@ -0,0 +1,124 @@ +// Code generated by entc, DO NOT EDIT. + +package users + +import ( + "time" +) + +const ( + // Label holds the string label denoting the users type in the database. + Label = "users" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUser holds the string denoting the user field in the database. + FieldUser = "user" + // FieldChara holds the string denoting the chara field in the database. + FieldChara = "chara" + // FieldSkill holds the string denoting the skill field in the database. + FieldSkill = "skill" + // FieldHp holds the string denoting the hp field in the database. + FieldHp = "hp" + // FieldAttack holds the string denoting the attack field in the database. + FieldAttack = "attack" + // FieldDefense holds the string denoting the defense field in the database. + FieldDefense = "defense" + // FieldCritical holds the string denoting the critical field in the database. + FieldCritical = "critical" + // FieldBattle holds the string denoting the battle field in the database. + FieldBattle = "battle" + // FieldWin holds the string denoting the win field in the database. + FieldWin = "win" + // FieldDay holds the string denoting the day field in the database. + FieldDay = "day" + // FieldPercentage holds the string denoting the percentage field in the database. + FieldPercentage = "percentage" + // FieldLimit holds the string denoting the limit field in the database. + FieldLimit = "limit" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldComment holds the string denoting the comment field in the database. + FieldComment = "comment" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldNext holds the string denoting the next field in the database. + FieldNext = "next" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldURL holds the string denoting the url field in the database. + FieldURL = "url" + // Table holds the table name of the users in the database. + Table = "users" +) + +// Columns holds all SQL columns for users fields. +var Columns = []string{ + FieldID, + FieldUser, + FieldChara, + FieldSkill, + FieldHp, + FieldAttack, + FieldDefense, + FieldCritical, + FieldBattle, + FieldWin, + FieldDay, + FieldPercentage, + FieldLimit, + FieldStatus, + FieldComment, + FieldCreatedAt, + FieldNext, + FieldUpdatedAt, + FieldURL, +} + +// 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 + } + } + return false +} + +var ( + // UserValidator is a validator for the "user" field. It is called by the builders before save. + UserValidator func(string) error + // DefaultChara holds the default value on creation for the "chara" field. + DefaultChara string + // DefaultSkill holds the default value on creation for the "skill" field. + DefaultSkill int + // DefaultHp holds the default value on creation for the "hp" field. + DefaultHp int + // DefaultAttack holds the default value on creation for the "attack" field. + DefaultAttack int + // DefaultDefense holds the default value on creation for the "defense" field. + DefaultDefense int + // DefaultCritical holds the default value on creation for the "critical" field. + DefaultCritical int + // DefaultBattle holds the default value on creation for the "battle" field. + DefaultBattle int + // DefaultWin holds the default value on creation for the "win" field. + DefaultWin int + // DefaultDay holds the default value on creation for the "day" field. + DefaultDay int + // DefaultPercentage holds the default value on creation for the "percentage" field. + DefaultPercentage float64 + // DefaultLimit holds the default value on creation for the "limit" field. + DefaultLimit bool + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus string + // DefaultComment holds the default value on creation for the "comment" field. + DefaultComment string + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultNext holds the default value on creation for the "next" field. + DefaultNext string + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // DefaultURL holds the default value on creation for the "url" field. + DefaultURL string +) diff --git a/ent/users/where.go b/ent/users/where.go new file mode 100644 index 0000000..4b36261 --- /dev/null +++ b/ent/users/where.go @@ -0,0 +1,2005 @@ +// Code generated by entc, DO NOT EDIT. + +package users + +import ( + "t/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldID), id)) + }) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.In(s.C(FieldID), v...)) + }) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.NotIn(s.C(FieldID), v...)) + }) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }) +} + +// User applies equality check predicate on the "user" field. It's identical to UserEQ. +func User(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUser), v)) + }) +} + +// Chara applies equality check predicate on the "chara" field. It's identical to CharaEQ. +func Chara(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldChara), v)) + }) +} + +// Skill applies equality check predicate on the "skill" field. It's identical to SkillEQ. +func Skill(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSkill), v)) + }) +} + +// Hp applies equality check predicate on the "hp" field. It's identical to HpEQ. +func Hp(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHp), v)) + }) +} + +// Attack applies equality check predicate on the "attack" field. It's identical to AttackEQ. +func Attack(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAttack), v)) + }) +} + +// Defense applies equality check predicate on the "defense" field. It's identical to DefenseEQ. +func Defense(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDefense), v)) + }) +} + +// Critical applies equality check predicate on the "critical" field. It's identical to CriticalEQ. +func Critical(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCritical), v)) + }) +} + +// Battle applies equality check predicate on the "battle" field. It's identical to BattleEQ. +func Battle(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBattle), v)) + }) +} + +// Win applies equality check predicate on the "win" field. It's identical to WinEQ. +func Win(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWin), v)) + }) +} + +// Day applies equality check predicate on the "day" field. It's identical to DayEQ. +func Day(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDay), v)) + }) +} + +// Percentage applies equality check predicate on the "percentage" field. It's identical to PercentageEQ. +func Percentage(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPercentage), v)) + }) +} + +// Limit applies equality check predicate on the "limit" field. It's identical to LimitEQ. +func Limit(v bool) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLimit), v)) + }) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatus), v)) + }) +} + +// Comment applies equality check predicate on the "comment" field. It's identical to CommentEQ. +func Comment(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldComment), v)) + }) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCreatedAt), v)) + }) +} + +// Next applies equality check predicate on the "next" field. It's identical to NextEQ. +func Next(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNext), v)) + }) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) + }) +} + +// URL applies equality check predicate on the "url" field. It's identical to URLEQ. +func URL(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldURL), v)) + }) +} + +// UserEQ applies the EQ predicate on the "user" field. +func UserEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUser), v)) + }) +} + +// UserNEQ applies the NEQ predicate on the "user" field. +func UserNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUser), v)) + }) +} + +// UserIn applies the In predicate on the "user" field. +func UserIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUser), v...)) + }) +} + +// UserNotIn applies the NotIn predicate on the "user" field. +func UserNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUser), v...)) + }) +} + +// UserGT applies the GT predicate on the "user" field. +func UserGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUser), v)) + }) +} + +// UserGTE applies the GTE predicate on the "user" field. +func UserGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUser), v)) + }) +} + +// UserLT applies the LT predicate on the "user" field. +func UserLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUser), v)) + }) +} + +// UserLTE applies the LTE predicate on the "user" field. +func UserLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUser), v)) + }) +} + +// UserContains applies the Contains predicate on the "user" field. +func UserContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldUser), v)) + }) +} + +// UserHasPrefix applies the HasPrefix predicate on the "user" field. +func UserHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldUser), v)) + }) +} + +// UserHasSuffix applies the HasSuffix predicate on the "user" field. +func UserHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldUser), v)) + }) +} + +// UserEqualFold applies the EqualFold predicate on the "user" field. +func UserEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldUser), v)) + }) +} + +// UserContainsFold applies the ContainsFold predicate on the "user" field. +func UserContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldUser), v)) + }) +} + +// CharaEQ applies the EQ predicate on the "chara" field. +func CharaEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldChara), v)) + }) +} + +// CharaNEQ applies the NEQ predicate on the "chara" field. +func CharaNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldChara), v)) + }) +} + +// CharaIn applies the In predicate on the "chara" field. +func CharaIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldChara), v...)) + }) +} + +// CharaNotIn applies the NotIn predicate on the "chara" field. +func CharaNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldChara), v...)) + }) +} + +// CharaGT applies the GT predicate on the "chara" field. +func CharaGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldChara), v)) + }) +} + +// CharaGTE applies the GTE predicate on the "chara" field. +func CharaGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldChara), v)) + }) +} + +// CharaLT applies the LT predicate on the "chara" field. +func CharaLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldChara), v)) + }) +} + +// CharaLTE applies the LTE predicate on the "chara" field. +func CharaLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldChara), v)) + }) +} + +// CharaContains applies the Contains predicate on the "chara" field. +func CharaContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldChara), v)) + }) +} + +// CharaHasPrefix applies the HasPrefix predicate on the "chara" field. +func CharaHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldChara), v)) + }) +} + +// CharaHasSuffix applies the HasSuffix predicate on the "chara" field. +func CharaHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldChara), v)) + }) +} + +// CharaIsNil applies the IsNil predicate on the "chara" field. +func CharaIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldChara))) + }) +} + +// CharaNotNil applies the NotNil predicate on the "chara" field. +func CharaNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldChara))) + }) +} + +// CharaEqualFold applies the EqualFold predicate on the "chara" field. +func CharaEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldChara), v)) + }) +} + +// CharaContainsFold applies the ContainsFold predicate on the "chara" field. +func CharaContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldChara), v)) + }) +} + +// SkillEQ applies the EQ predicate on the "skill" field. +func SkillEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSkill), v)) + }) +} + +// SkillNEQ applies the NEQ predicate on the "skill" field. +func SkillNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldSkill), v)) + }) +} + +// SkillIn applies the In predicate on the "skill" field. +func SkillIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldSkill), v...)) + }) +} + +// SkillNotIn applies the NotIn predicate on the "skill" field. +func SkillNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldSkill), v...)) + }) +} + +// SkillGT applies the GT predicate on the "skill" field. +func SkillGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldSkill), v)) + }) +} + +// SkillGTE applies the GTE predicate on the "skill" field. +func SkillGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldSkill), v)) + }) +} + +// SkillLT applies the LT predicate on the "skill" field. +func SkillLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldSkill), v)) + }) +} + +// SkillLTE applies the LTE predicate on the "skill" field. +func SkillLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldSkill), v)) + }) +} + +// SkillIsNil applies the IsNil predicate on the "skill" field. +func SkillIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldSkill))) + }) +} + +// SkillNotNil applies the NotNil predicate on the "skill" field. +func SkillNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldSkill))) + }) +} + +// HpEQ applies the EQ predicate on the "hp" field. +func HpEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHp), v)) + }) +} + +// HpNEQ applies the NEQ predicate on the "hp" field. +func HpNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHp), v)) + }) +} + +// HpIn applies the In predicate on the "hp" field. +func HpIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldHp), v...)) + }) +} + +// HpNotIn applies the NotIn predicate on the "hp" field. +func HpNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldHp), v...)) + }) +} + +// HpGT applies the GT predicate on the "hp" field. +func HpGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHp), v)) + }) +} + +// HpGTE applies the GTE predicate on the "hp" field. +func HpGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHp), v)) + }) +} + +// HpLT applies the LT predicate on the "hp" field. +func HpLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHp), v)) + }) +} + +// HpLTE applies the LTE predicate on the "hp" field. +func HpLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHp), v)) + }) +} + +// HpIsNil applies the IsNil predicate on the "hp" field. +func HpIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHp))) + }) +} + +// HpNotNil applies the NotNil predicate on the "hp" field. +func HpNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHp))) + }) +} + +// AttackEQ applies the EQ predicate on the "attack" field. +func AttackEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAttack), v)) + }) +} + +// AttackNEQ applies the NEQ predicate on the "attack" field. +func AttackNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldAttack), v)) + }) +} + +// AttackIn applies the In predicate on the "attack" field. +func AttackIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldAttack), v...)) + }) +} + +// AttackNotIn applies the NotIn predicate on the "attack" field. +func AttackNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldAttack), v...)) + }) +} + +// AttackGT applies the GT predicate on the "attack" field. +func AttackGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAttack), v)) + }) +} + +// AttackGTE applies the GTE predicate on the "attack" field. +func AttackGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAttack), v)) + }) +} + +// AttackLT applies the LT predicate on the "attack" field. +func AttackLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAttack), v)) + }) +} + +// AttackLTE applies the LTE predicate on the "attack" field. +func AttackLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAttack), v)) + }) +} + +// AttackIsNil applies the IsNil predicate on the "attack" field. +func AttackIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldAttack))) + }) +} + +// AttackNotNil applies the NotNil predicate on the "attack" field. +func AttackNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldAttack))) + }) +} + +// DefenseEQ applies the EQ predicate on the "defense" field. +func DefenseEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDefense), v)) + }) +} + +// DefenseNEQ applies the NEQ predicate on the "defense" field. +func DefenseNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldDefense), v)) + }) +} + +// DefenseIn applies the In predicate on the "defense" field. +func DefenseIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldDefense), v...)) + }) +} + +// DefenseNotIn applies the NotIn predicate on the "defense" field. +func DefenseNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldDefense), v...)) + }) +} + +// DefenseGT applies the GT predicate on the "defense" field. +func DefenseGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldDefense), v)) + }) +} + +// DefenseGTE applies the GTE predicate on the "defense" field. +func DefenseGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldDefense), v)) + }) +} + +// DefenseLT applies the LT predicate on the "defense" field. +func DefenseLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldDefense), v)) + }) +} + +// DefenseLTE applies the LTE predicate on the "defense" field. +func DefenseLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldDefense), v)) + }) +} + +// DefenseIsNil applies the IsNil predicate on the "defense" field. +func DefenseIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldDefense))) + }) +} + +// DefenseNotNil applies the NotNil predicate on the "defense" field. +func DefenseNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldDefense))) + }) +} + +// CriticalEQ applies the EQ predicate on the "critical" field. +func CriticalEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCritical), v)) + }) +} + +// CriticalNEQ applies the NEQ predicate on the "critical" field. +func CriticalNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldCritical), v)) + }) +} + +// CriticalIn applies the In predicate on the "critical" field. +func CriticalIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldCritical), v...)) + }) +} + +// CriticalNotIn applies the NotIn predicate on the "critical" field. +func CriticalNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldCritical), v...)) + }) +} + +// CriticalGT applies the GT predicate on the "critical" field. +func CriticalGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldCritical), v)) + }) +} + +// CriticalGTE applies the GTE predicate on the "critical" field. +func CriticalGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldCritical), v)) + }) +} + +// CriticalLT applies the LT predicate on the "critical" field. +func CriticalLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldCritical), v)) + }) +} + +// CriticalLTE applies the LTE predicate on the "critical" field. +func CriticalLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldCritical), v)) + }) +} + +// CriticalIsNil applies the IsNil predicate on the "critical" field. +func CriticalIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldCritical))) + }) +} + +// CriticalNotNil applies the NotNil predicate on the "critical" field. +func CriticalNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldCritical))) + }) +} + +// BattleEQ applies the EQ predicate on the "battle" field. +func BattleEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBattle), v)) + }) +} + +// BattleNEQ applies the NEQ predicate on the "battle" field. +func BattleNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldBattle), v)) + }) +} + +// BattleIn applies the In predicate on the "battle" field. +func BattleIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldBattle), v...)) + }) +} + +// BattleNotIn applies the NotIn predicate on the "battle" field. +func BattleNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldBattle), v...)) + }) +} + +// BattleGT applies the GT predicate on the "battle" field. +func BattleGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBattle), v)) + }) +} + +// BattleGTE applies the GTE predicate on the "battle" field. +func BattleGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBattle), v)) + }) +} + +// BattleLT applies the LT predicate on the "battle" field. +func BattleLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBattle), v)) + }) +} + +// BattleLTE applies the LTE predicate on the "battle" field. +func BattleLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBattle), v)) + }) +} + +// BattleIsNil applies the IsNil predicate on the "battle" field. +func BattleIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldBattle))) + }) +} + +// BattleNotNil applies the NotNil predicate on the "battle" field. +func BattleNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldBattle))) + }) +} + +// WinEQ applies the EQ predicate on the "win" field. +func WinEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWin), v)) + }) +} + +// WinNEQ applies the NEQ predicate on the "win" field. +func WinNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldWin), v)) + }) +} + +// WinIn applies the In predicate on the "win" field. +func WinIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldWin), v...)) + }) +} + +// WinNotIn applies the NotIn predicate on the "win" field. +func WinNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldWin), v...)) + }) +} + +// WinGT applies the GT predicate on the "win" field. +func WinGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldWin), v)) + }) +} + +// WinGTE applies the GTE predicate on the "win" field. +func WinGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldWin), v)) + }) +} + +// WinLT applies the LT predicate on the "win" field. +func WinLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldWin), v)) + }) +} + +// WinLTE applies the LTE predicate on the "win" field. +func WinLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldWin), v)) + }) +} + +// WinIsNil applies the IsNil predicate on the "win" field. +func WinIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldWin))) + }) +} + +// WinNotNil applies the NotNil predicate on the "win" field. +func WinNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldWin))) + }) +} + +// DayEQ applies the EQ predicate on the "day" field. +func DayEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDay), v)) + }) +} + +// DayNEQ applies the NEQ predicate on the "day" field. +func DayNEQ(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldDay), v)) + }) +} + +// DayIn applies the In predicate on the "day" field. +func DayIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldDay), v...)) + }) +} + +// DayNotIn applies the NotIn predicate on the "day" field. +func DayNotIn(vs ...int) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldDay), v...)) + }) +} + +// DayGT applies the GT predicate on the "day" field. +func DayGT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldDay), v)) + }) +} + +// DayGTE applies the GTE predicate on the "day" field. +func DayGTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldDay), v)) + }) +} + +// DayLT applies the LT predicate on the "day" field. +func DayLT(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldDay), v)) + }) +} + +// DayLTE applies the LTE predicate on the "day" field. +func DayLTE(v int) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldDay), v)) + }) +} + +// DayIsNil applies the IsNil predicate on the "day" field. +func DayIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldDay))) + }) +} + +// DayNotNil applies the NotNil predicate on the "day" field. +func DayNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldDay))) + }) +} + +// PercentageEQ applies the EQ predicate on the "percentage" field. +func PercentageEQ(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPercentage), v)) + }) +} + +// PercentageNEQ applies the NEQ predicate on the "percentage" field. +func PercentageNEQ(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldPercentage), v)) + }) +} + +// PercentageIn applies the In predicate on the "percentage" field. +func PercentageIn(vs ...float64) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldPercentage), v...)) + }) +} + +// PercentageNotIn applies the NotIn predicate on the "percentage" field. +func PercentageNotIn(vs ...float64) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldPercentage), v...)) + }) +} + +// PercentageGT applies the GT predicate on the "percentage" field. +func PercentageGT(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldPercentage), v)) + }) +} + +// PercentageGTE applies the GTE predicate on the "percentage" field. +func PercentageGTE(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldPercentage), v)) + }) +} + +// PercentageLT applies the LT predicate on the "percentage" field. +func PercentageLT(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldPercentage), v)) + }) +} + +// PercentageLTE applies the LTE predicate on the "percentage" field. +func PercentageLTE(v float64) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldPercentage), v)) + }) +} + +// PercentageIsNil applies the IsNil predicate on the "percentage" field. +func PercentageIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldPercentage))) + }) +} + +// PercentageNotNil applies the NotNil predicate on the "percentage" field. +func PercentageNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldPercentage))) + }) +} + +// LimitEQ applies the EQ predicate on the "limit" field. +func LimitEQ(v bool) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLimit), v)) + }) +} + +// LimitNEQ applies the NEQ predicate on the "limit" field. +func LimitNEQ(v bool) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLimit), v)) + }) +} + +// LimitIsNil applies the IsNil predicate on the "limit" field. +func LimitIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldLimit))) + }) +} + +// LimitNotNil applies the NotNil predicate on the "limit" field. +func LimitNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldLimit))) + }) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatus), v)) + }) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStatus), v)) + }) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldStatus), v...)) + }) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldStatus), v...)) + }) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldStatus), v)) + }) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldStatus), v)) + }) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldStatus), v)) + }) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldStatus), v)) + }) +} + +// StatusContains applies the Contains predicate on the "status" field. +func StatusContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldStatus), v)) + }) +} + +// StatusHasPrefix applies the HasPrefix predicate on the "status" field. +func StatusHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldStatus), v)) + }) +} + +// StatusHasSuffix applies the HasSuffix predicate on the "status" field. +func StatusHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldStatus), v)) + }) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldStatus))) + }) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldStatus))) + }) +} + +// StatusEqualFold applies the EqualFold predicate on the "status" field. +func StatusEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldStatus), v)) + }) +} + +// StatusContainsFold applies the ContainsFold predicate on the "status" field. +func StatusContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldStatus), v)) + }) +} + +// CommentEQ applies the EQ predicate on the "comment" field. +func CommentEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldComment), v)) + }) +} + +// CommentNEQ applies the NEQ predicate on the "comment" field. +func CommentNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldComment), v)) + }) +} + +// CommentIn applies the In predicate on the "comment" field. +func CommentIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldComment), v...)) + }) +} + +// CommentNotIn applies the NotIn predicate on the "comment" field. +func CommentNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldComment), v...)) + }) +} + +// CommentGT applies the GT predicate on the "comment" field. +func CommentGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldComment), v)) + }) +} + +// CommentGTE applies the GTE predicate on the "comment" field. +func CommentGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldComment), v)) + }) +} + +// CommentLT applies the LT predicate on the "comment" field. +func CommentLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldComment), v)) + }) +} + +// CommentLTE applies the LTE predicate on the "comment" field. +func CommentLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldComment), v)) + }) +} + +// CommentContains applies the Contains predicate on the "comment" field. +func CommentContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldComment), v)) + }) +} + +// CommentHasPrefix applies the HasPrefix predicate on the "comment" field. +func CommentHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldComment), v)) + }) +} + +// CommentHasSuffix applies the HasSuffix predicate on the "comment" field. +func CommentHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldComment), v)) + }) +} + +// CommentIsNil applies the IsNil predicate on the "comment" field. +func CommentIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldComment))) + }) +} + +// CommentNotNil applies the NotNil predicate on the "comment" field. +func CommentNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldComment))) + }) +} + +// CommentEqualFold applies the EqualFold predicate on the "comment" field. +func CommentEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldComment), v)) + }) +} + +// CommentContainsFold applies the ContainsFold predicate on the "comment" field. +func CommentContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldComment), v)) + }) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldCreatedAt), v...)) + }) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) + }) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldCreatedAt), v)) + }) +} + +// CreatedAtIsNil applies the IsNil predicate on the "created_at" field. +func CreatedAtIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldCreatedAt))) + }) +} + +// CreatedAtNotNil applies the NotNil predicate on the "created_at" field. +func CreatedAtNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldCreatedAt))) + }) +} + +// NextEQ applies the EQ predicate on the "next" field. +func NextEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNext), v)) + }) +} + +// NextNEQ applies the NEQ predicate on the "next" field. +func NextNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldNext), v)) + }) +} + +// NextIn applies the In predicate on the "next" field. +func NextIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNext), v...)) + }) +} + +// NextNotIn applies the NotIn predicate on the "next" field. +func NextNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNext), v...)) + }) +} + +// NextGT applies the GT predicate on the "next" field. +func NextGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldNext), v)) + }) +} + +// NextGTE applies the GTE predicate on the "next" field. +func NextGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldNext), v)) + }) +} + +// NextLT applies the LT predicate on the "next" field. +func NextLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldNext), v)) + }) +} + +// NextLTE applies the LTE predicate on the "next" field. +func NextLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldNext), v)) + }) +} + +// NextContains applies the Contains predicate on the "next" field. +func NextContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldNext), v)) + }) +} + +// NextHasPrefix applies the HasPrefix predicate on the "next" field. +func NextHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldNext), v)) + }) +} + +// NextHasSuffix applies the HasSuffix predicate on the "next" field. +func NextHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldNext), v)) + }) +} + +// NextIsNil applies the IsNil predicate on the "next" field. +func NextIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldNext))) + }) +} + +// NextNotNil applies the NotNil predicate on the "next" field. +func NextNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldNext))) + }) +} + +// NextEqualFold applies the EqualFold predicate on the "next" field. +func NextEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldNext), v)) + }) +} + +// NextContainsFold applies the ContainsFold predicate on the "next" field. +func NextContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldNext), v)) + }) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUpdatedAt), v...)) + }) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) + }) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) + }) +} + +// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field. +func UpdatedAtIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUpdatedAt))) + }) +} + +// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field. +func UpdatedAtNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUpdatedAt))) + }) +} + +// URLEQ applies the EQ predicate on the "url" field. +func URLEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldURL), v)) + }) +} + +// URLNEQ applies the NEQ predicate on the "url" field. +func URLNEQ(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldURL), v)) + }) +} + +// URLIn applies the In predicate on the "url" field. +func URLIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldURL), v...)) + }) +} + +// URLNotIn applies the NotIn predicate on the "url" field. +func URLNotIn(vs ...string) predicate.Users { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Users(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldURL), v...)) + }) +} + +// URLGT applies the GT predicate on the "url" field. +func URLGT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldURL), v)) + }) +} + +// URLGTE applies the GTE predicate on the "url" field. +func URLGTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldURL), v)) + }) +} + +// URLLT applies the LT predicate on the "url" field. +func URLLT(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldURL), v)) + }) +} + +// URLLTE applies the LTE predicate on the "url" field. +func URLLTE(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldURL), v)) + }) +} + +// URLContains applies the Contains predicate on the "url" field. +func URLContains(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldURL), v)) + }) +} + +// URLHasPrefix applies the HasPrefix predicate on the "url" field. +func URLHasPrefix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldURL), v)) + }) +} + +// URLHasSuffix applies the HasSuffix predicate on the "url" field. +func URLHasSuffix(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldURL), v)) + }) +} + +// URLIsNil applies the IsNil predicate on the "url" field. +func URLIsNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldURL))) + }) +} + +// URLNotNil applies the NotNil predicate on the "url" field. +func URLNotNil() predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldURL))) + }) +} + +// URLEqualFold applies the EqualFold predicate on the "url" field. +func URLEqualFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldURL), v)) + }) +} + +// URLContainsFold applies the ContainsFold predicate on the "url" field. +func URLContainsFold(v string) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldURL), v)) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Users) predicate.Users { + return predicate.Users(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.Users) predicate.Users { + return predicate.Users(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.Users) predicate.Users { + return predicate.Users(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/users_create.go b/ent/users_create.go new file mode 100644 index 0000000..ee58b08 --- /dev/null +++ b/ent/users_create.go @@ -0,0 +1,674 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "t/ent/users" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UsersCreate is the builder for creating a Users entity. +type UsersCreate struct { + config + mutation *UsersMutation + hooks []Hook +} + +// SetUser sets the "user" field. +func (uc *UsersCreate) SetUser(s string) *UsersCreate { + uc.mutation.SetUser(s) + return uc +} + +// SetChara sets the "chara" field. +func (uc *UsersCreate) SetChara(s string) *UsersCreate { + uc.mutation.SetChara(s) + return uc +} + +// SetNillableChara sets the "chara" field if the given value is not nil. +func (uc *UsersCreate) SetNillableChara(s *string) *UsersCreate { + if s != nil { + uc.SetChara(*s) + } + return uc +} + +// SetSkill sets the "skill" field. +func (uc *UsersCreate) SetSkill(i int) *UsersCreate { + uc.mutation.SetSkill(i) + return uc +} + +// SetNillableSkill sets the "skill" field if the given value is not nil. +func (uc *UsersCreate) SetNillableSkill(i *int) *UsersCreate { + if i != nil { + uc.SetSkill(*i) + } + return uc +} + +// SetHp sets the "hp" field. +func (uc *UsersCreate) SetHp(i int) *UsersCreate { + uc.mutation.SetHp(i) + return uc +} + +// SetNillableHp sets the "hp" field if the given value is not nil. +func (uc *UsersCreate) SetNillableHp(i *int) *UsersCreate { + if i != nil { + uc.SetHp(*i) + } + return uc +} + +// SetAttack sets the "attack" field. +func (uc *UsersCreate) SetAttack(i int) *UsersCreate { + uc.mutation.SetAttack(i) + return uc +} + +// SetNillableAttack sets the "attack" field if the given value is not nil. +func (uc *UsersCreate) SetNillableAttack(i *int) *UsersCreate { + if i != nil { + uc.SetAttack(*i) + } + return uc +} + +// SetDefense sets the "defense" field. +func (uc *UsersCreate) SetDefense(i int) *UsersCreate { + uc.mutation.SetDefense(i) + return uc +} + +// SetNillableDefense sets the "defense" field if the given value is not nil. +func (uc *UsersCreate) SetNillableDefense(i *int) *UsersCreate { + if i != nil { + uc.SetDefense(*i) + } + return uc +} + +// SetCritical sets the "critical" field. +func (uc *UsersCreate) SetCritical(i int) *UsersCreate { + uc.mutation.SetCritical(i) + return uc +} + +// SetNillableCritical sets the "critical" field if the given value is not nil. +func (uc *UsersCreate) SetNillableCritical(i *int) *UsersCreate { + if i != nil { + uc.SetCritical(*i) + } + return uc +} + +// SetBattle sets the "battle" field. +func (uc *UsersCreate) SetBattle(i int) *UsersCreate { + uc.mutation.SetBattle(i) + return uc +} + +// SetNillableBattle sets the "battle" field if the given value is not nil. +func (uc *UsersCreate) SetNillableBattle(i *int) *UsersCreate { + if i != nil { + uc.SetBattle(*i) + } + return uc +} + +// SetWin sets the "win" field. +func (uc *UsersCreate) SetWin(i int) *UsersCreate { + uc.mutation.SetWin(i) + return uc +} + +// SetNillableWin sets the "win" field if the given value is not nil. +func (uc *UsersCreate) SetNillableWin(i *int) *UsersCreate { + if i != nil { + uc.SetWin(*i) + } + return uc +} + +// SetDay sets the "day" field. +func (uc *UsersCreate) SetDay(i int) *UsersCreate { + uc.mutation.SetDay(i) + return uc +} + +// SetNillableDay sets the "day" field if the given value is not nil. +func (uc *UsersCreate) SetNillableDay(i *int) *UsersCreate { + if i != nil { + uc.SetDay(*i) + } + return uc +} + +// SetPercentage sets the "percentage" field. +func (uc *UsersCreate) SetPercentage(f float64) *UsersCreate { + uc.mutation.SetPercentage(f) + return uc +} + +// SetNillablePercentage sets the "percentage" field if the given value is not nil. +func (uc *UsersCreate) SetNillablePercentage(f *float64) *UsersCreate { + if f != nil { + uc.SetPercentage(*f) + } + return uc +} + +// SetLimit sets the "limit" field. +func (uc *UsersCreate) SetLimit(b bool) *UsersCreate { + uc.mutation.SetLimit(b) + return uc +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uc *UsersCreate) SetNillableLimit(b *bool) *UsersCreate { + if b != nil { + uc.SetLimit(*b) + } + return uc +} + +// SetStatus sets the "status" field. +func (uc *UsersCreate) SetStatus(s string) *UsersCreate { + uc.mutation.SetStatus(s) + return uc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (uc *UsersCreate) SetNillableStatus(s *string) *UsersCreate { + if s != nil { + uc.SetStatus(*s) + } + return uc +} + +// SetComment sets the "comment" field. +func (uc *UsersCreate) SetComment(s string) *UsersCreate { + uc.mutation.SetComment(s) + return uc +} + +// SetNillableComment sets the "comment" field if the given value is not nil. +func (uc *UsersCreate) SetNillableComment(s *string) *UsersCreate { + if s != nil { + uc.SetComment(*s) + } + return uc +} + +// SetCreatedAt sets the "created_at" field. +func (uc *UsersCreate) SetCreatedAt(t time.Time) *UsersCreate { + uc.mutation.SetCreatedAt(t) + return uc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (uc *UsersCreate) SetNillableCreatedAt(t *time.Time) *UsersCreate { + if t != nil { + uc.SetCreatedAt(*t) + } + return uc +} + +// SetNext sets the "next" field. +func (uc *UsersCreate) SetNext(s string) *UsersCreate { + uc.mutation.SetNext(s) + return uc +} + +// SetNillableNext sets the "next" field if the given value is not nil. +func (uc *UsersCreate) SetNillableNext(s *string) *UsersCreate { + if s != nil { + uc.SetNext(*s) + } + return uc +} + +// SetUpdatedAt sets the "updated_at" field. +func (uc *UsersCreate) SetUpdatedAt(t time.Time) *UsersCreate { + uc.mutation.SetUpdatedAt(t) + return uc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (uc *UsersCreate) SetNillableUpdatedAt(t *time.Time) *UsersCreate { + if t != nil { + uc.SetUpdatedAt(*t) + } + return uc +} + +// SetURL sets the "url" field. +func (uc *UsersCreate) SetURL(s string) *UsersCreate { + uc.mutation.SetURL(s) + return uc +} + +// SetNillableURL sets the "url" field if the given value is not nil. +func (uc *UsersCreate) SetNillableURL(s *string) *UsersCreate { + if s != nil { + uc.SetURL(*s) + } + return uc +} + +// Mutation returns the UsersMutation object of the builder. +func (uc *UsersCreate) Mutation() *UsersMutation { + return uc.mutation +} + +// Save creates the Users in the database. +func (uc *UsersCreate) Save(ctx context.Context) (*Users, error) { + var ( + err error + node *Users + ) + uc.defaults() + if len(uc.hooks) == 0 { + if err = uc.check(); err != nil { + return nil, err + } + node, err = uc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UsersMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = uc.check(); err != nil { + return nil, err + } + uc.mutation = mutation + if node, err = uc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(uc.hooks) - 1; i >= 0; i-- { + if uc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, uc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (uc *UsersCreate) SaveX(ctx context.Context) *Users { + v, err := uc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uc *UsersCreate) Exec(ctx context.Context) error { + _, err := uc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uc *UsersCreate) 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 *UsersCreate) defaults() { + if _, ok := uc.mutation.Chara(); !ok { + v := users.DefaultChara + uc.mutation.SetChara(v) + } + if _, ok := uc.mutation.Skill(); !ok { + v := users.DefaultSkill + uc.mutation.SetSkill(v) + } + if _, ok := uc.mutation.Hp(); !ok { + v := users.DefaultHp + uc.mutation.SetHp(v) + } + if _, ok := uc.mutation.Attack(); !ok { + v := users.DefaultAttack + uc.mutation.SetAttack(v) + } + if _, ok := uc.mutation.Defense(); !ok { + v := users.DefaultDefense + uc.mutation.SetDefense(v) + } + if _, ok := uc.mutation.Critical(); !ok { + v := users.DefaultCritical + uc.mutation.SetCritical(v) + } + if _, ok := uc.mutation.Battle(); !ok { + v := users.DefaultBattle + uc.mutation.SetBattle(v) + } + if _, ok := uc.mutation.Win(); !ok { + v := users.DefaultWin + uc.mutation.SetWin(v) + } + if _, ok := uc.mutation.Day(); !ok { + v := users.DefaultDay + uc.mutation.SetDay(v) + } + if _, ok := uc.mutation.Percentage(); !ok { + v := users.DefaultPercentage + uc.mutation.SetPercentage(v) + } + if _, ok := uc.mutation.Limit(); !ok { + v := users.DefaultLimit + uc.mutation.SetLimit(v) + } + if _, ok := uc.mutation.Status(); !ok { + v := users.DefaultStatus + uc.mutation.SetStatus(v) + } + if _, ok := uc.mutation.Comment(); !ok { + v := users.DefaultComment + uc.mutation.SetComment(v) + } + if _, ok := uc.mutation.CreatedAt(); !ok { + v := users.DefaultCreatedAt() + uc.mutation.SetCreatedAt(v) + } + if _, ok := uc.mutation.Next(); !ok { + v := users.DefaultNext + uc.mutation.SetNext(v) + } + if _, ok := uc.mutation.UpdatedAt(); !ok { + v := users.DefaultUpdatedAt() + uc.mutation.SetUpdatedAt(v) + } + if _, ok := uc.mutation.URL(); !ok { + v := users.DefaultURL + uc.mutation.SetURL(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uc *UsersCreate) check() error { + if _, ok := uc.mutation.User(); !ok { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required field "Users.user"`)} + } + if v, ok := uc.mutation.User(); ok { + if err := users.UserValidator(v); err != nil { + return &ValidationError{Name: "user", err: fmt.Errorf(`ent: validator failed for field "Users.user": %w`, err)} + } + } + return nil +} + +func (uc *UsersCreate) sqlSave(ctx context.Context) (*Users, error) { + _node, _spec := uc.createSpec() + if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + return _node, nil +} + +func (uc *UsersCreate) createSpec() (*Users, *sqlgraph.CreateSpec) { + var ( + _node = &Users{config: uc.config} + _spec = &sqlgraph.CreateSpec{ + Table: users.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldID, + }, + } + ) + if value, ok := uc.mutation.User(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldUser, + }) + _node.User = value + } + if value, ok := uc.mutation.Chara(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldChara, + }) + _node.Chara = value + } + if value, ok := uc.mutation.Skill(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldSkill, + }) + _node.Skill = value + } + if value, ok := uc.mutation.Hp(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldHp, + }) + _node.Hp = value + } + if value, ok := uc.mutation.Attack(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldAttack, + }) + _node.Attack = value + } + if value, ok := uc.mutation.Defense(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDefense, + }) + _node.Defense = value + } + if value, ok := uc.mutation.Critical(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldCritical, + }) + _node.Critical = value + } + if value, ok := uc.mutation.Battle(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldBattle, + }) + _node.Battle = value + } + if value, ok := uc.mutation.Win(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldWin, + }) + _node.Win = value + } + if value, ok := uc.mutation.Day(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDay, + }) + _node.Day = value + } + if value, ok := uc.mutation.Percentage(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Value: value, + Column: users.FieldPercentage, + }) + _node.Percentage = value + } + if value, ok := uc.mutation.Limit(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: users.FieldLimit, + }) + _node.Limit = value + } + if value, ok := uc.mutation.Status(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldStatus, + }) + _node.Status = value + } + if value, ok := uc.mutation.Comment(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldComment, + }) + _node.Comment = value + } + if value, ok := uc.mutation.CreatedAt(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: users.FieldCreatedAt, + }) + _node.CreatedAt = value + } + if value, ok := uc.mutation.Next(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldNext, + }) + _node.Next = value + } + if value, ok := uc.mutation.UpdatedAt(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: users.FieldUpdatedAt, + }) + _node.UpdatedAt = value + } + if value, ok := uc.mutation.URL(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldURL, + }) + _node.URL = value + } + return _node, _spec +} + +// UsersCreateBulk is the builder for creating many Users entities in bulk. +type UsersCreateBulk struct { + config + builders []*UsersCreate +} + +// Save creates the Users entities in the database. +func (ucb *UsersCreateBulk) Save(ctx context.Context) ([]*Users, error) { + specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) + nodes := make([]*Users, 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.(*UsersMutation) + 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{err.Error(), err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + 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 *UsersCreateBulk) SaveX(ctx context.Context) []*Users { + v, err := ucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ucb *UsersCreateBulk) Exec(ctx context.Context) error { + _, err := ucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ucb *UsersCreateBulk) ExecX(ctx context.Context) { + if err := ucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/users_delete.go b/ent/users_delete.go new file mode 100644 index 0000000..662c450 --- /dev/null +++ b/ent/users_delete.go @@ -0,0 +1,111 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "t/ent/predicate" + "t/ent/users" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UsersDelete is the builder for deleting a Users entity. +type UsersDelete struct { + config + hooks []Hook + mutation *UsersMutation +} + +// Where appends a list predicates to the UsersDelete builder. +func (ud *UsersDelete) Where(ps ...predicate.Users) *UsersDelete { + ud.mutation.Where(ps...) + return ud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ud *UsersDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(ud.hooks) == 0 { + affected, err = ud.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UsersMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + ud.mutation = mutation + affected, err = ud.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(ud.hooks) - 1; i >= 0; i-- { + if ud.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = ud.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, ud.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ud *UsersDelete) ExecX(ctx context.Context) int { + n, err := ud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ud *UsersDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: users.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldID, + }, + }, + } + if ps := ud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return sqlgraph.DeleteNodes(ctx, ud.driver, _spec) +} + +// UsersDeleteOne is the builder for deleting a single Users entity. +type UsersDeleteOne struct { + ud *UsersDelete +} + +// Exec executes the deletion query. +func (udo *UsersDeleteOne) Exec(ctx context.Context) error { + n, err := udo.ud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{users.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (udo *UsersDeleteOne) ExecX(ctx context.Context) { + udo.ud.ExecX(ctx) +} diff --git a/ent/users_query.go b/ent/users_query.go new file mode 100644 index 0000000..720f79e --- /dev/null +++ b/ent/users_query.go @@ -0,0 +1,920 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "math" + "t/ent/predicate" + "t/ent/users" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UsersQuery is the builder for querying Users entities. +type UsersQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.Users + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UsersQuery builder. +func (uq *UsersQuery) Where(ps ...predicate.Users) *UsersQuery { + uq.predicates = append(uq.predicates, ps...) + return uq +} + +// Limit adds a limit step to the query. +func (uq *UsersQuery) Limit(limit int) *UsersQuery { + uq.limit = &limit + return uq +} + +// Offset adds an offset step to the query. +func (uq *UsersQuery) Offset(offset int) *UsersQuery { + uq.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 *UsersQuery) Unique(unique bool) *UsersQuery { + uq.unique = &unique + return uq +} + +// Order adds an order step to the query. +func (uq *UsersQuery) Order(o ...OrderFunc) *UsersQuery { + uq.order = append(uq.order, o...) + return uq +} + +// First returns the first Users entity from the query. +// Returns a *NotFoundError when no Users was found. +func (uq *UsersQuery) First(ctx context.Context) (*Users, error) { + nodes, err := uq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{users.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (uq *UsersQuery) FirstX(ctx context.Context) *Users { + node, err := uq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Users ID from the query. +// Returns a *NotFoundError when no Users ID was found. +func (uq *UsersQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{users.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (uq *UsersQuery) FirstIDX(ctx context.Context) int { + id, err := uq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Users entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one Users entity is not found. +// Returns a *NotFoundError when no Users entities are found. +func (uq *UsersQuery) Only(ctx context.Context) (*Users, error) { + nodes, err := uq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{users.Label} + default: + return nil, &NotSingularError{users.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (uq *UsersQuery) OnlyX(ctx context.Context) *Users { + node, err := uq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Users ID in the query. +// Returns a *NotSingularError when exactly one Users ID is not found. +// Returns a *NotFoundError when no entities are found. +func (uq *UsersQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{users.Label} + default: + err = &NotSingularError{users.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (uq *UsersQuery) 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 UsersSlice. +func (uq *UsersQuery) All(ctx context.Context) ([]*Users, error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + return uq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (uq *UsersQuery) AllX(ctx context.Context) []*Users { + nodes, err := uq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Users IDs. +func (uq *UsersQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := uq.Select(users.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (uq *UsersQuery) 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 *UsersQuery) Count(ctx context.Context) (int, error) { + if err := uq.prepareQuery(ctx); err != nil { + return 0, err + } + return uq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (uq *UsersQuery) 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 *UsersQuery) Exist(ctx context.Context) (bool, error) { + if err := uq.prepareQuery(ctx); err != nil { + return false, err + } + return uq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (uq *UsersQuery) ExistX(ctx context.Context) bool { + exist, err := uq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UsersQuery 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 *UsersQuery) Clone() *UsersQuery { + if uq == nil { + return nil + } + return &UsersQuery{ + config: uq.config, + limit: uq.limit, + offset: uq.offset, + order: append([]OrderFunc{}, uq.order...), + predicates: append([]predicate.Users{}, uq.predicates...), + // clone intermediate query. + sql: uq.sql.Clone(), + path: uq.path, + } +} + +// 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 { +// User string `json:"user,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Users.Query(). +// GroupBy(users.FieldUser). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (uq *UsersQuery) GroupBy(field string, fields ...string) *UsersGroupBy { + group := &UsersGroupBy{config: uq.config} + group.fields = append([]string{field}, fields...) + group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + return uq.sqlQuery(ctx), nil + } + return group +} + +// 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 { +// User string `json:"user,omitempty"` +// } +// +// client.Users.Query(). +// Select(users.FieldUser). +// Scan(ctx, &v) +// +func (uq *UsersQuery) Select(fields ...string) *UsersSelect { + uq.fields = append(uq.fields, fields...) + return &UsersSelect{UsersQuery: uq} +} + +func (uq *UsersQuery) prepareQuery(ctx context.Context) error { + for _, f := range uq.fields { + if !users.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 *UsersQuery) sqlAll(ctx context.Context) ([]*Users, error) { + var ( + nodes = []*Users{} + _spec = uq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + node := &Users{config: uq.config} + nodes = append(nodes, node) + return node.scanValues(columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + if len(nodes) == 0 { + return fmt.Errorf("ent: Assign called without calling ScanValues") + } + node := nodes[len(nodes)-1] + return node.assignValues(columns, values) + } + if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (uq *UsersQuery) sqlCount(ctx context.Context) (int, error) { + _spec := uq.querySpec() + _spec.Node.Columns = uq.fields + if len(uq.fields) > 0 { + _spec.Unique = uq.unique != nil && *uq.unique + } + return sqlgraph.CountNodes(ctx, uq.driver, _spec) +} + +func (uq *UsersQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := uq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (uq *UsersQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: users.Table, + Columns: users.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldID, + }, + }, + From: uq.sql, + Unique: true, + } + if unique := uq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := uq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, users.FieldID) + for i := range fields { + if fields[i] != users.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.limit; limit != nil { + _spec.Limit = *limit + } + if offset := uq.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 *UsersQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(uq.driver.Dialect()) + t1 := builder.Table(users.Table) + columns := uq.fields + if len(columns) == 0 { + columns = users.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if uq.sql != nil { + selector = uq.sql + selector.Select(selector.Columns(columns...)...) + } + if uq.unique != nil && *uq.unique { + selector.Distinct() + } + for _, p := range uq.predicates { + p(selector) + } + for _, p := range uq.order { + p(selector) + } + if offset := uq.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.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UsersGroupBy is the group-by builder for Users entities. +type UsersGroupBy struct { + config + fields []string + fns []AggregateFunc + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ugb *UsersGroupBy) Aggregate(fns ...AggregateFunc) *UsersGroupBy { + ugb.fns = append(ugb.fns, fns...) + return ugb +} + +// Scan applies the group-by query and scans the result into the given value. +func (ugb *UsersGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := ugb.path(ctx) + if err != nil { + return err + } + ugb.sql = query + return ugb.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (ugb *UsersGroupBy) ScanX(ctx context.Context, v interface{}) { + if err := ugb.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from group-by. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Strings(ctx context.Context) ([]string, error) { + if len(ugb.fields) > 1 { + return nil, errors.New("ent: UsersGroupBy.Strings is not achievable when grouping more than 1 field") + } + var v []string + if err := ugb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (ugb *UsersGroupBy) StringsX(ctx context.Context) []string { + v, err := ugb.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = ugb.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersGroupBy.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (ugb *UsersGroupBy) StringX(ctx context.Context) string { + v, err := ugb.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from group-by. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Ints(ctx context.Context) ([]int, error) { + if len(ugb.fields) > 1 { + return nil, errors.New("ent: UsersGroupBy.Ints is not achievable when grouping more than 1 field") + } + var v []int + if err := ugb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (ugb *UsersGroupBy) IntsX(ctx context.Context) []int { + v, err := ugb.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = ugb.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersGroupBy.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (ugb *UsersGroupBy) IntX(ctx context.Context) int { + v, err := ugb.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from group-by. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Float64s(ctx context.Context) ([]float64, error) { + if len(ugb.fields) > 1 { + return nil, errors.New("ent: UsersGroupBy.Float64s is not achievable when grouping more than 1 field") + } + var v []float64 + if err := ugb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (ugb *UsersGroupBy) Float64sX(ctx context.Context) []float64 { + v, err := ugb.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = ugb.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersGroupBy.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (ugb *UsersGroupBy) Float64X(ctx context.Context) float64 { + v, err := ugb.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from group-by. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Bools(ctx context.Context) ([]bool, error) { + if len(ugb.fields) > 1 { + return nil, errors.New("ent: UsersGroupBy.Bools is not achievable when grouping more than 1 field") + } + var v []bool + if err := ugb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (ugb *UsersGroupBy) BoolsX(ctx context.Context) []bool { + v, err := ugb.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (ugb *UsersGroupBy) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = ugb.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersGroupBy.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (ugb *UsersGroupBy) BoolX(ctx context.Context) bool { + v, err := ugb.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (ugb *UsersGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range ugb.fields { + if !users.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := ugb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ugb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (ugb *UsersGroupBy) sqlQuery() *sql.Selector { + selector := ugb.sql.Select() + aggregation := make([]string, 0, len(ugb.fns)) + for _, fn := range ugb.fns { + aggregation = append(aggregation, fn(selector)) + } + // If no columns were selected in a custom aggregation function, the default + // selection is the fields used for "group-by", and the aggregation functions. + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(ugb.fields)+len(ugb.fns)) + for _, f := range ugb.fields { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(ugb.fields...)...) +} + +// UsersSelect is the builder for selecting fields of Users entities. +type UsersSelect struct { + *UsersQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (us *UsersSelect) Scan(ctx context.Context, v interface{}) error { + if err := us.prepareQuery(ctx); err != nil { + return err + } + us.sql = us.UsersQuery.sqlQuery(ctx) + return us.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (us *UsersSelect) ScanX(ctx context.Context, v interface{}) { + if err := us.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Strings(ctx context.Context) ([]string, error) { + if len(us.fields) > 1 { + return nil, errors.New("ent: UsersSelect.Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := us.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (us *UsersSelect) StringsX(ctx context.Context) []string { + v, err := us.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = us.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersSelect.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (us *UsersSelect) StringX(ctx context.Context) string { + v, err := us.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Ints(ctx context.Context) ([]int, error) { + if len(us.fields) > 1 { + return nil, errors.New("ent: UsersSelect.Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := us.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (us *UsersSelect) IntsX(ctx context.Context) []int { + v, err := us.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = us.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersSelect.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (us *UsersSelect) IntX(ctx context.Context) int { + v, err := us.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Float64s(ctx context.Context) ([]float64, error) { + if len(us.fields) > 1 { + return nil, errors.New("ent: UsersSelect.Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := us.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (us *UsersSelect) Float64sX(ctx context.Context) []float64 { + v, err := us.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = us.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersSelect.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (us *UsersSelect) Float64X(ctx context.Context) float64 { + v, err := us.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Bools(ctx context.Context) ([]bool, error) { + if len(us.fields) > 1 { + return nil, errors.New("ent: UsersSelect.Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := us.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (us *UsersSelect) BoolsX(ctx context.Context) []bool { + v, err := us.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (us *UsersSelect) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = us.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{users.Label} + default: + err = fmt.Errorf("ent: UsersSelect.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (us *UsersSelect) BoolX(ctx context.Context) bool { + v, err := us.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (us *UsersSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := us.sql.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/users_update.go b/ent/users_update.go new file mode 100644 index 0000000..b84f75a --- /dev/null +++ b/ent/users_update.go @@ -0,0 +1,1316 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "t/ent/predicate" + "t/ent/users" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UsersUpdate is the builder for updating Users entities. +type UsersUpdate struct { + config + hooks []Hook + mutation *UsersMutation +} + +// Where appends a list predicates to the UsersUpdate builder. +func (uu *UsersUpdate) Where(ps ...predicate.Users) *UsersUpdate { + uu.mutation.Where(ps...) + return uu +} + +// SetHp sets the "hp" field. +func (uu *UsersUpdate) SetHp(i int) *UsersUpdate { + uu.mutation.ResetHp() + uu.mutation.SetHp(i) + return uu +} + +// SetNillableHp sets the "hp" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableHp(i *int) *UsersUpdate { + if i != nil { + uu.SetHp(*i) + } + return uu +} + +// AddHp adds i to the "hp" field. +func (uu *UsersUpdate) AddHp(i int) *UsersUpdate { + uu.mutation.AddHp(i) + return uu +} + +// ClearHp clears the value of the "hp" field. +func (uu *UsersUpdate) ClearHp() *UsersUpdate { + uu.mutation.ClearHp() + return uu +} + +// SetAttack sets the "attack" field. +func (uu *UsersUpdate) SetAttack(i int) *UsersUpdate { + uu.mutation.ResetAttack() + uu.mutation.SetAttack(i) + return uu +} + +// SetNillableAttack sets the "attack" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableAttack(i *int) *UsersUpdate { + if i != nil { + uu.SetAttack(*i) + } + return uu +} + +// AddAttack adds i to the "attack" field. +func (uu *UsersUpdate) AddAttack(i int) *UsersUpdate { + uu.mutation.AddAttack(i) + return uu +} + +// ClearAttack clears the value of the "attack" field. +func (uu *UsersUpdate) ClearAttack() *UsersUpdate { + uu.mutation.ClearAttack() + return uu +} + +// SetDefense sets the "defense" field. +func (uu *UsersUpdate) SetDefense(i int) *UsersUpdate { + uu.mutation.ResetDefense() + uu.mutation.SetDefense(i) + return uu +} + +// SetNillableDefense sets the "defense" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableDefense(i *int) *UsersUpdate { + if i != nil { + uu.SetDefense(*i) + } + return uu +} + +// AddDefense adds i to the "defense" field. +func (uu *UsersUpdate) AddDefense(i int) *UsersUpdate { + uu.mutation.AddDefense(i) + return uu +} + +// ClearDefense clears the value of the "defense" field. +func (uu *UsersUpdate) ClearDefense() *UsersUpdate { + uu.mutation.ClearDefense() + return uu +} + +// SetCritical sets the "critical" field. +func (uu *UsersUpdate) SetCritical(i int) *UsersUpdate { + uu.mutation.ResetCritical() + uu.mutation.SetCritical(i) + return uu +} + +// SetNillableCritical sets the "critical" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableCritical(i *int) *UsersUpdate { + if i != nil { + uu.SetCritical(*i) + } + return uu +} + +// AddCritical adds i to the "critical" field. +func (uu *UsersUpdate) AddCritical(i int) *UsersUpdate { + uu.mutation.AddCritical(i) + return uu +} + +// ClearCritical clears the value of the "critical" field. +func (uu *UsersUpdate) ClearCritical() *UsersUpdate { + uu.mutation.ClearCritical() + return uu +} + +// SetBattle sets the "battle" field. +func (uu *UsersUpdate) SetBattle(i int) *UsersUpdate { + uu.mutation.ResetBattle() + uu.mutation.SetBattle(i) + return uu +} + +// SetNillableBattle sets the "battle" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableBattle(i *int) *UsersUpdate { + if i != nil { + uu.SetBattle(*i) + } + return uu +} + +// AddBattle adds i to the "battle" field. +func (uu *UsersUpdate) AddBattle(i int) *UsersUpdate { + uu.mutation.AddBattle(i) + return uu +} + +// ClearBattle clears the value of the "battle" field. +func (uu *UsersUpdate) ClearBattle() *UsersUpdate { + uu.mutation.ClearBattle() + return uu +} + +// SetWin sets the "win" field. +func (uu *UsersUpdate) SetWin(i int) *UsersUpdate { + uu.mutation.ResetWin() + uu.mutation.SetWin(i) + return uu +} + +// SetNillableWin sets the "win" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableWin(i *int) *UsersUpdate { + if i != nil { + uu.SetWin(*i) + } + return uu +} + +// AddWin adds i to the "win" field. +func (uu *UsersUpdate) AddWin(i int) *UsersUpdate { + uu.mutation.AddWin(i) + return uu +} + +// ClearWin clears the value of the "win" field. +func (uu *UsersUpdate) ClearWin() *UsersUpdate { + uu.mutation.ClearWin() + return uu +} + +// SetDay sets the "day" field. +func (uu *UsersUpdate) SetDay(i int) *UsersUpdate { + uu.mutation.ResetDay() + uu.mutation.SetDay(i) + return uu +} + +// SetNillableDay sets the "day" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableDay(i *int) *UsersUpdate { + if i != nil { + uu.SetDay(*i) + } + return uu +} + +// AddDay adds i to the "day" field. +func (uu *UsersUpdate) AddDay(i int) *UsersUpdate { + uu.mutation.AddDay(i) + return uu +} + +// ClearDay clears the value of the "day" field. +func (uu *UsersUpdate) ClearDay() *UsersUpdate { + uu.mutation.ClearDay() + return uu +} + +// SetPercentage sets the "percentage" field. +func (uu *UsersUpdate) SetPercentage(f float64) *UsersUpdate { + uu.mutation.ResetPercentage() + uu.mutation.SetPercentage(f) + return uu +} + +// SetNillablePercentage sets the "percentage" field if the given value is not nil. +func (uu *UsersUpdate) SetNillablePercentage(f *float64) *UsersUpdate { + if f != nil { + uu.SetPercentage(*f) + } + return uu +} + +// AddPercentage adds f to the "percentage" field. +func (uu *UsersUpdate) AddPercentage(f float64) *UsersUpdate { + uu.mutation.AddPercentage(f) + return uu +} + +// ClearPercentage clears the value of the "percentage" field. +func (uu *UsersUpdate) ClearPercentage() *UsersUpdate { + uu.mutation.ClearPercentage() + return uu +} + +// SetLimit sets the "limit" field. +func (uu *UsersUpdate) SetLimit(b bool) *UsersUpdate { + uu.mutation.SetLimit(b) + return uu +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableLimit(b *bool) *UsersUpdate { + if b != nil { + uu.SetLimit(*b) + } + return uu +} + +// ClearLimit clears the value of the "limit" field. +func (uu *UsersUpdate) ClearLimit() *UsersUpdate { + uu.mutation.ClearLimit() + return uu +} + +// SetComment sets the "comment" field. +func (uu *UsersUpdate) SetComment(s string) *UsersUpdate { + uu.mutation.SetComment(s) + return uu +} + +// SetNillableComment sets the "comment" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableComment(s *string) *UsersUpdate { + if s != nil { + uu.SetComment(*s) + } + return uu +} + +// ClearComment clears the value of the "comment" field. +func (uu *UsersUpdate) ClearComment() *UsersUpdate { + uu.mutation.ClearComment() + return uu +} + +// SetNext sets the "next" field. +func (uu *UsersUpdate) SetNext(s string) *UsersUpdate { + uu.mutation.SetNext(s) + return uu +} + +// SetNillableNext sets the "next" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableNext(s *string) *UsersUpdate { + if s != nil { + uu.SetNext(*s) + } + return uu +} + +// ClearNext clears the value of the "next" field. +func (uu *UsersUpdate) ClearNext() *UsersUpdate { + uu.mutation.ClearNext() + return uu +} + +// SetUpdatedAt sets the "updated_at" field. +func (uu *UsersUpdate) SetUpdatedAt(t time.Time) *UsersUpdate { + uu.mutation.SetUpdatedAt(t) + return uu +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (uu *UsersUpdate) SetNillableUpdatedAt(t *time.Time) *UsersUpdate { + if t != nil { + uu.SetUpdatedAt(*t) + } + return uu +} + +// ClearUpdatedAt clears the value of the "updated_at" field. +func (uu *UsersUpdate) ClearUpdatedAt() *UsersUpdate { + uu.mutation.ClearUpdatedAt() + return uu +} + +// Mutation returns the UsersMutation object of the builder. +func (uu *UsersUpdate) Mutation() *UsersMutation { + return uu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (uu *UsersUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(uu.hooks) == 0 { + affected, err = uu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UsersMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + uu.mutation = mutation + affected, err = uu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(uu.hooks) - 1; i >= 0; i-- { + if uu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, uu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (uu *UsersUpdate) SaveX(ctx context.Context) int { + affected, err := uu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (uu *UsersUpdate) Exec(ctx context.Context) error { + _, err := uu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uu *UsersUpdate) ExecX(ctx context.Context) { + if err := uu.Exec(ctx); err != nil { + panic(err) + } +} + +func (uu *UsersUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: users.Table, + Columns: users.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldID, + }, + }, + } + if ps := uu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if uu.mutation.CharaCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldChara, + }) + } + if uu.mutation.SkillCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldSkill, + }) + } + if value, ok := uu.mutation.Hp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldHp, + }) + } + if value, ok := uu.mutation.AddedHp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldHp, + }) + } + if uu.mutation.HpCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldHp, + }) + } + if value, ok := uu.mutation.Attack(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldAttack, + }) + } + if value, ok := uu.mutation.AddedAttack(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldAttack, + }) + } + if uu.mutation.AttackCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldAttack, + }) + } + if value, ok := uu.mutation.Defense(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDefense, + }) + } + if value, ok := uu.mutation.AddedDefense(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDefense, + }) + } + if uu.mutation.DefenseCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldDefense, + }) + } + if value, ok := uu.mutation.Critical(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldCritical, + }) + } + if value, ok := uu.mutation.AddedCritical(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldCritical, + }) + } + if uu.mutation.CriticalCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldCritical, + }) + } + if value, ok := uu.mutation.Battle(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldBattle, + }) + } + if value, ok := uu.mutation.AddedBattle(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldBattle, + }) + } + if uu.mutation.BattleCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldBattle, + }) + } + if value, ok := uu.mutation.Win(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldWin, + }) + } + if value, ok := uu.mutation.AddedWin(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldWin, + }) + } + if uu.mutation.WinCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldWin, + }) + } + if value, ok := uu.mutation.Day(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDay, + }) + } + if value, ok := uu.mutation.AddedDay(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDay, + }) + } + if uu.mutation.DayCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldDay, + }) + } + if value, ok := uu.mutation.Percentage(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Value: value, + Column: users.FieldPercentage, + }) + } + if value, ok := uu.mutation.AddedPercentage(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Value: value, + Column: users.FieldPercentage, + }) + } + if uu.mutation.PercentageCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Column: users.FieldPercentage, + }) + } + if value, ok := uu.mutation.Limit(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: users.FieldLimit, + }) + } + if uu.mutation.LimitCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Column: users.FieldLimit, + }) + } + if uu.mutation.StatusCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldStatus, + }) + } + if value, ok := uu.mutation.Comment(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldComment, + }) + } + if uu.mutation.CommentCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldComment, + }) + } + if uu.mutation.CreatedAtCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: users.FieldCreatedAt, + }) + } + if value, ok := uu.mutation.Next(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldNext, + }) + } + if uu.mutation.NextCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldNext, + }) + } + if value, ok := uu.mutation.UpdatedAt(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: users.FieldUpdatedAt, + }) + } + if uu.mutation.UpdatedAtCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: users.FieldUpdatedAt, + }) + } + if uu.mutation.URLCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldURL, + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{users.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return 0, err + } + return n, nil +} + +// UsersUpdateOne is the builder for updating a single Users entity. +type UsersUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UsersMutation +} + +// SetHp sets the "hp" field. +func (uuo *UsersUpdateOne) SetHp(i int) *UsersUpdateOne { + uuo.mutation.ResetHp() + uuo.mutation.SetHp(i) + return uuo +} + +// SetNillableHp sets the "hp" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableHp(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetHp(*i) + } + return uuo +} + +// AddHp adds i to the "hp" field. +func (uuo *UsersUpdateOne) AddHp(i int) *UsersUpdateOne { + uuo.mutation.AddHp(i) + return uuo +} + +// ClearHp clears the value of the "hp" field. +func (uuo *UsersUpdateOne) ClearHp() *UsersUpdateOne { + uuo.mutation.ClearHp() + return uuo +} + +// SetAttack sets the "attack" field. +func (uuo *UsersUpdateOne) SetAttack(i int) *UsersUpdateOne { + uuo.mutation.ResetAttack() + uuo.mutation.SetAttack(i) + return uuo +} + +// SetNillableAttack sets the "attack" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableAttack(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetAttack(*i) + } + return uuo +} + +// AddAttack adds i to the "attack" field. +func (uuo *UsersUpdateOne) AddAttack(i int) *UsersUpdateOne { + uuo.mutation.AddAttack(i) + return uuo +} + +// ClearAttack clears the value of the "attack" field. +func (uuo *UsersUpdateOne) ClearAttack() *UsersUpdateOne { + uuo.mutation.ClearAttack() + return uuo +} + +// SetDefense sets the "defense" field. +func (uuo *UsersUpdateOne) SetDefense(i int) *UsersUpdateOne { + uuo.mutation.ResetDefense() + uuo.mutation.SetDefense(i) + return uuo +} + +// SetNillableDefense sets the "defense" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableDefense(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetDefense(*i) + } + return uuo +} + +// AddDefense adds i to the "defense" field. +func (uuo *UsersUpdateOne) AddDefense(i int) *UsersUpdateOne { + uuo.mutation.AddDefense(i) + return uuo +} + +// ClearDefense clears the value of the "defense" field. +func (uuo *UsersUpdateOne) ClearDefense() *UsersUpdateOne { + uuo.mutation.ClearDefense() + return uuo +} + +// SetCritical sets the "critical" field. +func (uuo *UsersUpdateOne) SetCritical(i int) *UsersUpdateOne { + uuo.mutation.ResetCritical() + uuo.mutation.SetCritical(i) + return uuo +} + +// SetNillableCritical sets the "critical" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableCritical(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetCritical(*i) + } + return uuo +} + +// AddCritical adds i to the "critical" field. +func (uuo *UsersUpdateOne) AddCritical(i int) *UsersUpdateOne { + uuo.mutation.AddCritical(i) + return uuo +} + +// ClearCritical clears the value of the "critical" field. +func (uuo *UsersUpdateOne) ClearCritical() *UsersUpdateOne { + uuo.mutation.ClearCritical() + return uuo +} + +// SetBattle sets the "battle" field. +func (uuo *UsersUpdateOne) SetBattle(i int) *UsersUpdateOne { + uuo.mutation.ResetBattle() + uuo.mutation.SetBattle(i) + return uuo +} + +// SetNillableBattle sets the "battle" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableBattle(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetBattle(*i) + } + return uuo +} + +// AddBattle adds i to the "battle" field. +func (uuo *UsersUpdateOne) AddBattle(i int) *UsersUpdateOne { + uuo.mutation.AddBattle(i) + return uuo +} + +// ClearBattle clears the value of the "battle" field. +func (uuo *UsersUpdateOne) ClearBattle() *UsersUpdateOne { + uuo.mutation.ClearBattle() + return uuo +} + +// SetWin sets the "win" field. +func (uuo *UsersUpdateOne) SetWin(i int) *UsersUpdateOne { + uuo.mutation.ResetWin() + uuo.mutation.SetWin(i) + return uuo +} + +// SetNillableWin sets the "win" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableWin(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetWin(*i) + } + return uuo +} + +// AddWin adds i to the "win" field. +func (uuo *UsersUpdateOne) AddWin(i int) *UsersUpdateOne { + uuo.mutation.AddWin(i) + return uuo +} + +// ClearWin clears the value of the "win" field. +func (uuo *UsersUpdateOne) ClearWin() *UsersUpdateOne { + uuo.mutation.ClearWin() + return uuo +} + +// SetDay sets the "day" field. +func (uuo *UsersUpdateOne) SetDay(i int) *UsersUpdateOne { + uuo.mutation.ResetDay() + uuo.mutation.SetDay(i) + return uuo +} + +// SetNillableDay sets the "day" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableDay(i *int) *UsersUpdateOne { + if i != nil { + uuo.SetDay(*i) + } + return uuo +} + +// AddDay adds i to the "day" field. +func (uuo *UsersUpdateOne) AddDay(i int) *UsersUpdateOne { + uuo.mutation.AddDay(i) + return uuo +} + +// ClearDay clears the value of the "day" field. +func (uuo *UsersUpdateOne) ClearDay() *UsersUpdateOne { + uuo.mutation.ClearDay() + return uuo +} + +// SetPercentage sets the "percentage" field. +func (uuo *UsersUpdateOne) SetPercentage(f float64) *UsersUpdateOne { + uuo.mutation.ResetPercentage() + uuo.mutation.SetPercentage(f) + return uuo +} + +// SetNillablePercentage sets the "percentage" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillablePercentage(f *float64) *UsersUpdateOne { + if f != nil { + uuo.SetPercentage(*f) + } + return uuo +} + +// AddPercentage adds f to the "percentage" field. +func (uuo *UsersUpdateOne) AddPercentage(f float64) *UsersUpdateOne { + uuo.mutation.AddPercentage(f) + return uuo +} + +// ClearPercentage clears the value of the "percentage" field. +func (uuo *UsersUpdateOne) ClearPercentage() *UsersUpdateOne { + uuo.mutation.ClearPercentage() + return uuo +} + +// SetLimit sets the "limit" field. +func (uuo *UsersUpdateOne) SetLimit(b bool) *UsersUpdateOne { + uuo.mutation.SetLimit(b) + return uuo +} + +// SetNillableLimit sets the "limit" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableLimit(b *bool) *UsersUpdateOne { + if b != nil { + uuo.SetLimit(*b) + } + return uuo +} + +// ClearLimit clears the value of the "limit" field. +func (uuo *UsersUpdateOne) ClearLimit() *UsersUpdateOne { + uuo.mutation.ClearLimit() + return uuo +} + +// SetComment sets the "comment" field. +func (uuo *UsersUpdateOne) SetComment(s string) *UsersUpdateOne { + uuo.mutation.SetComment(s) + return uuo +} + +// SetNillableComment sets the "comment" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableComment(s *string) *UsersUpdateOne { + if s != nil { + uuo.SetComment(*s) + } + return uuo +} + +// ClearComment clears the value of the "comment" field. +func (uuo *UsersUpdateOne) ClearComment() *UsersUpdateOne { + uuo.mutation.ClearComment() + return uuo +} + +// SetNext sets the "next" field. +func (uuo *UsersUpdateOne) SetNext(s string) *UsersUpdateOne { + uuo.mutation.SetNext(s) + return uuo +} + +// SetNillableNext sets the "next" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableNext(s *string) *UsersUpdateOne { + if s != nil { + uuo.SetNext(*s) + } + return uuo +} + +// ClearNext clears the value of the "next" field. +func (uuo *UsersUpdateOne) ClearNext() *UsersUpdateOne { + uuo.mutation.ClearNext() + return uuo +} + +// SetUpdatedAt sets the "updated_at" field. +func (uuo *UsersUpdateOne) SetUpdatedAt(t time.Time) *UsersUpdateOne { + uuo.mutation.SetUpdatedAt(t) + return uuo +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (uuo *UsersUpdateOne) SetNillableUpdatedAt(t *time.Time) *UsersUpdateOne { + if t != nil { + uuo.SetUpdatedAt(*t) + } + return uuo +} + +// ClearUpdatedAt clears the value of the "updated_at" field. +func (uuo *UsersUpdateOne) ClearUpdatedAt() *UsersUpdateOne { + uuo.mutation.ClearUpdatedAt() + return uuo +} + +// Mutation returns the UsersMutation object of the builder. +func (uuo *UsersUpdateOne) Mutation() *UsersMutation { + return uuo.mutation +} + +// 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 *UsersUpdateOne) Select(field string, fields ...string) *UsersUpdateOne { + uuo.fields = append([]string{field}, fields...) + return uuo +} + +// Save executes the query and returns the updated Users entity. +func (uuo *UsersUpdateOne) Save(ctx context.Context) (*Users, error) { + var ( + err error + node *Users + ) + if len(uuo.hooks) == 0 { + node, err = uuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UsersMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + uuo.mutation = mutation + node, err = uuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(uuo.hooks) - 1; i >= 0; i-- { + if uuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uuo.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, uuo.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (uuo *UsersUpdateOne) SaveX(ctx context.Context) *Users { + node, err := uuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uuo *UsersUpdateOne) Exec(ctx context.Context) error { + _, err := uuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uuo *UsersUpdateOne) ExecX(ctx context.Context) { + if err := uuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (uuo *UsersUpdateOne) sqlSave(ctx context.Context) (_node *Users, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: users.Table, + Columns: users.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldID, + }, + }, + } + id, ok := uuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Users.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, users.FieldID) + for _, f := range fields { + if !users.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != users.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 uuo.mutation.CharaCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldChara, + }) + } + if uuo.mutation.SkillCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldSkill, + }) + } + if value, ok := uuo.mutation.Hp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldHp, + }) + } + if value, ok := uuo.mutation.AddedHp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldHp, + }) + } + if uuo.mutation.HpCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldHp, + }) + } + if value, ok := uuo.mutation.Attack(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldAttack, + }) + } + if value, ok := uuo.mutation.AddedAttack(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldAttack, + }) + } + if uuo.mutation.AttackCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldAttack, + }) + } + if value, ok := uuo.mutation.Defense(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDefense, + }) + } + if value, ok := uuo.mutation.AddedDefense(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDefense, + }) + } + if uuo.mutation.DefenseCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldDefense, + }) + } + if value, ok := uuo.mutation.Critical(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldCritical, + }) + } + if value, ok := uuo.mutation.AddedCritical(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldCritical, + }) + } + if uuo.mutation.CriticalCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldCritical, + }) + } + if value, ok := uuo.mutation.Battle(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldBattle, + }) + } + if value, ok := uuo.mutation.AddedBattle(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldBattle, + }) + } + if uuo.mutation.BattleCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldBattle, + }) + } + if value, ok := uuo.mutation.Win(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldWin, + }) + } + if value, ok := uuo.mutation.AddedWin(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldWin, + }) + } + if uuo.mutation.WinCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldWin, + }) + } + if value, ok := uuo.mutation.Day(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDay, + }) + } + if value, ok := uuo.mutation.AddedDay(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: users.FieldDay, + }) + } + if uuo.mutation.DayCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: users.FieldDay, + }) + } + if value, ok := uuo.mutation.Percentage(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Value: value, + Column: users.FieldPercentage, + }) + } + if value, ok := uuo.mutation.AddedPercentage(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Value: value, + Column: users.FieldPercentage, + }) + } + if uuo.mutation.PercentageCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat64, + Column: users.FieldPercentage, + }) + } + if value, ok := uuo.mutation.Limit(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: users.FieldLimit, + }) + } + if uuo.mutation.LimitCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Column: users.FieldLimit, + }) + } + if uuo.mutation.StatusCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldStatus, + }) + } + if value, ok := uuo.mutation.Comment(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldComment, + }) + } + if uuo.mutation.CommentCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldComment, + }) + } + if uuo.mutation.CreatedAtCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: users.FieldCreatedAt, + }) + } + if value, ok := uuo.mutation.Next(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: users.FieldNext, + }) + } + if uuo.mutation.NextCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldNext, + }) + } + if value, ok := uuo.mutation.UpdatedAt(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: users.FieldUpdatedAt, + }) + } + if uuo.mutation.UpdatedAtCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: users.FieldUpdatedAt, + }) + } + if uuo.mutation.URLCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: users.FieldURL, + }) + } + _node = &Users{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{users.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + return _node, nil +} diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..edb1501 --- /dev/null +++ b/fly.toml @@ -0,0 +1,29 @@ +# fly.toml file generated for ent on 2022-08-31T13:39:30+09:00 + +app = "ent" +kill_signal = "SIGINT" +kill_timeout = 5 + +[build] + builder = "paketobuildpacks/builder:base" + buildpacks = ["gcr.io/paketo-buildpacks/go"] + +[env] + PORT = "8080" + +[processes] + api = "bin/t" + +[[services]] + internal_port = 8080 + processes = ["api"] + protocol = "tcp" + + [[services.ports]] + force_https = true + handlers = ["http"] + port = 80 + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..dd6f518 --- /dev/null +++ b/go.mod @@ -0,0 +1,59 @@ +module t + +// +heroku goVersion go1.17 +go 1.17 + +require ( + entgo.io/ent v0.10.0 + github.com/go-chi/chi/v5 v5.0.4 + github.com/jackc/pgx/v4 v4.15.0 + github.com/lib/pq v1.10.4 + github.com/mailru/easyjson v0.7.7 + go.uber.org/zap v1.21.0 +) + +require ( + entgo.io/contrib v0.2.1-0.20220210075301-2b75bf138815 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/ariga/ogent v0.0.0-20220224071349-f1dbffa2e32a // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-logr/logr v1.2.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/inflect v0.19.0 // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/google/go-cmp v0.5.7 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.10.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/kyokomi/lottery v1.2.0 // indirect + github.com/segmentio/asm v1.1.3 // indirect + github.com/uniplaces/carbon v0.1.6 // indirect + golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect + golang.org/x/mod v0.5.1 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) + +require ( + ariga.io/atlas v0.3.5 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/go-faster/errors v0.5.0 + github.com/go-faster/jx v0.32.2 + github.com/google/uuid v1.3.0 + github.com/hashicorp/hcl/v2 v2.11.1 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/ogen-go/ogen v0.19.0 + github.com/sergi/go-diff v1.1.0 // indirect + github.com/zclconf/go-cty v1.10.0 // indirect + go.opentelemetry.io/otel v1.4.1 + go.opentelemetry.io/otel/metric v0.27.0 + go.opentelemetry.io/otel/trace v1.4.1 + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.7.0 // indirect + golang.org/x/sys v0.0.0-20220222200937-f2425489ef4c // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c316d9e --- /dev/null +++ b/go.sum @@ -0,0 +1,1006 @@ +ariga.io/atlas v0.3.2-0.20220120225051-c3fac7d636dd/go.mod h1:XcLUpQX7Cq4qtagEHIleq3MJaBeeJ76BS8doc4gkOJk= +ariga.io/atlas v0.3.5 h1:Os42TUebb14I8DUTM68CBvNMP6l59979IX5cU7IdBOM= +ariga.io/atlas v0.3.5/go.mod h1:XcLUpQX7Cq4qtagEHIleq3MJaBeeJ76BS8doc4gkOJk= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +entgo.io/contrib v0.2.1-0.20220210075301-2b75bf138815 h1:VBZtzQqTOHvMVHbGHN1L0uJYq7GQFzenL5Xx04tk+ys= +entgo.io/contrib v0.2.1-0.20220210075301-2b75bf138815/go.mod h1:oDXgxZMWGHZAQcuty41ndZahRrGKFmZHiSaV7YDjhvM= +entgo.io/ent v0.10.0 h1:9cBomE1fh+WX34DPYQL7tDNAIvhKa3tXvwxuLyhYCMo= +entgo.io/ent v0.10.0/go.mod h1:5bjIYdTizykmdtPY3knXrrGpxAh0cMjFfxdNnlNiUGU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= +github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/ariga/ogent v0.0.0-20220224071349-f1dbffa2e32a h1:qoEP5z17RvQoqgR2eEfr/rrt1Ej0ZzPRP6t9UFL8Q6c= +github.com/ariga/ogent v0.0.0-20220224071349-f1dbffa2e32a/go.mod h1:rjSPtPmb4XgkC+63icADHqPuaFxGpSY3oQMFg4c8+lc= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-chi/chi/v5 v5.0.4 h1:5e494iHzsYBiyXQAHHuI4tyJS9M3V84OuX3ufIIGHFo= +github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-faster/errors v0.5.0 h1:hS/zHFJ2Vb14jcupq5J9tk05XW+PFTmySOkDRByHBo4= +github.com/go-faster/errors v0.5.0/go.mod h1:/9SNBcg2ESJTYztBFEiM5Np6ns85BtPNMJd8lFTiFwk= +github.com/go-faster/jx v0.32.1/go.mod h1:T561ezgn74siJgc+QzZzoGHokGBKxV6WZugVyfw+68c= +github.com/go-faster/jx v0.32.2 h1:xrBsEiawju+56UqBpNAjQ3/9ZmiSRzOletSsehRPeRw= +github.com/go-faster/jx v0.32.2/go.mod h1:T561ezgn74siJgc+QzZzoGHokGBKxV6WZugVyfw+68c= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= +github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/hcl/v2 v2.10.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= +github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= +github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= +github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= +github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= +github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= +github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/kyokomi/lottery v1.2.0 h1:oW9YxYv5j/nu/Kkf8K5tu7Vn8dAoZTjluDxihTPX/68= +github.com/kyokomi/lottery v1.2.0/go.mod h1:TkKpJrFrOJNHpblUqYu0bAQWil3NMwKMBluHyqFfU6Y= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= +github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/ogen-go/ogen v0.18.1 h1:BtYFZQGSD8PiTztmDjdnguRWNL/Wwy3fUbrsGACjPLQ= +github.com/ogen-go/ogen v0.18.1/go.mod h1:23nkNYuCSapnQw902m9FARM4qSlI0PkGGRddN3V0SS0= +github.com/ogen-go/ogen v0.19.0 h1:rVU3w2WjA9ivlvDwBKtOsIjqRlUPdxEauoL0db3EOjg= +github.com/ogen-go/ogen v0.19.0/go.mod h1:UFCkfw8gvVfhcda6U+CzRzBxPn5BF8MkxEdWsXadCo4= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= +github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942 h1:t0lM6y/M5IiUZyvbBTcngso8SZEZICH7is9B6g/obVU= +github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/uniplaces/carbon v0.1.6 h1:JVxwWs8FfwAN+PvB2bh9WCZRX2u1Vp77cGXr51uzxJs= +github.com/uniplaces/carbon v0.1.6/go.mod h1:glebpttsTxh8fBbciRAy3WvLfhBVa8n7qfgDTMAuJ3Y= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.33.0/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8ZJjl97LIw4= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= +github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/otel v1.4.0/go.mod h1:jeAqMFKy2uLIxCtKxoFj0FAL5zAPKQagc3+GtBWakzk= +go.opentelemetry.io/otel v1.4.1 h1:QbINgGDDcoQUoMJa2mMaWno49lja9sHwp6aoa2n3a4g= +go.opentelemetry.io/otel v1.4.1/go.mod h1:StM6F/0fSwpd8dKWDCdRr7uRvEPYdW0hBSlbdTiUde4= +go.opentelemetry.io/otel/internal/metric v0.27.0 h1:9dAVGAfFiiEq5NVB9FUJ5et+btbDQAUIJehJ+ikyryk= +go.opentelemetry.io/otel/internal/metric v0.27.0/go.mod h1:n1CVxRqKqYZtqyTh9U/onvKapPGv7y/rpyOTI+LFNzw= +go.opentelemetry.io/otel/metric v0.27.0 h1:HhJPsGhJoKRSegPQILFbODU56NS/L1UE4fS1sC5kIwQ= +go.opentelemetry.io/otel/metric v0.27.0/go.mod h1:raXDJ7uP2/Jc0nVZWQjJtzoyssOYWu/+pjZqRzfvZ7g= +go.opentelemetry.io/otel/trace v1.4.0/go.mod h1:uc3eRsqDfWs9R7b92xbQbU42/eTNz4N+gLP8qJCi4aE= +go.opentelemetry.io/otel/trace v1.4.1 h1:O+16qcdTrT7zxv2J6GejTPFinSwA++cYerC5iSiF8EQ= +go.opentelemetry.io/otel/trace v1.4.1/go.mod h1:iYEVbroFCNut9QkwEczV9vMRPHNKSSwYZjulEtsmhFc= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= +go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI= +golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220222200937-f2425489ef4c h1:sSIdNI2Dd6vGv47bKc/xArpfxVmEz2+3j0E6I484xC4= +golang.org/x/sys v0.0.0-20220222200937-f2425489ef4c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.9-0.20211216111533-8d383106f7e7/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/main.go b/main.go new file mode 100644 index 0000000..948c2a5 --- /dev/null +++ b/main.go @@ -0,0 +1,146 @@ +package main + +import ( +"strconv" + "time" + "t/ent" + "net/http" + "math/rand" + "context" + "log" + "os" + "database/sql" + entsql "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect" + _ "github.com/jackc/pgx/v4/stdlib" + _ "github.com/lib/pq" + "t/ent/ogent" + "entgo.io/ent/dialect/sql/schema" + "github.com/kyokomi/lottery" +) + +type User struct { + user string `json:"user"` + created_at time.Time `json:"created_at"` +} + +func Open(databaseUrl string) *ent.Client { + db, err := sql.Open("pgx", databaseUrl) + if err != nil { + log.Fatal(err) + } + drv := entsql.OpenDB(dialect.Postgres, db) + return ent.NewClient(ent.Driver(drv)) +} + +func Random(i int) (l int){ + rand.Seed(time.Now().UnixNano()) + l = rand.Intn(i) + for l == 0 { + l = rand.Intn(i) + } + return +} + +func Kira(i int) (l bool){ + lot := lottery.New(rand.New(rand.NewSource(time.Now().UnixNano()))) + if lot.Lot(i) { + l = true + } else { + l = false + } + return +} + +type handler struct { + *ogent.OgentHandler + client *ent.Client +} + + +func (h handler) DrawStart(ctx context.Context, params ogent.DrawStartParams) (ogent.DrawStartNoContent, error) { + return ogent.DrawStartNoContent{}, h.client.Users.UpdateOneID(params.ID).Exec(ctx) +} + +func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) (ogent.DrawDoneNoContent, error) { + body := h.client.Users.GetX(ctx, params.ID) + total := body.Day + total_n := total + 1 + jst, err := time.LoadLocation("Asia/Tokyo") + if err != nil { + panic(err) + } + t := time.Now().In(jst) + tt := t.Format("20060102") + f := body.UpdatedAt.Add(time.Hour * 24 * 1).In(jst) + ff := f.Format("20060102") + fff := body.Next + if tt < fff { + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetNext(ff).SetLimit(true).Exec(ctx) + } + + bb := h.client.Users.GetX(ctx, body.Battle) + ba := bb.Attack + aa := body.Attack + attack_p := aa - ba + win_n := body.Win + 1 + pat := float64(win_n) / float64(total_n) * 100 + var at int + if attack_p > 0 { + at = Random(55) + } else { + at = Random(45) + } + if at > 25 { + b := Random(4) + if b == 1 { + b := Random(10) + com := "attack+" + strconv.Itoa(b) + a := body.Attack + b + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetAttack(a).SetUpdatedAt(t).SetNext(ff).SetDay(total_n).SetWin(win_n).SetPercentage(pat).SetLimit(false).SetComment(com).Exec(ctx) + } else if b == 2 { + b := Random(10) + com := "defense+" + strconv.Itoa(b) + a := body.Defense + b + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetDefense(a).SetUpdatedAt(t).SetNext(ff).SetDay(total_n).SetWin(win_n).SetPercentage(pat).SetLimit(false).SetComment(com).Exec(ctx) + } else if b == 3 { + b := Random(10) + com := "hp+" + strconv.Itoa(b) + a := body.Hp + b + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetHp(a).SetUpdatedAt(t).SetNext(ff).SetDay(total_n).SetWin(win_n).SetPercentage(pat).SetComment(com).SetLimit(false).Exec(ctx) + } else { + b := Random(10) + com := "critical+" + strconv.Itoa(b) + a := body.Critical + b + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetCritical(a).SetUpdatedAt(t).SetNext(ff).SetDay(total_n).SetWin(win_n).SetPercentage(pat).SetComment(com).SetLimit(false).SetWin(win_n).Exec(ctx) + } +} else { + com := "loss" + return ogent.DrawDoneNoContent{}, h.client.Users.UpdateOneID(params.ID).SetNext(ff).SetDay(total_n).SetComment(com).SetLimit(false).Exec(ctx) +} +} + +func main() { + url := os.Getenv("DATABASE_URL") + "?sslmode=require" + client, err := ent.Open("postgres", url) + //client, err := Open(url) + if err := client.Schema.Create(context.Background(), schema.WithAtlas(true)); err != nil { + log.Fatal(err) + } + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + h := handler{ + OgentHandler: ogent.NewOgentHandler(client), + client: client, + } + srv,err := ogent.NewServer(h) + //srv,err := ogent.NewServer(ogent.NewOgentHandler(client)) + if err != nil { + log.Fatal(err) + } + if err := http.ListenAndServe(":" + port, srv); err != nil { + log.Fatal(err) + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..22b7123 --- /dev/null +++ b/readme.md @@ -0,0 +1,78 @@ +heroku open-api ent example + +- go-module-name : t + +- onconflict + +```sh +$ curl -X POST -H "Content-Type: application/json" -d '{"user":"syui"}' api.syui.cf/users +...ok + +$ !! +...err + +$ heroku logs +``` + + +```sh +# delete +$ curl -X DELETE https://api.syui.cf/users/1 + +# card draw +$ curl -X PUT api.syui.cf/users/1/d +$ curl api.syui.cf/users/1 + +# patch +$ curl -X PATCH -H "Content-Type: application/json" -d '{"battle":2}' api.syui.cf/users/1 +$ curl -X PATCH -H "Content-Type: application/json" -d '{"limit":false}' api.syui.cf/users/1 +$ d=`date "+%Y%m%d"` +$ curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$d\"}" api.syui.cf/users/1 +``` + +```sh +$ vim ./ent/ogent/ogent.go +// 新規登録の停止 +// CreateUsers handles POST /users-slice requests. +func (h *OgentHandler) CreateUsers(ctx context.Context, req CreateUsersReq) (CreateUsersRes, error) { + b := h.client.Users.Create() + //b.SetUser(req.User) + b.SetUser("syui") +} + +// 削除の無効 +// DeleteUsers handles DELETE /users-slice/{id} requests. +func (h *OgentHandler) DeleteUsers(ctx context.Context, params DeleteUsersParams) (DeleteUsersRes, error) { + if params.ID != 1 { +err := h.client.Users.DeleteOneID(params.ID).Exec(ctx) + } + return new(DeleteUsersNoContent), nil +} + +// 要素の書き換えの禁止 +// UpdateUsers handles PATCH /users-slice/{id} requests. +func (h *OgentHandler) UpdateUsers(ctx context.Context, req UpdateUsersReq, params UpdateUsersParams) (UpdateUsersRes, error) { + b := h.client.Users.UpdateOneID(params.ID) + // Add all fields. + //if v, ok := req.Hp.Get(); ok { + // b.SetHp(v) + //} +``` + +ref : + +- https://github.com/ent/ent/blob/master/dialect/sql/schema/postgres_test.go + +- https://github.com/go-kratos/beer-shop/tree/main/app/catalog/service/internal/data/ent + +- https://entgo.io/ja/blog/2022/02/15/generate-rest-crud-with-ent-and-ogen/ + +- https://github.com/ariga/ogent/blob/main/example/todo/ent/entc.go + +```sh +$ vim ent/entc.go +$ vim ent/schema/users.go +$ go generate ./... +$ go build +$ ./t +```