update game ue
This commit is contained in:
parent
ca01557445
commit
f1bfdf41fb
164
ent/client.go
164
ent/client.go
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
@ -29,6 +30,8 @@ type Client struct {
|
||||
Card *CardClient
|
||||
// Group is the client for interacting with the Group builders.
|
||||
Group *GroupClient
|
||||
// Ue is the client for interacting with the Ue builders.
|
||||
Ue *UeClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
}
|
||||
@ -46,6 +49,7 @@ func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.Card = NewCardClient(c.config)
|
||||
c.Group = NewGroupClient(c.config)
|
||||
c.Ue = NewUeClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
}
|
||||
|
||||
@ -131,6 +135,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
config: cfg,
|
||||
Card: NewCardClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
Ue: NewUeClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@ -153,6 +158,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
config: cfg,
|
||||
Card: NewCardClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
Ue: NewUeClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@ -184,6 +190,7 @@ func (c *Client) Close() error {
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.Card.Use(hooks...)
|
||||
c.Group.Use(hooks...)
|
||||
c.Ue.Use(hooks...)
|
||||
c.User.Use(hooks...)
|
||||
}
|
||||
|
||||
@ -192,6 +199,7 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
c.Card.Intercept(interceptors...)
|
||||
c.Group.Intercept(interceptors...)
|
||||
c.Ue.Intercept(interceptors...)
|
||||
c.User.Intercept(interceptors...)
|
||||
}
|
||||
|
||||
@ -202,6 +210,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.Card.mutate(ctx, m)
|
||||
case *GroupMutation:
|
||||
return c.Group.mutate(ctx, m)
|
||||
case *UeMutation:
|
||||
return c.Ue.mutate(ctx, m)
|
||||
case *UserMutation:
|
||||
return c.User.mutate(ctx, m)
|
||||
default:
|
||||
@ -477,6 +487,140 @@ func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, erro
|
||||
}
|
||||
}
|
||||
|
||||
// UeClient is a client for the Ue schema.
|
||||
type UeClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewUeClient returns a client for the Ue from the given config.
|
||||
func NewUeClient(c config) *UeClient {
|
||||
return &UeClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `ue.Hooks(f(g(h())))`.
|
||||
func (c *UeClient) Use(hooks ...Hook) {
|
||||
c.hooks.Ue = append(c.hooks.Ue, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `ue.Intercept(f(g(h())))`.
|
||||
func (c *UeClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Ue = append(c.inters.Ue, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Ue entity.
|
||||
func (c *UeClient) Create() *UeCreate {
|
||||
mutation := newUeMutation(c.config, OpCreate)
|
||||
return &UeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Ue entities.
|
||||
func (c *UeClient) CreateBulk(builders ...*UeCreate) *UeCreateBulk {
|
||||
return &UeCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Ue.
|
||||
func (c *UeClient) Update() *UeUpdate {
|
||||
mutation := newUeMutation(c.config, OpUpdate)
|
||||
return &UeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *UeClient) UpdateOne(u *Ue) *UeUpdateOne {
|
||||
mutation := newUeMutation(c.config, OpUpdateOne, withUe(u))
|
||||
return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *UeClient) UpdateOneID(id int) *UeUpdateOne {
|
||||
mutation := newUeMutation(c.config, OpUpdateOne, withUeID(id))
|
||||
return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Ue.
|
||||
func (c *UeClient) Delete() *UeDelete {
|
||||
mutation := newUeMutation(c.config, OpDelete)
|
||||
return &UeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *UeClient) DeleteOne(u *Ue) *UeDeleteOne {
|
||||
return c.DeleteOneID(u.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *UeClient) DeleteOneID(id int) *UeDeleteOne {
|
||||
builder := c.Delete().Where(ue.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &UeDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Ue.
|
||||
func (c *UeClient) Query() *UeQuery {
|
||||
return &UeQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeUe},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Ue entity by its id.
|
||||
func (c *UeClient) Get(ctx context.Context, id int) (*Ue, error) {
|
||||
return c.Query().Where(ue.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *UeClient) GetX(ctx context.Context, id int) *Ue {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryOwner queries the owner edge of a Ue.
|
||||
func (c *UeClient) QueryOwner(u *Ue) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ue.Table, ue.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *UeClient) Hooks() []Hook {
|
||||
return c.hooks.Ue
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *UeClient) Interceptors() []Interceptor {
|
||||
return c.inters.Ue
|
||||
}
|
||||
|
||||
func (c *UeClient) mutate(ctx context.Context, m *UeMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&UeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&UeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&UeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Ue mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// UserClient is a client for the User schema.
|
||||
type UserClient struct {
|
||||
config
|
||||
@ -586,6 +730,22 @@ func (c *UserClient) QueryCard(u *User) *CardQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUe queries the ue edge of a User.
|
||||
func (c *UserClient) QueryUe(u *User) *UeQuery {
|
||||
query := (&UeClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(ue.Table, ue.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *UserClient) Hooks() []Hook {
|
||||
return c.hooks.User
|
||||
@ -614,9 +774,9 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error)
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
Card, Group, User []ent.Hook
|
||||
Card, Group, Ue, User []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
Card, Group, User []ent.Interceptor
|
||||
Card, Group, Ue, User []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"reflect"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
@ -69,6 +70,7 @@ func columnChecker(table string) func(string) error {
|
||||
checks := map[string]func(string) bool{
|
||||
card.Table: card.ValidColumn,
|
||||
group.Table: group.ValidColumn,
|
||||
ue.Table: ue.ValidColumn,
|
||||
user.Table: user.ValidColumn,
|
||||
}
|
||||
check, ok := checks[table]
|
||||
|
@ -32,6 +32,18 @@ func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupMutation", m)
|
||||
}
|
||||
|
||||
// The UeFunc type is an adapter to allow the use of ordinary
|
||||
// function as Ue mutator.
|
||||
type UeFunc func(context.Context, *ent.UeMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f UeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.UeMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UeMutation", m)
|
||||
}
|
||||
|
||||
// The UserFunc type is an adapter to allow the use of ordinary
|
||||
// function as User mutator.
|
||||
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||
|
@ -56,6 +56,44 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// UesColumns holds the columns for the "ues" table.
|
||||
UesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "limit", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "limit_boss", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "limit_item", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "lv", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "lv_point", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "sword", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "card", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "mode", Type: field.TypeString, Nullable: true},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cp", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "count", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_x", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_y", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_z", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_n", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "author", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "user_ue", Type: field.TypeInt},
|
||||
}
|
||||
// UesTable holds the schema information for the "ues" table.
|
||||
UesTable = &schema.Table{
|
||||
Name: "ues",
|
||||
Columns: UesColumns,
|
||||
PrimaryKey: []*schema.Column{UesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "ues_users_ue",
|
||||
Columns: []*schema.Column{UesColumns[20]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
@ -91,7 +129,7 @@ var (
|
||||
{Name: "ten_post", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_get", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20231231"},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20240203"},
|
||||
{Name: "room", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model", Type: field.TypeBool, Nullable: true},
|
||||
{Name: "model_at", Type: field.TypeTime, Nullable: true},
|
||||
@ -133,11 +171,13 @@ var (
|
||||
Tables = []*schema.Table{
|
||||
CardsTable,
|
||||
GroupsTable,
|
||||
UesTable,
|
||||
UsersTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
CardsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
UesTable.ForeignKeys[0].RefTable = UsersTable
|
||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
}
|
||||
|
2178
ent/mutation.go
2178
ent/mutation.go
File diff suppressed because it is too large
Load Diff
@ -201,6 +201,77 @@ func (c *Client) sendCreateGroup(ctx context.Context, request *CreateGroupReq) (
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateUe invokes createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
func (c *Client) CreateUe(ctx context.Context, request *CreateUeReq) (CreateUeRes, error) {
|
||||
res, err := c.sendCreateUe(ctx, request)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendCreateUe(ctx context.Context, request *CreateUeReq) (res CreateUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("createUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "CreateUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues"
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "POST", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeCreateUeRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeCreateUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateUser invokes createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@ -436,6 +507,88 @@ func (c *Client) sendDeleteGroup(ctx context.Context, params DeleteGroupParams)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteUe invokes deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
func (c *Client) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
|
||||
res, err := c.sendDeleteUe(ctx, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendDeleteUe(ctx context.Context, params DeleteUeParams) (res DeleteUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("deleteUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "DeleteUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues/"
|
||||
{
|
||||
// Encode "id" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "id",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.IntToString(params.ID))
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "encode path")
|
||||
}
|
||||
u.Path += e.Result()
|
||||
}
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "DELETE", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeDeleteUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteUser invokes deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@ -1017,6 +1170,112 @@ func (c *Client) sendListGroupUsers(ctx context.Context, params ListGroupUsersPa
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListUe invokes listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
func (c *Client) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) {
|
||||
res, err := c.sendListUe(ctx, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendListUe(ctx context.Context, params ListUeParams) (res ListUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("listUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "ListUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues"
|
||||
|
||||
stage = "EncodeQueryParams"
|
||||
q := uri.NewQueryEncoder()
|
||||
{
|
||||
// Encode "page" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "page",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.Page.Get(); ok {
|
||||
return e.EncodeValue(conv.IntToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "itemsPerPage" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "itemsPerPage",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.ItemsPerPage.Get(); ok {
|
||||
return e.EncodeValue(conv.IntToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
u.RawQuery = q.Values().Encode()
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "GET", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeListUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListUser invokes listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@ -1244,6 +1503,127 @@ func (c *Client) sendListUserCard(ctx context.Context, params ListUserCardParams
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListUserUe invokes listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
func (c *Client) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) {
|
||||
res, err := c.sendListUserUe(ctx, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendListUserUe(ctx context.Context, params ListUserUeParams) (res ListUserUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("listUserUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "ListUserUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/users/"
|
||||
{
|
||||
// Encode "id" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "id",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.IntToString(params.ID))
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "encode path")
|
||||
}
|
||||
u.Path += e.Result()
|
||||
}
|
||||
u.Path += "/ue"
|
||||
|
||||
stage = "EncodeQueryParams"
|
||||
q := uri.NewQueryEncoder()
|
||||
{
|
||||
// Encode "page" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "page",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.Page.Get(); ok {
|
||||
return e.EncodeValue(conv.IntToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "itemsPerPage" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "itemsPerPage",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.ItemsPerPage.Get(); ok {
|
||||
return e.EncodeValue(conv.IntToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
u.RawQuery = q.Values().Encode()
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "GET", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeListUserUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReadCard invokes readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@ -1491,6 +1871,171 @@ func (c *Client) sendReadGroup(ctx context.Context, params ReadGroupParams) (res
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReadUe invokes readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
func (c *Client) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) {
|
||||
res, err := c.sendReadUe(ctx, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendReadUe(ctx context.Context, params ReadUeParams) (res ReadUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "ReadUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues/"
|
||||
{
|
||||
// Encode "id" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "id",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.IntToString(params.ID))
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "encode path")
|
||||
}
|
||||
u.Path += e.Result()
|
||||
}
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "GET", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeReadUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReadUeOwner invokes readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
func (c *Client) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) {
|
||||
res, err := c.sendReadUeOwner(ctx, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (res ReadUeOwnerRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readUeOwner"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "ReadUeOwner",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues/"
|
||||
{
|
||||
// Encode "id" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "id",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.IntToString(params.ID))
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "encode path")
|
||||
}
|
||||
u.Path += e.Result()
|
||||
}
|
||||
u.Path += "/owner"
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "GET", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeReadUeOwnerResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReadUser invokes readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@ -1743,6 +2288,91 @@ func (c *Client) sendUpdateGroup(ctx context.Context, request *UpdateGroupReq, p
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateUe invokes updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
func (c *Client) UpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) {
|
||||
res, err := c.sendUpdateUe(ctx, request, params)
|
||||
_ = res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendUpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (res UpdateUeRes, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateUe"),
|
||||
}
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
c.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, "UpdateUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
// Track stage for error reporting.
|
||||
var stage string
|
||||
defer func() {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
c.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
|
||||
stage = "BuildURL"
|
||||
u := uri.Clone(c.requestURL(ctx))
|
||||
u.Path += "/ues/"
|
||||
{
|
||||
// Encode "id" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "id",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.IntToString(params.ID))
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "encode path")
|
||||
}
|
||||
u.Path += e.Result()
|
||||
}
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeUpdateUeRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
stage = "SendRequest"
|
||||
resp, err := c.cfg.Client.Do(r)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeUpdateUeResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateUser invokes updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
@ -221,6 +221,108 @@ func (s *Server) handleCreateGroupRequest(args [0]string, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
// handleCreateUeRequest handles createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
func (s *Server) handleCreateUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("createUe"),
|
||||
semconv.HTTPMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/ues"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "CreateUe",
|
||||
ID: "createUe",
|
||||
}
|
||||
)
|
||||
request, close, err := s.decodeCreateUeRequest(r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeRequestError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeRequest", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := close(); err != nil {
|
||||
recordError("CloseRequest", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var response CreateUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "CreateUe",
|
||||
OperationID: "createUe",
|
||||
Body: request,
|
||||
Params: middleware.Parameters{},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = *CreateUeReq
|
||||
Params = struct{}
|
||||
Response = CreateUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
nil,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.CreateUe(ctx, request)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.CreateUe(ctx, request)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeCreateUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleCreateUserRequest handles createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@ -527,6 +629,108 @@ func (s *Server) handleDeleteGroupRequest(args [1]string, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
// handleDeleteUeRequest handles deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
func (s *Server) handleDeleteUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("deleteUe"),
|
||||
semconv.HTTPMethodKey.String("DELETE"),
|
||||
semconv.HTTPRouteKey.String("/ues/{id}"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "DeleteUe",
|
||||
ID: "deleteUe",
|
||||
}
|
||||
)
|
||||
params, err := decodeDeleteUeParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var response DeleteUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "DeleteUe",
|
||||
OperationID: "deleteUe",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}: params.ID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = DeleteUeParams
|
||||
Response = DeleteUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackDeleteUeParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.DeleteUe(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.DeleteUe(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeDeleteUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleDeleteUserRequest handles deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@ -1155,6 +1359,112 @@ func (s *Server) handleListGroupUsersRequest(args [1]string, w http.ResponseWrit
|
||||
}
|
||||
}
|
||||
|
||||
// handleListUeRequest handles listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
func (s *Server) handleListUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("listUe"),
|
||||
semconv.HTTPMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ues"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "ListUe",
|
||||
ID: "listUe",
|
||||
}
|
||||
)
|
||||
params, err := decodeListUeParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var response ListUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "ListUe",
|
||||
OperationID: "listUe",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
}: params.Page,
|
||||
{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
}: params.ItemsPerPage,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = ListUeParams
|
||||
Response = ListUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackListUeParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.ListUe(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.ListUe(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeListUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleListUserRequest handles listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@ -1371,6 +1681,116 @@ func (s *Server) handleListUserCardRequest(args [1]string, w http.ResponseWriter
|
||||
}
|
||||
}
|
||||
|
||||
// handleListUserUeRequest handles listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
func (s *Server) handleListUserUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("listUserUe"),
|
||||
semconv.HTTPMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/users/{id}/ue"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUserUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "ListUserUe",
|
||||
ID: "listUserUe",
|
||||
}
|
||||
)
|
||||
params, err := decodeListUserUeParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var response ListUserUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "ListUserUe",
|
||||
OperationID: "listUserUe",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}: params.ID,
|
||||
{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
}: params.Page,
|
||||
{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
}: params.ItemsPerPage,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = ListUserUeParams
|
||||
Response = ListUserUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackListUserUeParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.ListUserUe(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.ListUserUe(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeListUserUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleReadCardRequest handles readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@ -1677,6 +2097,210 @@ func (s *Server) handleReadGroupRequest(args [1]string, w http.ResponseWriter, r
|
||||
}
|
||||
}
|
||||
|
||||
// handleReadUeRequest handles readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
func (s *Server) handleReadUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readUe"),
|
||||
semconv.HTTPMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ues/{id}"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "ReadUe",
|
||||
ID: "readUe",
|
||||
}
|
||||
)
|
||||
params, err := decodeReadUeParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var response ReadUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "ReadUe",
|
||||
OperationID: "readUe",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}: params.ID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = ReadUeParams
|
||||
Response = ReadUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackReadUeParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.ReadUe(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.ReadUe(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeReadUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleReadUeOwnerRequest handles readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
func (s *Server) handleReadUeOwnerRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readUeOwner"),
|
||||
semconv.HTTPMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ues/{id}/owner"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUeOwner",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "ReadUeOwner",
|
||||
ID: "readUeOwner",
|
||||
}
|
||||
)
|
||||
params, err := decodeReadUeOwnerParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var response ReadUeOwnerRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "ReadUeOwner",
|
||||
OperationID: "readUeOwner",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}: params.ID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = ReadUeOwnerParams
|
||||
Response = ReadUeOwnerRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackReadUeOwnerParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.ReadUeOwner(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.ReadUeOwner(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeReadUeOwnerResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleReadUserRequest handles readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@ -2013,6 +2637,123 @@ func (s *Server) handleUpdateGroupRequest(args [1]string, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
// handleUpdateUeRequest handles updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
func (s *Server) handleUpdateUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateUe"),
|
||||
semconv.HTTPMethodKey.String("PATCH"),
|
||||
semconv.HTTPRouteKey.String("/ues/{id}"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateUe",
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
|
||||
}()
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, otelAttrs...)
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, stage)
|
||||
s.errors.Add(ctx, 1, otelAttrs...)
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: "UpdateUe",
|
||||
ID: "updateUe",
|
||||
}
|
||||
)
|
||||
params, err := decodeUpdateUeParams(args, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
request, close, err := s.decodeUpdateUeRequest(r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeRequestError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
recordError("DecodeRequest", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := close(); err != nil {
|
||||
recordError("CloseRequest", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var response UpdateUeRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: "UpdateUe",
|
||||
OperationID: "updateUe",
|
||||
Body: request,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}: params.ID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = *UpdateUeReq
|
||||
Params = UpdateUeParams
|
||||
Response = UpdateUeRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackUpdateUeParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.UpdateUe(ctx, request, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.UpdateUe(ctx, request, params)
|
||||
}
|
||||
if err != nil {
|
||||
recordError("Internal", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeUpdateUeResponse(response, w, span); err != nil {
|
||||
recordError("EncodeResponse", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleUpdateUserRequest handles updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
@ -9,6 +9,10 @@ type CreateGroupRes interface {
|
||||
createGroupRes()
|
||||
}
|
||||
|
||||
type CreateUeRes interface {
|
||||
createUeRes()
|
||||
}
|
||||
|
||||
type CreateUserRes interface {
|
||||
createUserRes()
|
||||
}
|
||||
@ -21,6 +25,10 @@ type DeleteGroupRes interface {
|
||||
deleteGroupRes()
|
||||
}
|
||||
|
||||
type DeleteUeRes interface {
|
||||
deleteUeRes()
|
||||
}
|
||||
|
||||
type DeleteUserRes interface {
|
||||
deleteUserRes()
|
||||
}
|
||||
@ -37,6 +45,10 @@ type ListGroupUsersRes interface {
|
||||
listGroupUsersRes()
|
||||
}
|
||||
|
||||
type ListUeRes interface {
|
||||
listUeRes()
|
||||
}
|
||||
|
||||
type ListUserCardRes interface {
|
||||
listUserCardRes()
|
||||
}
|
||||
@ -45,6 +57,10 @@ type ListUserRes interface {
|
||||
listUserRes()
|
||||
}
|
||||
|
||||
type ListUserUeRes interface {
|
||||
listUserUeRes()
|
||||
}
|
||||
|
||||
type ReadCardOwnerRes interface {
|
||||
readCardOwnerRes()
|
||||
}
|
||||
@ -57,6 +73,14 @@ type ReadGroupRes interface {
|
||||
readGroupRes()
|
||||
}
|
||||
|
||||
type ReadUeOwnerRes interface {
|
||||
readUeOwnerRes()
|
||||
}
|
||||
|
||||
type ReadUeRes interface {
|
||||
readUeRes()
|
||||
}
|
||||
|
||||
type ReadUserRes interface {
|
||||
readUserRes()
|
||||
}
|
||||
@ -69,6 +93,10 @@ type UpdateGroupRes interface {
|
||||
updateGroupRes()
|
||||
}
|
||||
|
||||
type UpdateUeRes interface {
|
||||
updateUeRes()
|
||||
}
|
||||
|
||||
type UpdateUserRes interface {
|
||||
updateUserRes()
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -139,6 +139,68 @@ func decodeDeleteGroupParams(args [1]string, r *http.Request) (params DeleteGrou
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// DeleteUeParams is parameters of deleteUe operation.
|
||||
type DeleteUeParams struct {
|
||||
// ID of the Ue.
|
||||
ID int
|
||||
}
|
||||
|
||||
func unpackDeleteUeParams(packed middleware.Parameters) (params DeleteUeParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}
|
||||
params.ID = packed[key].(int)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeDeleteUeParams(args [1]string, r *http.Request) (params DeleteUeParams, _ error) {
|
||||
// Decode path: id.
|
||||
if err := func() error {
|
||||
param, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.ID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// DeleteUserParams is parameters of deleteUser operation.
|
||||
type DeleteUserParams struct {
|
||||
// ID of the User.
|
||||
@ -820,6 +882,171 @@ func decodeListGroupUsersParams(args [1]string, r *http.Request) (params ListGro
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListUeParams is parameters of listUe operation.
|
||||
type ListUeParams struct {
|
||||
// What page to render.
|
||||
Page OptInt
|
||||
// Item count to render per page.
|
||||
ItemsPerPage OptInt
|
||||
}
|
||||
|
||||
func unpackListUeParams(packed middleware.Parameters) (params ListUeParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Page = v.(OptInt)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.ItemsPerPage = v.(OptInt)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListUeParams(args [0]string, r *http.Request) (params ListUeParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Decode query: page.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "page",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotPageVal int
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotPageVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Page.SetTo(paramsDotPageVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if params.Page.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: false,
|
||||
Max: 0,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
}).Validate(int64(params.Page.Value)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: itemsPerPage.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "itemsPerPage",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotItemsPerPageVal int
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotItemsPerPageVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if params.ItemsPerPage.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
}).Validate(int64(params.ItemsPerPage.Value)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListUserParams is parameters of listUser operation.
|
||||
type ListUserParams struct {
|
||||
// What page to render.
|
||||
@ -1152,6 +1379,173 @@ func decodeListUserCardParams(args [1]string, r *http.Request) (params ListUserC
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListUserUeParams is parameters of listUserUe operation.
|
||||
type ListUserUeParams struct {
|
||||
// ID of the User.
|
||||
ID int
|
||||
// What page to render.
|
||||
Page OptInt
|
||||
// Item count to render per page.
|
||||
ItemsPerPage OptInt
|
||||
}
|
||||
|
||||
func unpackListUserUeParams(packed middleware.Parameters) (params ListUserUeParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}
|
||||
params.ID = packed[key].(int)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Page = v.(OptInt)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.ItemsPerPage = v.(OptInt)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListUserUeParams(args [1]string, r *http.Request) (params ListUserUeParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Decode path: id.
|
||||
if err := func() error {
|
||||
param, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.ID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: page.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "page",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotPageVal int
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotPageVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Page.SetTo(paramsDotPageVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: itemsPerPage.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "itemsPerPage",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotItemsPerPageVal int
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotItemsPerPageVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "itemsPerPage",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReadCardParams is parameters of readCard operation.
|
||||
type ReadCardParams struct {
|
||||
// ID of the Card.
|
||||
@ -1338,6 +1732,130 @@ func decodeReadGroupParams(args [1]string, r *http.Request) (params ReadGroupPar
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReadUeParams is parameters of readUe operation.
|
||||
type ReadUeParams struct {
|
||||
// ID of the Ue.
|
||||
ID int
|
||||
}
|
||||
|
||||
func unpackReadUeParams(packed middleware.Parameters) (params ReadUeParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}
|
||||
params.ID = packed[key].(int)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeReadUeParams(args [1]string, r *http.Request) (params ReadUeParams, _ error) {
|
||||
// Decode path: id.
|
||||
if err := func() error {
|
||||
param, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.ID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReadUeOwnerParams is parameters of readUeOwner operation.
|
||||
type ReadUeOwnerParams struct {
|
||||
// ID of the Ue.
|
||||
ID int
|
||||
}
|
||||
|
||||
func unpackReadUeOwnerParams(packed middleware.Parameters) (params ReadUeOwnerParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}
|
||||
params.ID = packed[key].(int)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeReadUeOwnerParams(args [1]string, r *http.Request) (params ReadUeOwnerParams, _ error) {
|
||||
// Decode path: id.
|
||||
if err := func() error {
|
||||
param, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.ID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReadUserParams is parameters of readUser operation.
|
||||
type ReadUserParams struct {
|
||||
// ID of the User.
|
||||
@ -1524,6 +2042,68 @@ func decodeUpdateGroupParams(args [1]string, r *http.Request) (params UpdateGrou
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateUeParams is parameters of updateUe operation.
|
||||
type UpdateUeParams struct {
|
||||
// ID of the Ue.
|
||||
ID int
|
||||
}
|
||||
|
||||
func unpackUpdateUeParams(packed middleware.Parameters) (params UpdateUeParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
}
|
||||
params.ID = packed[key].(int)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUpdateUeParams(args [1]string, r *http.Request) (params UpdateUeParams, _ error) {
|
||||
// Decode path: id.
|
||||
if err := func() error {
|
||||
param, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.ID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateUserParams is parameters of updateUser operation.
|
||||
type UpdateUserParams struct {
|
||||
// ID of the User.
|
||||
|
@ -141,6 +141,69 @@ func (s *Server) decodeCreateGroupRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateUeRequest(r *http.Request) (
|
||||
req *CreateUeReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request CreateUeReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateUserRequest(r *http.Request) (
|
||||
req *CreateUserReq,
|
||||
close func() error,
|
||||
@ -330,6 +393,69 @@ func (s *Server) decodeUpdateGroupRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateUeRequest(r *http.Request) (
|
||||
req *UpdateUeReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request UpdateUeReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateUserRequest(r *http.Request) (
|
||||
req *UpdateUserReq,
|
||||
close func() error,
|
||||
|
@ -39,6 +39,20 @@ func encodeCreateGroupRequest(
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateUeRequest(
|
||||
req *CreateUeReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateUserRequest(
|
||||
req *CreateUserReq,
|
||||
r *http.Request,
|
||||
@ -81,6 +95,20 @@ func encodeUpdateGroupRequest(
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateUeRequest(
|
||||
req *UpdateUeReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateUserRequest(
|
||||
req *UpdateUserReq,
|
||||
r *http.Request,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeCreate:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeCreateUserResponse(response CreateUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UserCreate:
|
||||
@ -298,6 +353,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *DeleteUeNoContent:
|
||||
w.WriteHeader(204)
|
||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeDeleteUserResponse(response DeleteUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *DeleteUserNoContent:
|
||||
@ -575,6 +691,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ListUeOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
@ -711,6 +894,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ListUserUeOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
@ -914,6 +1164,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeOwnerRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
switch response := response.(type) {
|
||||
@ -1116,6 +1500,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeUpdate:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUpdateUserResponse(response UpdateUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UserUpdate:
|
||||
|
@ -243,8 +243,98 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "users"
|
||||
if l := len("users"); len(elem) >= l && elem[0:l] == "users" {
|
||||
case 'u': // Prefix: "u"
|
||||
if l := len("u"); len(elem) >= l && elem[0:l] == "u" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'e': // Prefix: "es"
|
||||
if l := len("es"); len(elem) >= l && elem[0:l] == "es" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUeRequest([0]string{}, w, r)
|
||||
case "POST":
|
||||
s.handleCreateUeRequest([0]string{}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "GET":
|
||||
s.handleReadUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "PATCH":
|
||||
s.handleUpdateUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleReadUeOwnerRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sers"
|
||||
if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@ -300,8 +390,19 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/card"
|
||||
if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'c': // Prefix: "card"
|
||||
if l := len("card"); len(elem) >= l && elem[0:l] == "card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@ -341,6 +442,28 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "ue"
|
||||
if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -647,8 +770,114 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "users"
|
||||
if l := len("users"); len(elem) >= l && elem[0:l] == "users" {
|
||||
case 'u': // Prefix: "u"
|
||||
if l := len("u"); len(elem) >= l && elem[0:l] == "u" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'e': // Prefix: "es"
|
||||
if l := len("es"); len(elem) >= l && elem[0:l] == "es" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListUe"
|
||||
r.operationID = "listUe"
|
||||
r.pathPattern = "/ues"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = "CreateUe"
|
||||
r.operationID = "createUe"
|
||||
r.pathPattern = "/ues"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = "DeleteUe"
|
||||
r.operationID = "deleteUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = "ReadUe"
|
||||
r.operationID = "readUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
r.name = "UpdateUe"
|
||||
r.operationID = "updateUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ReadUeOwner
|
||||
r.name = "ReadUeOwner"
|
||||
r.operationID = "readUeOwner"
|
||||
r.pathPattern = "/ues/{id}/owner"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sers"
|
||||
if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@ -719,8 +948,19 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/card"
|
||||
if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'c': // Prefix: "card"
|
||||
if l := len("card"); len(elem) >= l && elem[0:l] == "card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@ -762,6 +1002,29 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "ue"
|
||||
if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ListUserUe
|
||||
r.name = "ListUserUe"
|
||||
r.operationID = "listUserUe"
|
||||
r.pathPattern = "/users/{id}/ue"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,12 @@ type Handler interface {
|
||||
//
|
||||
// POST /groups
|
||||
CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error)
|
||||
// CreateUe implements createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error)
|
||||
// CreateUser implements createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@ -38,6 +44,12 @@ type Handler interface {
|
||||
//
|
||||
// DELETE /groups/{id}
|
||||
DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error)
|
||||
// DeleteUe implements deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error)
|
||||
// DeleteUser implements deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@ -74,6 +86,12 @@ type Handler interface {
|
||||
//
|
||||
// GET /groups/{id}/users
|
||||
ListGroupUsers(ctx context.Context, params ListGroupUsersParams) (ListGroupUsersRes, error)
|
||||
// ListUe implements listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error)
|
||||
// ListUser implements listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@ -86,6 +104,12 @@ type Handler interface {
|
||||
//
|
||||
// GET /users/{id}/card
|
||||
ListUserCard(ctx context.Context, params ListUserCardParams) (ListUserCardRes, error)
|
||||
// ListUserUe implements listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error)
|
||||
// ReadCard implements readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@ -104,6 +128,18 @@ type Handler interface {
|
||||
//
|
||||
// GET /groups/{id}
|
||||
ReadGroup(ctx context.Context, params ReadGroupParams) (ReadGroupRes, error)
|
||||
// ReadUe implements readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error)
|
||||
// ReadUeOwner implements readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error)
|
||||
// ReadUser implements readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@ -122,6 +158,12 @@ type Handler interface {
|
||||
//
|
||||
// PATCH /groups/{id}
|
||||
UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error)
|
||||
// UpdateUe implements updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error)
|
||||
// UpdateUser implements updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
@ -31,6 +31,15 @@ func (UnimplementedHandler) CreateGroup(ctx context.Context, req *CreateGroupReq
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateUe implements createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
func (UnimplementedHandler) CreateUe(ctx context.Context, req *CreateUeReq) (r CreateUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateUser implements createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@ -58,6 +67,15 @@ func (UnimplementedHandler) DeleteGroup(ctx context.Context, params DeleteGroupP
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteUe implements deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
func (UnimplementedHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (r DeleteUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteUser implements deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@ -112,6 +130,15 @@ func (UnimplementedHandler) ListGroupUsers(ctx context.Context, params ListGroup
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUe implements listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
func (UnimplementedHandler) ListUe(ctx context.Context, params ListUeParams) (r ListUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUser implements listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@ -130,6 +157,15 @@ func (UnimplementedHandler) ListUserCard(ctx context.Context, params ListUserCar
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUserUe implements listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
func (UnimplementedHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (r ListUserUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadCard implements readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@ -157,6 +193,24 @@ func (UnimplementedHandler) ReadGroup(ctx context.Context, params ReadGroupParam
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUe implements readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
func (UnimplementedHandler) ReadUe(ctx context.Context, params ReadUeParams) (r ReadUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUeOwner implements readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
func (UnimplementedHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (r ReadUeOwnerRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUser implements readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@ -184,6 +238,15 @@ func (UnimplementedHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateUe implements updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
func (UnimplementedHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (r UpdateUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateUser implements updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
@ -24,6 +24,12 @@ func (s ListGroupUsersOKApplicationJSON) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUeOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserCardOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
@ -36,3 +42,9 @@ func (s ListUserOKApplicationJSON) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserUeOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"t/ent"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"github.com/go-faster/jx"
|
||||
"os"
|
||||
"github.com/go-faster/jx"
|
||||
)
|
||||
|
||||
// origin-config
|
||||
@ -48,29 +48,31 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// origin-config
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -131,33 +133,32 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea
|
||||
// UpdateCard handles PATCH /cards/{id} requests.
|
||||
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
|
||||
b := h.client.Card.UpdateOneID(params.ID)
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
// Add all fields.
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
@ -197,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -289,7 +290,7 @@ func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerPa
|
||||
func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) {
|
||||
b := h.client.Group.Create()
|
||||
// Add all fields.
|
||||
b.SetName("")
|
||||
b.SetName(req.Name)
|
||||
b.SetPassword(req.Password)
|
||||
// Add all edges.
|
||||
b.AddUserIDs(req.Users...)
|
||||
@ -353,6 +354,7 @@ func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (R
|
||||
// UpdateGroup handles PATCH /groups/{id} requests.
|
||||
func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) {
|
||||
b := h.client.Group.UpdateOneID(0)
|
||||
//b := h.client.Group.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
if v, ok := req.Name.Get(); ok {
|
||||
b.SetName(v)
|
||||
@ -395,6 +397,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par
|
||||
// DeleteGroup handles DELETE /groups/{id} requests.
|
||||
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
|
||||
err := h.client.Group.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -491,40 +494,318 @@ func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsers
|
||||
return (*ListGroupUsersOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// CreateUe handles POST /ues requests.
|
||||
func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error) {
|
||||
b := h.client.Ue.Create()
|
||||
// Add all fields.
|
||||
if v, ok := req.Limit.Get(); ok {
|
||||
b.SetLimit(v)
|
||||
}
|
||||
if v, ok := req.LimitBoss.Get(); ok {
|
||||
b.SetLimitBoss(v)
|
||||
}
|
||||
if v, ok := req.LimitItem.Get(); ok {
|
||||
b.SetLimitItem(v)
|
||||
}
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Lv.Get(); ok {
|
||||
b.SetLv(v)
|
||||
}
|
||||
if v, ok := req.LvPoint.Get(); ok {
|
||||
b.SetLvPoint(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
if v, ok := req.Sword.Get(); ok {
|
||||
b.SetSword(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Mode.Get(); ok {
|
||||
b.SetMode(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.LocationX.Get(); ok {
|
||||
b.SetLocationX(v)
|
||||
}
|
||||
if v, ok := req.LocationY.Get(); ok {
|
||||
b.SetLocationY(v)
|
||||
}
|
||||
if v, ok := req.LocationZ.Get(); ok {
|
||||
b.SetLocationZ(v)
|
||||
}
|
||||
if v, ok := req.LocationN.Get(); ok {
|
||||
b.SetLocationN(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Ue.Query().Where(ue.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUeCreate(e), nil
|
||||
}
|
||||
|
||||
// ReadUe handles GET /ues/{id} requests.
|
||||
func (h *OgentHandler) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) {
|
||||
q := h.client.Ue.Query().Where(ue.IDEQ(params.ID))
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewUeRead(e), nil
|
||||
}
|
||||
|
||||
// UpdateUe handles PATCH /ues/{id} requests.
|
||||
func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) {
|
||||
b := h.client.Ue.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
if v, ok := req.Limit.Get(); ok {
|
||||
b.SetLimit(v)
|
||||
}
|
||||
if v, ok := req.LimitBoss.Get(); ok {
|
||||
b.SetLimitBoss(v)
|
||||
}
|
||||
if v, ok := req.LimitItem.Get(); ok {
|
||||
b.SetLimitItem(v)
|
||||
}
|
||||
if v, ok := req.Lv.Get(); ok {
|
||||
b.SetLv(v)
|
||||
}
|
||||
if v, ok := req.LvPoint.Get(); ok {
|
||||
b.SetLvPoint(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
if v, ok := req.Sword.Get(); ok {
|
||||
b.SetSword(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Mode.Get(); ok {
|
||||
b.SetMode(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.LocationX.Get(); ok {
|
||||
b.SetLocationX(v)
|
||||
}
|
||||
if v, ok := req.LocationY.Get(); ok {
|
||||
b.SetLocationY(v)
|
||||
}
|
||||
if v, ok := req.LocationZ.Get(); ok {
|
||||
b.SetLocationZ(v)
|
||||
}
|
||||
if v, ok := req.LocationN.Get(); ok {
|
||||
b.SetLocationN(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Ue.Query().Where(ue.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUeUpdate(e), nil
|
||||
}
|
||||
|
||||
// DeleteUe handles DELETE /ues/{id} requests.
|
||||
func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
|
||||
err := h.client.Ue.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new(DeleteUeNoContent), nil
|
||||
|
||||
}
|
||||
|
||||
// ListUe handles GET /ues requests.
|
||||
func (h *OgentHandler) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) {
|
||||
q := h.client.Ue.Query()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUeLists(es)
|
||||
return (*ListUeOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ReadUeOwner handles GET /ues/{id}/owner requests.
|
||||
func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) {
|
||||
q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)).QueryOwner()
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewUeOwnerRead(e), nil
|
||||
}
|
||||
|
||||
// CreateUser handles POST /users requests.
|
||||
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
|
||||
b := h.client.User.Create()
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
//origin-config
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Member.Get(); ok {
|
||||
b.SetMember(v)
|
||||
}
|
||||
@ -537,6 +818,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Badge.Get(); ok {
|
||||
b.SetBadge(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
@ -546,9 +833,7 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
@ -558,12 +843,15 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
@ -576,6 +864,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
@ -585,6 +876,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
@ -603,6 +897,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
@ -612,12 +909,6 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.ModelAttack.Get(); ok {
|
||||
b.SetModelAttack(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelLimit.Get(); ok {
|
||||
b.SetModelLimit(v)
|
||||
}
|
||||
@ -627,6 +918,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.ModelMode.Get(); ok {
|
||||
b.SetModelMode(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.Game.Get(); ok {
|
||||
b.SetGame(v)
|
||||
}
|
||||
@ -643,8 +940,16 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
b.SetGameLv(v)
|
||||
}
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
// Add all edges.
|
||||
b.AddCardIDs(req.Card...)
|
||||
b.AddUeIDs(req.Ue...)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -705,20 +1010,9 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea
|
||||
// UpdateUser handles PATCH /users/{id} requests.
|
||||
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
|
||||
b := h.client.User.UpdateOneID(params.ID)
|
||||
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
// Add all fields.
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
@ -746,17 +1040,17 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
@ -773,6 +1067,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
@ -782,6 +1079,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
@ -800,6 +1100,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
@ -809,12 +1112,6 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.ModelAttack.Get(); ok {
|
||||
b.SetModelAttack(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelLimit.Get(); ok {
|
||||
b.SetModelLimit(v)
|
||||
}
|
||||
@ -824,6 +1121,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.ModelMode.Get(); ok {
|
||||
b.SetModelMode(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.Game.Get(); ok {
|
||||
b.SetGame(v)
|
||||
}
|
||||
@ -843,9 +1146,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if req.Card != nil {
|
||||
b.ClearCard().AddCardIDs(req.Card...)
|
||||
}
|
||||
if req.Ue != nil {
|
||||
b.ClearUe().AddUeIDs(req.Ue...)
|
||||
}
|
||||
b.SetToken(v)
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -880,6 +1186,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
// DeleteUser handles DELETE /users/{id} requests.
|
||||
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
|
||||
err := h.client.User.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.User.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -975,3 +1282,39 @@ func (h *OgentHandler) ListUserCard(ctx context.Context, params ListUserCardPara
|
||||
r := NewUserCardLists(es)
|
||||
return (*ListUserCardOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ListUserUe handles GET /users/{id}/ue requests.
|
||||
func (h *OgentHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) {
|
||||
q := h.client.User.Query().Where(user.IDEQ(params.ID)).QueryUe()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUserUeLists(es)
|
||||
return (*ListUserUeOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
@ -400,6 +400,254 @@ func (u *GroupUsersList) Elem() GroupUsersList {
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUeCreate(e *ent.Ue) *UeCreate {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UeCreate
|
||||
ret.ID = e.ID
|
||||
ret.Limit = NewOptBool(e.Limit)
|
||||
ret.LimitBoss = NewOptBool(e.LimitBoss)
|
||||
ret.LimitItem = NewOptBool(e.LimitItem)
|
||||
ret.Lv = NewOptInt(e.Lv)
|
||||
ret.LvPoint = NewOptInt(e.LvPoint)
|
||||
ret.Model = NewOptInt(e.Model)
|
||||
ret.Sword = NewOptInt(e.Sword)
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Mode = NewOptString(e.Mode)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.Count = NewOptInt(e.Count)
|
||||
ret.LocationX = NewOptInt(e.LocationX)
|
||||
ret.LocationY = NewOptInt(e.LocationY)
|
||||
ret.LocationZ = NewOptInt(e.LocationZ)
|
||||
ret.LocationN = NewOptInt(e.LocationN)
|
||||
ret.Author = NewOptString(e.Author)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUeCreates(es []*ent.Ue) []UeCreate {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UeCreate, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUeCreate(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UeCreate) Elem() UeCreate {
|
||||
if u == nil {
|
||||
return UeCreate{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUeList(e *ent.Ue) *UeList {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UeList
|
||||
ret.ID = e.ID
|
||||
ret.Limit = NewOptBool(e.Limit)
|
||||
ret.LimitBoss = NewOptBool(e.LimitBoss)
|
||||
ret.LimitItem = NewOptBool(e.LimitItem)
|
||||
ret.Lv = NewOptInt(e.Lv)
|
||||
ret.LvPoint = NewOptInt(e.LvPoint)
|
||||
ret.Model = NewOptInt(e.Model)
|
||||
ret.Sword = NewOptInt(e.Sword)
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Mode = NewOptString(e.Mode)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.Count = NewOptInt(e.Count)
|
||||
ret.LocationX = NewOptInt(e.LocationX)
|
||||
ret.LocationY = NewOptInt(e.LocationY)
|
||||
ret.LocationZ = NewOptInt(e.LocationZ)
|
||||
ret.LocationN = NewOptInt(e.LocationN)
|
||||
ret.Author = NewOptString(e.Author)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUeLists(es []*ent.Ue) []UeList {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UeList, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUeList(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UeList) Elem() UeList {
|
||||
if u == nil {
|
||||
return UeList{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUeRead(e *ent.Ue) *UeRead {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UeRead
|
||||
ret.ID = e.ID
|
||||
ret.Limit = NewOptBool(e.Limit)
|
||||
ret.LimitBoss = NewOptBool(e.LimitBoss)
|
||||
ret.LimitItem = NewOptBool(e.LimitItem)
|
||||
ret.Lv = NewOptInt(e.Lv)
|
||||
ret.LvPoint = NewOptInt(e.LvPoint)
|
||||
ret.Model = NewOptInt(e.Model)
|
||||
ret.Sword = NewOptInt(e.Sword)
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Mode = NewOptString(e.Mode)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.Count = NewOptInt(e.Count)
|
||||
ret.LocationX = NewOptInt(e.LocationX)
|
||||
ret.LocationY = NewOptInt(e.LocationY)
|
||||
ret.LocationZ = NewOptInt(e.LocationZ)
|
||||
ret.LocationN = NewOptInt(e.LocationN)
|
||||
ret.Author = NewOptString(e.Author)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUeReads(es []*ent.Ue) []UeRead {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UeRead, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUeRead(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UeRead) Elem() UeRead {
|
||||
if u == nil {
|
||||
return UeRead{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUeUpdate(e *ent.Ue) *UeUpdate {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UeUpdate
|
||||
ret.ID = e.ID
|
||||
ret.Limit = NewOptBool(e.Limit)
|
||||
ret.LimitBoss = NewOptBool(e.LimitBoss)
|
||||
ret.LimitItem = NewOptBool(e.LimitItem)
|
||||
ret.Lv = NewOptInt(e.Lv)
|
||||
ret.LvPoint = NewOptInt(e.LvPoint)
|
||||
ret.Model = NewOptInt(e.Model)
|
||||
ret.Sword = NewOptInt(e.Sword)
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Mode = NewOptString(e.Mode)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.Count = NewOptInt(e.Count)
|
||||
ret.LocationX = NewOptInt(e.LocationX)
|
||||
ret.LocationY = NewOptInt(e.LocationY)
|
||||
ret.LocationZ = NewOptInt(e.LocationZ)
|
||||
ret.LocationN = NewOptInt(e.LocationN)
|
||||
ret.Author = NewOptString(e.Author)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUeUpdates(es []*ent.Ue) []UeUpdate {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UeUpdate, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUeUpdate(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UeUpdate) Elem() UeUpdate {
|
||||
if u == nil {
|
||||
return UeUpdate{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUeOwnerRead(e *ent.User) *UeOwnerRead {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UeOwnerRead
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Member = NewOptBool(e.Member)
|
||||
ret.Book = NewOptBool(e.Book)
|
||||
ret.Manga = NewOptBool(e.Manga)
|
||||
ret.Badge = NewOptBool(e.Badge)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.ServerAt = NewOptDateTime(e.ServerAt)
|
||||
ret.EggAt = NewOptDateTime(e.EggAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
ret.Room = NewOptInt(e.Room)
|
||||
ret.Model = NewOptBool(e.Model)
|
||||
ret.ModelAt = NewOptDateTime(e.ModelAt)
|
||||
ret.ModelAttack = NewOptInt(e.ModelAttack)
|
||||
ret.ModelLimit = NewOptInt(e.ModelLimit)
|
||||
ret.ModelSkill = NewOptInt(e.ModelSkill)
|
||||
ret.ModelMode = NewOptInt(e.ModelMode)
|
||||
ret.ModelCritical = NewOptInt(e.ModelCritical)
|
||||
ret.ModelCriticalD = NewOptInt(e.ModelCriticalD)
|
||||
ret.Game = NewOptBool(e.Game)
|
||||
ret.GameTest = NewOptBool(e.GameTest)
|
||||
ret.GameEnd = NewOptBool(e.GameEnd)
|
||||
ret.GameAccount = NewOptBool(e.GameAccount)
|
||||
ret.GameLv = NewOptInt(e.GameLv)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUeOwnerReads(es []*ent.User) []UeOwnerRead {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UeOwnerRead, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUeOwnerRead(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UeOwnerRead) Elem() UeOwnerRead {
|
||||
if u == nil {
|
||||
return UeOwnerRead{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
||||
func NewUserCreate(e *ent.User) *UserCreate {
|
||||
if e == nil {
|
||||
return nil
|
||||
@ -722,3 +970,47 @@ func (c *UserCardList) Elem() UserCardList {
|
||||
}
|
||||
return *c
|
||||
}
|
||||
|
||||
func NewUserUeList(e *ent.Ue) *UserUeList {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
var ret UserUeList
|
||||
ret.ID = e.ID
|
||||
ret.Limit = NewOptBool(e.Limit)
|
||||
ret.LimitBoss = NewOptBool(e.LimitBoss)
|
||||
ret.LimitItem = NewOptBool(e.LimitItem)
|
||||
ret.Lv = NewOptInt(e.Lv)
|
||||
ret.LvPoint = NewOptInt(e.LvPoint)
|
||||
ret.Model = NewOptInt(e.Model)
|
||||
ret.Sword = NewOptInt(e.Sword)
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Mode = NewOptString(e.Mode)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.Count = NewOptInt(e.Count)
|
||||
ret.LocationX = NewOptInt(e.LocationX)
|
||||
ret.LocationY = NewOptInt(e.LocationY)
|
||||
ret.LocationZ = NewOptInt(e.LocationZ)
|
||||
ret.LocationN = NewOptInt(e.LocationN)
|
||||
ret.Author = NewOptString(e.Author)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func NewUserUeLists(es []*ent.Ue) []UserUeList {
|
||||
if len(es) == 0 {
|
||||
return nil
|
||||
}
|
||||
r := make([]UserUeList, len(es))
|
||||
for i, e := range es {
|
||||
r[i] = NewUserUeList(e).Elem()
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (u *UserUeList) Elem() UserUeList {
|
||||
if u == nil {
|
||||
return UserUeList{}
|
||||
}
|
||||
return *u
|
||||
}
|
||||
|
1028
ent/openapi.json
1028
ent/openapi.json
File diff suppressed because it is too large
Load Diff
@ -12,5 +12,8 @@ type Card func(*sql.Selector)
|
||||
// Group is the predicate function for group builders.
|
||||
type Group func(*sql.Selector)
|
||||
|
||||
// Ue is the predicate function for ue builders.
|
||||
type Ue func(*sql.Selector)
|
||||
|
||||
// User is the predicate function for user builders.
|
||||
type User func(*sql.Selector)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/schema"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
)
|
||||
@ -50,6 +51,28 @@ func init() {
|
||||
groupDescPassword := groupFields[1].Descriptor()
|
||||
// group.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
group.PasswordValidator = groupDescPassword.Validators[0].(func(string) error)
|
||||
ueFields := schema.Ue{}.Fields()
|
||||
_ = ueFields
|
||||
// ueDescLimit is the schema descriptor for limit field.
|
||||
ueDescLimit := ueFields[0].Descriptor()
|
||||
// ue.DefaultLimit holds the default value on creation for the limit field.
|
||||
ue.DefaultLimit = ueDescLimit.Default.(bool)
|
||||
// ueDescLimitBoss is the schema descriptor for limit_boss field.
|
||||
ueDescLimitBoss := ueFields[1].Descriptor()
|
||||
// ue.DefaultLimitBoss holds the default value on creation for the limit_boss field.
|
||||
ue.DefaultLimitBoss = ueDescLimitBoss.Default.(bool)
|
||||
// ueDescLimitItem is the schema descriptor for limit_item field.
|
||||
ueDescLimitItem := ueFields[2].Descriptor()
|
||||
// ue.DefaultLimitItem holds the default value on creation for the limit_item field.
|
||||
ue.DefaultLimitItem = ueDescLimitItem.Default.(bool)
|
||||
// ueDescPassword is the schema descriptor for password field.
|
||||
ueDescPassword := ueFields[3].Descriptor()
|
||||
// ue.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
ue.PasswordValidator = ueDescPassword.Validators[0].(func(string) error)
|
||||
// ueDescCreatedAt is the schema descriptor for created_at field.
|
||||
ueDescCreatedAt := ueFields[18].Descriptor()
|
||||
// ue.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
ue.DefaultCreatedAt = ueDescCreatedAt.Default.(func() time.Time)
|
||||
userFields := schema.User{}.Fields()
|
||||
_ = userFields
|
||||
// userDescUsername is the schema descriptor for username field.
|
||||
|
95
ent/schema/ue.go
Normal file
95
ent/schema/ue.go
Normal file
@ -0,0 +1,95 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Game holds the schema definition for the Game entity.
|
||||
type Ue struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Ue) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.Bool("limit").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("limit_boss").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("limit_item").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("lv").
|
||||
Optional(),
|
||||
|
||||
field.Int("lv_point").
|
||||
Optional(),
|
||||
|
||||
field.Int("model").
|
||||
Optional(),
|
||||
|
||||
field.Int("sword").
|
||||
Optional(),
|
||||
|
||||
field.Int("card").
|
||||
Optional(),
|
||||
|
||||
field.String("mode").
|
||||
Optional(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("cp").
|
||||
Optional(),
|
||||
|
||||
field.Int("count").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_x").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_y").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_z").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_n").
|
||||
Optional(),
|
||||
|
||||
field.String("author").
|
||||
Optional(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (Ue) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("owner", User.Type).
|
||||
Ref("ue").
|
||||
Unique().
|
||||
Required(),
|
||||
|
||||
}
|
||||
}
|
@ -229,6 +229,8 @@ func (User) Indexes() []ent.Index {
|
||||
func (User) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("card", Card.Type),
|
||||
edge.To("ue", Ue.Type),
|
||||
//Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@ type Tx struct {
|
||||
Card *CardClient
|
||||
// Group is the client for interacting with the Group builders.
|
||||
Group *GroupClient
|
||||
// Ue is the client for interacting with the Ue builders.
|
||||
Ue *UeClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
|
||||
@ -151,6 +153,7 @@ func (tx *Tx) Client() *Client {
|
||||
func (tx *Tx) init() {
|
||||
tx.Card = NewCardClient(tx.config)
|
||||
tx.Group = NewGroupClient(tx.config)
|
||||
tx.Ue = NewUeClient(tx.config)
|
||||
tx.User = NewUserClient(tx.config)
|
||||
}
|
||||
|
||||
|
335
ent/ue.go
Normal file
335
ent/ue.go
Normal file
@ -0,0 +1,335 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Ue is the model entity for the Ue schema.
|
||||
type Ue struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Limit holds the value of the "limit" field.
|
||||
Limit bool `json:"limit,omitempty"`
|
||||
// LimitBoss holds the value of the "limit_boss" field.
|
||||
LimitBoss bool `json:"limit_boss,omitempty"`
|
||||
// LimitItem holds the value of the "limit_item" field.
|
||||
LimitItem bool `json:"limit_item,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Lv holds the value of the "lv" field.
|
||||
Lv int `json:"lv,omitempty"`
|
||||
// LvPoint holds the value of the "lv_point" field.
|
||||
LvPoint int `json:"lv_point,omitempty"`
|
||||
// Model holds the value of the "model" field.
|
||||
Model int `json:"model,omitempty"`
|
||||
// Sword holds the value of the "sword" field.
|
||||
Sword int `json:"sword,omitempty"`
|
||||
// Card holds the value of the "card" field.
|
||||
Card int `json:"card,omitempty"`
|
||||
// Mode holds the value of the "mode" field.
|
||||
Mode string `json:"mode,omitempty"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Cp holds the value of the "cp" field.
|
||||
Cp int `json:"cp,omitempty"`
|
||||
// Count holds the value of the "count" field.
|
||||
Count int `json:"count,omitempty"`
|
||||
// LocationX holds the value of the "location_x" field.
|
||||
LocationX int `json:"location_x,omitempty"`
|
||||
// LocationY holds the value of the "location_y" field.
|
||||
LocationY int `json:"location_y,omitempty"`
|
||||
// LocationZ holds the value of the "location_z" field.
|
||||
LocationZ int `json:"location_z,omitempty"`
|
||||
// LocationN holds the value of the "location_n" field.
|
||||
LocationN int `json:"location_n,omitempty"`
|
||||
// Author holds the value of the "author" field.
|
||||
Author string `json:"author,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the UeQuery when eager-loading is set.
|
||||
Edges UeEdges `json:"edges"`
|
||||
user_ue *int
|
||||
}
|
||||
|
||||
// UeEdges holds the relations/edges for other nodes in the graph.
|
||||
type UeEdges struct {
|
||||
// Owner holds the value of the owner edge.
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// OwnerOrErr returns the Owner value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e UeEdges) OwnerOrErr() (*User, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Owner == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return e.Owner, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "owner"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Ue) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ue.FieldLimit, ue.FieldLimitBoss, ue.FieldLimitItem:
|
||||
values[i] = new(sql.NullBool)
|
||||
case ue.FieldID, ue.FieldLv, ue.FieldLvPoint, ue.FieldModel, ue.FieldSword, ue.FieldCard, ue.FieldCp, ue.FieldCount, ue.FieldLocationX, ue.FieldLocationY, ue.FieldLocationZ, ue.FieldLocationN:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case ue.FieldPassword, ue.FieldMode, ue.FieldToken, ue.FieldAuthor:
|
||||
values[i] = new(sql.NullString)
|
||||
case ue.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case ue.ForeignKeys[0]: // user_ue
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type Ue", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Ue fields.
|
||||
func (u *Ue) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ue.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
u.ID = int(value.Int64)
|
||||
case ue.FieldLimit:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit", values[i])
|
||||
} else if value.Valid {
|
||||
u.Limit = value.Bool
|
||||
}
|
||||
case ue.FieldLimitBoss:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit_boss", values[i])
|
||||
} else if value.Valid {
|
||||
u.LimitBoss = value.Bool
|
||||
}
|
||||
case ue.FieldLimitItem:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit_item", values[i])
|
||||
} else if value.Valid {
|
||||
u.LimitItem = value.Bool
|
||||
}
|
||||
case ue.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
u.Password = value.String
|
||||
}
|
||||
case ue.FieldLv:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field lv", values[i])
|
||||
} else if value.Valid {
|
||||
u.Lv = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLvPoint:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field lv_point", values[i])
|
||||
} else if value.Valid {
|
||||
u.LvPoint = int(value.Int64)
|
||||
}
|
||||
case ue.FieldModel:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model", values[i])
|
||||
} else if value.Valid {
|
||||
u.Model = int(value.Int64)
|
||||
}
|
||||
case ue.FieldSword:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sword", values[i])
|
||||
} else if value.Valid {
|
||||
u.Sword = int(value.Int64)
|
||||
}
|
||||
case ue.FieldCard:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field card", values[i])
|
||||
} else if value.Valid {
|
||||
u.Card = int(value.Int64)
|
||||
}
|
||||
case ue.FieldMode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mode", values[i])
|
||||
} else if value.Valid {
|
||||
u.Mode = value.String
|
||||
}
|
||||
case ue.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value.Valid {
|
||||
u.Token = value.String
|
||||
}
|
||||
case ue.FieldCp:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp", values[i])
|
||||
} else if value.Valid {
|
||||
u.Cp = int(value.Int64)
|
||||
}
|
||||
case ue.FieldCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field count", values[i])
|
||||
} else if value.Valid {
|
||||
u.Count = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationX:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_x", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationX = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationY:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_y", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationY = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationZ:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_z", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationZ = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationN:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_n", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationN = int(value.Int64)
|
||||
}
|
||||
case ue.FieldAuthor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field author", values[i])
|
||||
} else if value.Valid {
|
||||
u.Author = value.String
|
||||
}
|
||||
case ue.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.CreatedAt = value.Time
|
||||
}
|
||||
case ue.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field user_ue", value)
|
||||
} else if value.Valid {
|
||||
u.user_ue = new(int)
|
||||
*u.user_ue = int(value.Int64)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Ue entity.
|
||||
func (u *Ue) QueryOwner() *UserQuery {
|
||||
return NewUeClient(u.config).QueryOwner(u)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Ue.
|
||||
// Note that you need to call Ue.Unwrap() before calling this method if this Ue
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (u *Ue) Update() *UeUpdateOne {
|
||||
return NewUeClient(u.config).UpdateOne(u)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Ue entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (u *Ue) Unwrap() *Ue {
|
||||
_tx, ok := u.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Ue is not a transactional entity")
|
||||
}
|
||||
u.config.driver = _tx.drv
|
||||
return u
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (u *Ue) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Ue(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", u.ID))
|
||||
builder.WriteString("limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Limit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit_boss=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LimitBoss))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit_item=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LimitItem))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("lv=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Lv))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("lv_point=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LvPoint))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Model))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sword=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Sword))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("card=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Card))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mode=")
|
||||
builder.WriteString(u.Mode)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Cp))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Count))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_x=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationX))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_y=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationY))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_z=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationZ))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_n=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationN))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("author=")
|
||||
builder.WriteString(u.Author)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(u.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Ues is a parsable slice of Ue.
|
||||
type Ues []*Ue
|
121
ent/ue/ue.go
Normal file
121
ent/ue/ue.go
Normal file
@ -0,0 +1,121 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ue
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the ue type in the database.
|
||||
Label = "ue"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldLimit holds the string denoting the limit field in the database.
|
||||
FieldLimit = "limit"
|
||||
// FieldLimitBoss holds the string denoting the limit_boss field in the database.
|
||||
FieldLimitBoss = "limit_boss"
|
||||
// FieldLimitItem holds the string denoting the limit_item field in the database.
|
||||
FieldLimitItem = "limit_item"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldLv holds the string denoting the lv field in the database.
|
||||
FieldLv = "lv"
|
||||
// FieldLvPoint holds the string denoting the lv_point field in the database.
|
||||
FieldLvPoint = "lv_point"
|
||||
// FieldModel holds the string denoting the model field in the database.
|
||||
FieldModel = "model"
|
||||
// FieldSword holds the string denoting the sword field in the database.
|
||||
FieldSword = "sword"
|
||||
// FieldCard holds the string denoting the card field in the database.
|
||||
FieldCard = "card"
|
||||
// FieldMode holds the string denoting the mode field in the database.
|
||||
FieldMode = "mode"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldCp holds the string denoting the cp field in the database.
|
||||
FieldCp = "cp"
|
||||
// FieldCount holds the string denoting the count field in the database.
|
||||
FieldCount = "count"
|
||||
// FieldLocationX holds the string denoting the location_x field in the database.
|
||||
FieldLocationX = "location_x"
|
||||
// FieldLocationY holds the string denoting the location_y field in the database.
|
||||
FieldLocationY = "location_y"
|
||||
// FieldLocationZ holds the string denoting the location_z field in the database.
|
||||
FieldLocationZ = "location_z"
|
||||
// FieldLocationN holds the string denoting the location_n field in the database.
|
||||
FieldLocationN = "location_n"
|
||||
// FieldAuthor holds the string denoting the author field in the database.
|
||||
FieldAuthor = "author"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
// Table holds the table name of the ue in the database.
|
||||
Table = "ues"
|
||||
// OwnerTable is the table that holds the owner relation/edge.
|
||||
OwnerTable = "ues"
|
||||
// OwnerInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
OwnerInverseTable = "users"
|
||||
// OwnerColumn is the table column denoting the owner relation/edge.
|
||||
OwnerColumn = "user_ue"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for ue fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldLimit,
|
||||
FieldLimitBoss,
|
||||
FieldLimitItem,
|
||||
FieldPassword,
|
||||
FieldLv,
|
||||
FieldLvPoint,
|
||||
FieldModel,
|
||||
FieldSword,
|
||||
FieldCard,
|
||||
FieldMode,
|
||||
FieldToken,
|
||||
FieldCp,
|
||||
FieldCount,
|
||||
FieldLocationX,
|
||||
FieldLocationY,
|
||||
FieldLocationZ,
|
||||
FieldLocationN,
|
||||
FieldAuthor,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "ues"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"user_ue",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultLimit holds the default value on creation for the "limit" field.
|
||||
DefaultLimit bool
|
||||
// DefaultLimitBoss holds the default value on creation for the "limit_boss" field.
|
||||
DefaultLimitBoss bool
|
||||
// DefaultLimitItem holds the default value on creation for the "limit_item" field.
|
||||
DefaultLimitItem bool
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
1160
ent/ue/where.go
Normal file
1160
ent/ue/where.go
Normal file
File diff suppressed because it is too large
Load Diff
563
ent/ue_create.go
Normal file
563
ent/ue_create.go
Normal file
@ -0,0 +1,563 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeCreate is the builder for creating a Ue entity.
|
||||
type UeCreate struct {
|
||||
config
|
||||
mutation *UeMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (uc *UeCreate) SetLimit(b bool) *UeCreate {
|
||||
uc.mutation.SetLimit(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimit(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimit(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLimitBoss sets the "limit_boss" field.
|
||||
func (uc *UeCreate) SetLimitBoss(b bool) *UeCreate {
|
||||
uc.mutation.SetLimitBoss(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimitBoss(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimitBoss(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLimitItem sets the "limit_item" field.
|
||||
func (uc *UeCreate) SetLimitItem(b bool) *UeCreate {
|
||||
uc.mutation.SetLimitItem(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimitItem sets the "limit_item" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimitItem(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimitItem(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (uc *UeCreate) SetPassword(s string) *UeCreate {
|
||||
uc.mutation.SetPassword(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLv sets the "lv" field.
|
||||
func (uc *UeCreate) SetLv(i int) *UeCreate {
|
||||
uc.mutation.SetLv(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLv sets the "lv" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLv(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLv(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLvPoint sets the "lv_point" field.
|
||||
func (uc *UeCreate) SetLvPoint(i int) *UeCreate {
|
||||
uc.mutation.SetLvPoint(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLvPoint sets the "lv_point" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLvPoint(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLvPoint(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModel sets the "model" field.
|
||||
func (uc *UeCreate) SetModel(i int) *UeCreate {
|
||||
uc.mutation.SetModel(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModel sets the "model" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableModel(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetModel(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetSword sets the "sword" field.
|
||||
func (uc *UeCreate) SetSword(i int) *UeCreate {
|
||||
uc.mutation.SetSword(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableSword sets the "sword" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableSword(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetSword(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (uc *UeCreate) SetCard(i int) *UeCreate {
|
||||
uc.mutation.SetCard(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCard(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCard(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetMode sets the "mode" field.
|
||||
func (uc *UeCreate) SetMode(s string) *UeCreate {
|
||||
uc.mutation.SetMode(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableMode sets the "mode" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableMode(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetMode(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uc *UeCreate) SetToken(s string) *UeCreate {
|
||||
uc.mutation.SetToken(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableToken(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetToken(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCp sets the "cp" field.
|
||||
func (uc *UeCreate) SetCp(i int) *UeCreate {
|
||||
uc.mutation.SetCp(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCp sets the "cp" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCp(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCp(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (uc *UeCreate) SetCount(i int) *UeCreate {
|
||||
uc.mutation.SetCount(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCount(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCount(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationX sets the "location_x" field.
|
||||
func (uc *UeCreate) SetLocationX(i int) *UeCreate {
|
||||
uc.mutation.SetLocationX(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationX sets the "location_x" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationX(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationX(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationY sets the "location_y" field.
|
||||
func (uc *UeCreate) SetLocationY(i int) *UeCreate {
|
||||
uc.mutation.SetLocationY(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationY sets the "location_y" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationY(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationY(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationZ sets the "location_z" field.
|
||||
func (uc *UeCreate) SetLocationZ(i int) *UeCreate {
|
||||
uc.mutation.SetLocationZ(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationZ sets the "location_z" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationZ(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationZ(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationN sets the "location_n" field.
|
||||
func (uc *UeCreate) SetLocationN(i int) *UeCreate {
|
||||
uc.mutation.SetLocationN(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationN sets the "location_n" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationN(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationN(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetAuthor sets the "author" field.
|
||||
func (uc *UeCreate) SetAuthor(s string) *UeCreate {
|
||||
uc.mutation.SetAuthor(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableAuthor(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetAuthor(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (uc *UeCreate) SetCreatedAt(t time.Time) *UeCreate {
|
||||
uc.mutation.SetCreatedAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCreatedAt(t *time.Time) *UeCreate {
|
||||
if t != nil {
|
||||
uc.SetCreatedAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (uc *UeCreate) SetOwnerID(id int) *UeCreate {
|
||||
uc.mutation.SetOwnerID(id)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (uc *UeCreate) SetOwner(u *User) *UeCreate {
|
||||
return uc.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the UeMutation object of the builder.
|
||||
func (uc *UeCreate) Mutation() *UeMutation {
|
||||
return uc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Ue in the database.
|
||||
func (uc *UeCreate) Save(ctx context.Context) (*Ue, error) {
|
||||
uc.defaults()
|
||||
return withHooks[*Ue, UeMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (uc *UeCreate) SaveX(ctx context.Context) *Ue {
|
||||
v, err := uc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (uc *UeCreate) Exec(ctx context.Context) error {
|
||||
_, err := uc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (uc *UeCreate) ExecX(ctx context.Context) {
|
||||
if err := uc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UeCreate) defaults() {
|
||||
if _, ok := uc.mutation.Limit(); !ok {
|
||||
v := ue.DefaultLimit
|
||||
uc.mutation.SetLimit(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LimitBoss(); !ok {
|
||||
v := ue.DefaultLimitBoss
|
||||
uc.mutation.SetLimitBoss(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LimitItem(); !ok {
|
||||
v := ue.DefaultLimitItem
|
||||
uc.mutation.SetLimitItem(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
v := ue.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (uc *UeCreate) check() error {
|
||||
if _, ok := uc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Ue.password"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Password(); ok {
|
||||
if err := ue.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Ue.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Ue.owner"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uc *UeCreate) sqlSave(ctx context.Context) (*Ue, error) {
|
||||
if err := uc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := uc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
uc.mutation.id = &_node.ID
|
||||
uc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (uc *UeCreate) createSpec() (*Ue, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Ue{config: uc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := uc.mutation.Limit(); ok {
|
||||
_spec.SetField(ue.FieldLimit, field.TypeBool, value)
|
||||
_node.Limit = value
|
||||
}
|
||||
if value, ok := uc.mutation.LimitBoss(); ok {
|
||||
_spec.SetField(ue.FieldLimitBoss, field.TypeBool, value)
|
||||
_node.LimitBoss = value
|
||||
}
|
||||
if value, ok := uc.mutation.LimitItem(); ok {
|
||||
_spec.SetField(ue.FieldLimitItem, field.TypeBool, value)
|
||||
_node.LimitItem = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
_spec.SetField(ue.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := uc.mutation.Lv(); ok {
|
||||
_spec.SetField(ue.FieldLv, field.TypeInt, value)
|
||||
_node.Lv = value
|
||||
}
|
||||
if value, ok := uc.mutation.LvPoint(); ok {
|
||||
_spec.SetField(ue.FieldLvPoint, field.TypeInt, value)
|
||||
_node.LvPoint = value
|
||||
}
|
||||
if value, ok := uc.mutation.Model(); ok {
|
||||
_spec.SetField(ue.FieldModel, field.TypeInt, value)
|
||||
_node.Model = value
|
||||
}
|
||||
if value, ok := uc.mutation.Sword(); ok {
|
||||
_spec.SetField(ue.FieldSword, field.TypeInt, value)
|
||||
_node.Sword = value
|
||||
}
|
||||
if value, ok := uc.mutation.Card(); ok {
|
||||
_spec.SetField(ue.FieldCard, field.TypeInt, value)
|
||||
_node.Card = value
|
||||
}
|
||||
if value, ok := uc.mutation.Mode(); ok {
|
||||
_spec.SetField(ue.FieldMode, field.TypeString, value)
|
||||
_node.Mode = value
|
||||
}
|
||||
if value, ok := uc.mutation.Token(); ok {
|
||||
_spec.SetField(ue.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := uc.mutation.Cp(); ok {
|
||||
_spec.SetField(ue.FieldCp, field.TypeInt, value)
|
||||
_node.Cp = value
|
||||
}
|
||||
if value, ok := uc.mutation.Count(); ok {
|
||||
_spec.SetField(ue.FieldCount, field.TypeInt, value)
|
||||
_node.Count = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationX(); ok {
|
||||
_spec.SetField(ue.FieldLocationX, field.TypeInt, value)
|
||||
_node.LocationX = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationY(); ok {
|
||||
_spec.SetField(ue.FieldLocationY, field.TypeInt, value)
|
||||
_node.LocationY = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationZ(); ok {
|
||||
_spec.SetField(ue.FieldLocationZ, field.TypeInt, value)
|
||||
_node.LocationZ = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationN(); ok {
|
||||
_spec.SetField(ue.FieldLocationN, field.TypeInt, value)
|
||||
_node.LocationN = value
|
||||
}
|
||||
if value, ok := uc.mutation.Author(); ok {
|
||||
_spec.SetField(ue.FieldAuthor, field.TypeString, value)
|
||||
_node.Author = value
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(ue.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if nodes := uc.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: ue.OwnerTable,
|
||||
Columns: []string{ue.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.user_ue = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// UeCreateBulk is the builder for creating many Ue entities in bulk.
|
||||
type UeCreateBulk struct {
|
||||
config
|
||||
builders []*UeCreate
|
||||
}
|
||||
|
||||
// Save creates the Ue entities in the database.
|
||||
func (ucb *UeCreateBulk) Save(ctx context.Context) ([]*Ue, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ucb.builders))
|
||||
nodes := make([]*Ue, len(ucb.builders))
|
||||
mutators := make([]Mutator, len(ucb.builders))
|
||||
for i := range ucb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ucb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*UeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ucb *UeCreateBulk) SaveX(ctx context.Context) []*Ue {
|
||||
v, err := ucb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ucb *UeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ucb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ucb *UeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ucb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
88
ent/ue_delete.go
Normal file
88
ent/ue_delete.go
Normal file
@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"t/ent/predicate"
|
||||
"t/ent/ue"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeDelete is the builder for deleting a Ue entity.
|
||||
type UeDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *UeMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UeDelete builder.
|
||||
func (ud *UeDelete) Where(ps ...predicate.Ue) *UeDelete {
|
||||
ud.mutation.Where(ps...)
|
||||
return ud
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ud *UeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks[int, UeMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ud *UeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ud.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ud *UeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
if ps := ud.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ud.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// UeDeleteOne is the builder for deleting a single Ue entity.
|
||||
type UeDeleteOne struct {
|
||||
ud *UeDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UeDelete builder.
|
||||
func (udo *UeDeleteOne) Where(ps ...predicate.Ue) *UeDeleteOne {
|
||||
udo.ud.mutation.Where(ps...)
|
||||
return udo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (udo *UeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := udo.ud.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{ue.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (udo *UeDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := udo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
613
ent/ue_query.go
Normal file
613
ent/ue_query.go
Normal file
@ -0,0 +1,613 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"t/ent/predicate"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeQuery is the builder for querying Ue entities.
|
||||
type UeQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []OrderFunc
|
||||
inters []Interceptor
|
||||
predicates []predicate.Ue
|
||||
withOwner *UserQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the UeQuery builder.
|
||||
func (uq *UeQuery) Where(ps ...predicate.Ue) *UeQuery {
|
||||
uq.predicates = append(uq.predicates, ps...)
|
||||
return uq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (uq *UeQuery) Limit(limit int) *UeQuery {
|
||||
uq.ctx.Limit = &limit
|
||||
return uq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (uq *UeQuery) Offset(offset int) *UeQuery {
|
||||
uq.ctx.Offset = &offset
|
||||
return uq
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (uq *UeQuery) Unique(unique bool) *UeQuery {
|
||||
uq.ctx.Unique = &unique
|
||||
return uq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (uq *UeQuery) Order(o ...OrderFunc) *UeQuery {
|
||||
uq.order = append(uq.order, o...)
|
||||
return uq
|
||||
}
|
||||
|
||||
// QueryOwner chains the current query on the "owner" edge.
|
||||
func (uq *UeQuery) QueryOwner() *UserQuery {
|
||||
query := (&UserClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ue.Table, ue.FieldID, selector),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Ue entity from the query.
|
||||
// Returns a *NotFoundError when no Ue was found.
|
||||
func (uq *UeQuery) First(ctx context.Context) (*Ue, error) {
|
||||
nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{ue.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (uq *UeQuery) FirstX(ctx context.Context) *Ue {
|
||||
node, err := uq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Ue ID from the query.
|
||||
// Returns a *NotFoundError when no Ue ID was found.
|
||||
func (uq *UeQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{ue.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (uq *UeQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := uq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Ue entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Ue entity is found.
|
||||
// Returns a *NotFoundError when no Ue entities are found.
|
||||
func (uq *UeQuery) Only(ctx context.Context) (*Ue, error) {
|
||||
nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{ue.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{ue.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (uq *UeQuery) OnlyX(ctx context.Context) *Ue {
|
||||
node, err := uq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Ue ID in the query.
|
||||
// Returns a *NotSingularError when more than one Ue ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (uq *UeQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{ue.Label}
|
||||
default:
|
||||
err = &NotSingularError{ue.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (uq *UeQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := uq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Ues.
|
||||
func (uq *UeQuery) All(ctx context.Context) ([]*Ue, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "All")
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Ue, *UeQuery]()
|
||||
return withInterceptors[[]*Ue](ctx, uq, qr, uq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (uq *UeQuery) AllX(ctx context.Context) []*Ue {
|
||||
nodes, err := uq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Ue IDs.
|
||||
func (uq *UeQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if uq.ctx.Unique == nil && uq.path != nil {
|
||||
uq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, uq.ctx, "IDs")
|
||||
if err = uq.Select(ue.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (uq *UeQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := uq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (uq *UeQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "Count")
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, uq, querierCount[*UeQuery](), uq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (uq *UeQuery) CountX(ctx context.Context) int {
|
||||
count, err := uq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (uq *UeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "Exist")
|
||||
switch _, err := uq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (uq *UeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := uq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the UeQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (uq *UeQuery) Clone() *UeQuery {
|
||||
if uq == nil {
|
||||
return nil
|
||||
}
|
||||
return &UeQuery{
|
||||
config: uq.config,
|
||||
ctx: uq.ctx.Clone(),
|
||||
order: append([]OrderFunc{}, uq.order...),
|
||||
inters: append([]Interceptor{}, uq.inters...),
|
||||
predicates: append([]predicate.Ue{}, uq.predicates...),
|
||||
withOwner: uq.withOwner.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
path: uq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithOwner tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "owner" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UeQuery) WithOwner(opts ...func(*UserQuery)) *UeQuery {
|
||||
query := (&UserClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withOwner = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Limit bool `json:"limit,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ue.Query().
|
||||
// GroupBy(ue.FieldLimit).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UeQuery) GroupBy(field string, fields ...string) *UeGroupBy {
|
||||
uq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &UeGroupBy{build: uq}
|
||||
grbuild.flds = &uq.ctx.Fields
|
||||
grbuild.label = ue.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Limit bool `json:"limit,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ue.Query().
|
||||
// Select(ue.FieldLimit).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UeQuery) Select(fields ...string) *UeSelect {
|
||||
uq.ctx.Fields = append(uq.ctx.Fields, fields...)
|
||||
sbuild := &UeSelect{UeQuery: uq}
|
||||
sbuild.label = ue.Label
|
||||
sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a UeSelect configured with the given aggregations.
|
||||
func (uq *UeQuery) Aggregate(fns ...AggregateFunc) *UeSelect {
|
||||
return uq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (uq *UeQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range uq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, uq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range uq.ctx.Fields {
|
||||
if !ue.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if uq.path != nil {
|
||||
prev, err := uq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
uq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ue, error) {
|
||||
var (
|
||||
nodes = []*Ue{}
|
||||
withFKs = uq.withFKs
|
||||
_spec = uq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
uq.withOwner != nil,
|
||||
}
|
||||
)
|
||||
if uq.withOwner != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ue.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Ue).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Ue{config: uq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := uq.withOwner; query != nil {
|
||||
if err := uq.loadOwner(ctx, query, nodes, nil,
|
||||
func(n *Ue, e *User) { n.Edges.Owner = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Ue, init func(*Ue), assign func(*Ue, *User)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Ue)
|
||||
for i := range nodes {
|
||||
if nodes[i].user_ue == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].user_ue
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(user.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := uq.querySpec()
|
||||
_spec.Node.Columns = uq.ctx.Fields
|
||||
if len(uq.ctx.Fields) > 0 {
|
||||
_spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, uq.driver, _spec)
|
||||
}
|
||||
|
||||
func (uq *UeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(ue.Table, ue.Columns, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
_spec.From = uq.sql
|
||||
if unique := uq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if uq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := uq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ue.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != ue.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := uq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := uq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(uq.driver.Dialect())
|
||||
t1 := builder.Table(ue.Table)
|
||||
columns := uq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = ue.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if uq.sql != nil {
|
||||
selector = uq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if uq.ctx.Unique != nil && *uq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range uq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range uq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// UeGroupBy is the group-by builder for Ue entities.
|
||||
type UeGroupBy struct {
|
||||
selector
|
||||
build *UeQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ugb *UeGroupBy) Aggregate(fns ...AggregateFunc) *UeGroupBy {
|
||||
ugb.fns = append(ugb.fns, fns...)
|
||||
return ugb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ugb *UeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy")
|
||||
if err := ugb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UeQuery, *UeGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v)
|
||||
}
|
||||
|
||||
func (ugb *UeGroupBy) sqlScan(ctx context.Context, root *UeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ugb.fns))
|
||||
for _, fn := range ugb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns))
|
||||
for _, f := range *ugb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ugb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// UeSelect is the builder for selecting fields of Ue entities.
|
||||
type UeSelect struct {
|
||||
*UeQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (us *UeSelect) Aggregate(fns ...AggregateFunc) *UeSelect {
|
||||
us.fns = append(us.fns, fns...)
|
||||
return us
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (us *UeSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, us.ctx, "Select")
|
||||
if err := us.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UeQuery, *UeSelect](ctx, us.UeQuery, us, us.inters, v)
|
||||
}
|
||||
|
||||
func (us *UeSelect) sqlScan(ctx context.Context, root *UeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(us.fns))
|
||||
for _, fn := range us.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*us.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := us.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
1400
ent/ue_update.go
Normal file
1400
ent/ue_update.go
Normal file
File diff suppressed because it is too large
Load Diff
18
ent/user.go
18
ent/user.go
@ -120,9 +120,11 @@ type User struct {
|
||||
type UserEdges struct {
|
||||
// Card holds the value of the card edge.
|
||||
Card []*Card `json:"card,omitempty"`
|
||||
// Ue holds the value of the ue edge.
|
||||
Ue []*Ue `json:"ue,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
loadedTypes [2]bool
|
||||
}
|
||||
|
||||
// CardOrErr returns the Card value or an error if the edge
|
||||
@ -134,6 +136,15 @@ func (e UserEdges) CardOrErr() ([]*Card, error) {
|
||||
return nil, &NotLoadedError{edge: "card"}
|
||||
}
|
||||
|
||||
// UeOrErr returns the Ue value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) UeOrErr() ([]*Ue, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Ue, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "ue"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*User) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
@ -469,6 +480,11 @@ func (u *User) QueryCard() *CardQuery {
|
||||
return NewUserClient(u.config).QueryCard(u)
|
||||
}
|
||||
|
||||
// QueryUe queries the "ue" edge of the User entity.
|
||||
func (u *User) QueryUe() *UeQuery {
|
||||
return NewUserClient(u.config).QueryUe(u)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this User.
|
||||
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@ -107,6 +107,8 @@ const (
|
||||
FieldGameLv = "game_lv"
|
||||
// EdgeCard holds the string denoting the card edge name in mutations.
|
||||
EdgeCard = "card"
|
||||
// EdgeUe holds the string denoting the ue edge name in mutations.
|
||||
EdgeUe = "ue"
|
||||
// Table holds the table name of the user in the database.
|
||||
Table = "users"
|
||||
// CardTable is the table that holds the card relation/edge.
|
||||
@ -116,6 +118,13 @@ const (
|
||||
CardInverseTable = "cards"
|
||||
// CardColumn is the table column denoting the card relation/edge.
|
||||
CardColumn = "user_card"
|
||||
// UeTable is the table that holds the ue relation/edge.
|
||||
UeTable = "ues"
|
||||
// UeInverseTable is the table name for the Ue entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "ue" package.
|
||||
UeInverseTable = "ues"
|
||||
// UeColumn is the table column denoting the ue relation/edge.
|
||||
UeColumn = "user_ue"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for user fields.
|
||||
|
@ -2452,6 +2452,33 @@ func HasCardWith(preds ...predicate.Card) predicate.User {
|
||||
})
|
||||
}
|
||||
|
||||
// HasUe applies the HasEdge predicate on the "ue" edge.
|
||||
func HasUe() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasUeWith applies the HasEdge predicate on the "ue" edge with a given conditions (other predicates).
|
||||
func HasUeWith(preds ...predicate.Ue) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UeInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.User) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/card"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
@ -678,6 +679,21 @@ func (uc *UserCreate) AddCard(c ...*Card) *UserCreate {
|
||||
return uc.AddCardIDs(ids...)
|
||||
}
|
||||
|
||||
// AddUeIDs adds the "ue" edge to the Ue entity by IDs.
|
||||
func (uc *UserCreate) AddUeIDs(ids ...int) *UserCreate {
|
||||
uc.mutation.AddUeIDs(ids...)
|
||||
return uc
|
||||
}
|
||||
|
||||
// AddUe adds the "ue" edges to the Ue entity.
|
||||
func (uc *UserCreate) AddUe(u ...*Ue) *UserCreate {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uc.AddUeIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uc *UserCreate) Mutation() *UserMutation {
|
||||
return uc.mutation
|
||||
@ -1051,6 +1067,22 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.UeIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"math"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@ -24,6 +25,7 @@ type UserQuery struct {
|
||||
inters []Interceptor
|
||||
predicates []predicate.User
|
||||
withCard *CardQuery
|
||||
withUe *UeQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
@ -83,6 +85,28 @@ func (uq *UserQuery) QueryCard() *CardQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUe chains the current query on the "ue" edge.
|
||||
func (uq *UserQuery) QueryUe() *UeQuery {
|
||||
query := (&UeClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||
sqlgraph.To(ue.Table, ue.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first User entity from the query.
|
||||
// Returns a *NotFoundError when no User was found.
|
||||
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||
@ -276,6 +300,7 @@ func (uq *UserQuery) Clone() *UserQuery {
|
||||
inters: append([]Interceptor{}, uq.inters...),
|
||||
predicates: append([]predicate.User{}, uq.predicates...),
|
||||
withCard: uq.withCard.Clone(),
|
||||
withUe: uq.withUe.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
path: uq.path,
|
||||
@ -293,6 +318,17 @@ func (uq *UserQuery) WithCard(opts ...func(*CardQuery)) *UserQuery {
|
||||
return uq
|
||||
}
|
||||
|
||||
// WithUe tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "ue" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithUe(opts ...func(*UeQuery)) *UserQuery {
|
||||
query := (&UeClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withUe = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@ -372,8 +408,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
nodes = []*User{}
|
||||
withFKs = uq.withFKs
|
||||
_spec = uq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
loadedTypes = [2]bool{
|
||||
uq.withCard != nil,
|
||||
uq.withUe != nil,
|
||||
}
|
||||
)
|
||||
if withFKs {
|
||||
@ -404,6 +441,13 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withUe; query != nil {
|
||||
if err := uq.loadUe(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.Ue = []*Ue{} },
|
||||
func(n *User, e *Ue) { n.Edges.Ue = append(n.Edges.Ue, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
@ -438,6 +482,37 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User, init func(*User), assign func(*User, *Ue)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*User)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Ue(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.UeColumn, fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.user_ue
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "user_ue" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := uq.querySpec()
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
@ -1029,6 +1030,21 @@ func (uu *UserUpdate) AddCard(c ...*Card) *UserUpdate {
|
||||
return uu.AddCardIDs(ids...)
|
||||
}
|
||||
|
||||
// AddUeIDs adds the "ue" edge to the Ue entity by IDs.
|
||||
func (uu *UserUpdate) AddUeIDs(ids ...int) *UserUpdate {
|
||||
uu.mutation.AddUeIDs(ids...)
|
||||
return uu
|
||||
}
|
||||
|
||||
// AddUe adds the "ue" edges to the Ue entity.
|
||||
func (uu *UserUpdate) AddUe(u ...*Ue) *UserUpdate {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uu.AddUeIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uu *UserUpdate) Mutation() *UserMutation {
|
||||
return uu.mutation
|
||||
@ -1055,6 +1071,27 @@ func (uu *UserUpdate) RemoveCard(c ...*Card) *UserUpdate {
|
||||
return uu.RemoveCardIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearUe clears all "ue" edges to the Ue entity.
|
||||
func (uu *UserUpdate) ClearUe() *UserUpdate {
|
||||
uu.mutation.ClearUe()
|
||||
return uu
|
||||
}
|
||||
|
||||
// RemoveUeIDs removes the "ue" edge to Ue entities by IDs.
|
||||
func (uu *UserUpdate) RemoveUeIDs(ids ...int) *UserUpdate {
|
||||
uu.mutation.RemoveUeIDs(ids...)
|
||||
return uu
|
||||
}
|
||||
|
||||
// RemoveUe removes "ue" edges to Ue entities.
|
||||
func (uu *UserUpdate) RemoveUe(u ...*Ue) *UserUpdate {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uu.RemoveUeIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (uu *UserUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks)
|
||||
@ -1448,6 +1485,51 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if uu.mutation.UeCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uu.mutation.RemovedUeIDs(); len(nodes) > 0 && !uu.mutation.UeCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uu.mutation.UeIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{user.Label}
|
||||
@ -2468,6 +2550,21 @@ func (uuo *UserUpdateOne) AddCard(c ...*Card) *UserUpdateOne {
|
||||
return uuo.AddCardIDs(ids...)
|
||||
}
|
||||
|
||||
// AddUeIDs adds the "ue" edge to the Ue entity by IDs.
|
||||
func (uuo *UserUpdateOne) AddUeIDs(ids ...int) *UserUpdateOne {
|
||||
uuo.mutation.AddUeIDs(ids...)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// AddUe adds the "ue" edges to the Ue entity.
|
||||
func (uuo *UserUpdateOne) AddUe(u ...*Ue) *UserUpdateOne {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uuo.AddUeIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uuo *UserUpdateOne) Mutation() *UserMutation {
|
||||
return uuo.mutation
|
||||
@ -2494,6 +2591,27 @@ func (uuo *UserUpdateOne) RemoveCard(c ...*Card) *UserUpdateOne {
|
||||
return uuo.RemoveCardIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearUe clears all "ue" edges to the Ue entity.
|
||||
func (uuo *UserUpdateOne) ClearUe() *UserUpdateOne {
|
||||
uuo.mutation.ClearUe()
|
||||
return uuo
|
||||
}
|
||||
|
||||
// RemoveUeIDs removes the "ue" edge to Ue entities by IDs.
|
||||
func (uuo *UserUpdateOne) RemoveUeIDs(ids ...int) *UserUpdateOne {
|
||||
uuo.mutation.RemoveUeIDs(ids...)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// RemoveUe removes "ue" edges to Ue entities.
|
||||
func (uuo *UserUpdateOne) RemoveUe(u ...*Ue) *UserUpdateOne {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uuo.RemoveUeIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UserUpdate builder.
|
||||
func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
||||
uuo.mutation.Where(ps...)
|
||||
@ -2917,6 +3035,51 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if uuo.mutation.UeCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uuo.mutation.RemovedUeIDs(); len(nodes) > 0 && !uuo.mutation.UeCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uuo.mutation.UeIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &User{config: uuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
2
main.go
2
main.go
@ -51,7 +51,7 @@ func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) erro
|
||||
|
||||
func main() {
|
||||
// Create ent client.
|
||||
client, err := ent.Open(dialect.SQLite, "file:/data/new.sqlite?_fk=1")
|
||||
client, err := ent.Open(dialect.SQLite, "file:/app/data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
|
@ -8,6 +8,6 @@ id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$user
|
||||
curl -sL $host/users/$id
|
||||
read
|
||||
echo $id
|
||||
o=false
|
||||
o=true
|
||||
echo $o
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"game\":true, \"game_test\":$o, \"game_end\":$o, \"token\":\"$token\"}" -s $host/users/$id
|
||||
|
@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeCreate:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeCreateUserResponse(response CreateUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UserCreate:
|
||||
@ -298,6 +353,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *DeleteUeNoContent:
|
||||
w.WriteHeader(204)
|
||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeDeleteUserResponse(response DeleteUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *DeleteUserNoContent:
|
||||
@ -575,6 +691,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ListUeOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
@ -711,6 +894,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ListUserUeOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
@ -914,6 +1164,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeOwnerRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
switch response := response.(type) {
|
||||
@ -1116,6 +1500,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UeUpdate:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R400:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(400)
|
||||
span.SetStatus(codes.Error, http.StatusText(400))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R404:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(404)
|
||||
span.SetStatus(codes.Error, http.StatusText(404))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R409:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(409)
|
||||
span.SetStatus(codes.Error, http.StatusText(409))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
case *R500:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(500)
|
||||
span.SetStatus(codes.Error, http.StatusText(500))
|
||||
|
||||
e := jx.GetEncoder()
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUpdateUserResponse(response UpdateUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UserUpdate:
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"t/ent"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/ue"
|
||||
"t/ent/user"
|
||||
|
||||
"github.com/go-faster/jx"
|
||||
"os"
|
||||
"github.com/go-faster/jx"
|
||||
)
|
||||
|
||||
// origin-config
|
||||
@ -48,29 +48,31 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// origin-config
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -131,33 +133,32 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea
|
||||
// UpdateCard handles PATCH /cards/{id} requests.
|
||||
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
|
||||
b := h.client.Card.UpdateOneID(params.ID)
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
// Add all fields.
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
@ -197,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -289,7 +290,7 @@ func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerPa
|
||||
func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) {
|
||||
b := h.client.Group.Create()
|
||||
// Add all fields.
|
||||
b.SetName("")
|
||||
b.SetName(req.Name)
|
||||
b.SetPassword(req.Password)
|
||||
// Add all edges.
|
||||
b.AddUserIDs(req.Users...)
|
||||
@ -353,6 +354,7 @@ func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (R
|
||||
// UpdateGroup handles PATCH /groups/{id} requests.
|
||||
func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) {
|
||||
b := h.client.Group.UpdateOneID(0)
|
||||
//b := h.client.Group.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
if v, ok := req.Name.Get(); ok {
|
||||
b.SetName(v)
|
||||
@ -395,6 +397,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par
|
||||
// DeleteGroup handles DELETE /groups/{id} requests.
|
||||
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
|
||||
err := h.client.Group.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -491,40 +494,318 @@ func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsers
|
||||
return (*ListGroupUsersOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// CreateUe handles POST /ues requests.
|
||||
func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error) {
|
||||
b := h.client.Ue.Create()
|
||||
// Add all fields.
|
||||
if v, ok := req.Limit.Get(); ok {
|
||||
b.SetLimit(v)
|
||||
}
|
||||
if v, ok := req.LimitBoss.Get(); ok {
|
||||
b.SetLimitBoss(v)
|
||||
}
|
||||
if v, ok := req.LimitItem.Get(); ok {
|
||||
b.SetLimitItem(v)
|
||||
}
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Lv.Get(); ok {
|
||||
b.SetLv(v)
|
||||
}
|
||||
if v, ok := req.LvPoint.Get(); ok {
|
||||
b.SetLvPoint(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
if v, ok := req.Sword.Get(); ok {
|
||||
b.SetSword(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Mode.Get(); ok {
|
||||
b.SetMode(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.LocationX.Get(); ok {
|
||||
b.SetLocationX(v)
|
||||
}
|
||||
if v, ok := req.LocationY.Get(); ok {
|
||||
b.SetLocationY(v)
|
||||
}
|
||||
if v, ok := req.LocationZ.Get(); ok {
|
||||
b.SetLocationZ(v)
|
||||
}
|
||||
if v, ok := req.LocationN.Get(); ok {
|
||||
b.SetLocationN(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Ue.Query().Where(ue.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUeCreate(e), nil
|
||||
}
|
||||
|
||||
// ReadUe handles GET /ues/{id} requests.
|
||||
func (h *OgentHandler) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) {
|
||||
q := h.client.Ue.Query().Where(ue.IDEQ(params.ID))
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewUeRead(e), nil
|
||||
}
|
||||
|
||||
// UpdateUe handles PATCH /ues/{id} requests.
|
||||
func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) {
|
||||
b := h.client.Ue.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
if v, ok := req.Limit.Get(); ok {
|
||||
b.SetLimit(v)
|
||||
}
|
||||
if v, ok := req.LimitBoss.Get(); ok {
|
||||
b.SetLimitBoss(v)
|
||||
}
|
||||
if v, ok := req.LimitItem.Get(); ok {
|
||||
b.SetLimitItem(v)
|
||||
}
|
||||
if v, ok := req.Lv.Get(); ok {
|
||||
b.SetLv(v)
|
||||
}
|
||||
if v, ok := req.LvPoint.Get(); ok {
|
||||
b.SetLvPoint(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
if v, ok := req.Sword.Get(); ok {
|
||||
b.SetSword(v)
|
||||
}
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Mode.Get(); ok {
|
||||
b.SetMode(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Count.Get(); ok {
|
||||
b.SetCount(v)
|
||||
}
|
||||
if v, ok := req.LocationX.Get(); ok {
|
||||
b.SetLocationX(v)
|
||||
}
|
||||
if v, ok := req.LocationY.Get(); ok {
|
||||
b.SetLocationY(v)
|
||||
}
|
||||
if v, ok := req.LocationZ.Get(); ok {
|
||||
b.SetLocationZ(v)
|
||||
}
|
||||
if v, ok := req.LocationN.Get(); ok {
|
||||
b.SetLocationN(v)
|
||||
}
|
||||
if v, ok := req.Author.Get(); ok {
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Ue.Query().Where(ue.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUeUpdate(e), nil
|
||||
}
|
||||
|
||||
// DeleteUe handles DELETE /ues/{id} requests.
|
||||
func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
|
||||
err := h.client.Ue.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new(DeleteUeNoContent), nil
|
||||
|
||||
}
|
||||
|
||||
// ListUe handles GET /ues requests.
|
||||
func (h *OgentHandler) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) {
|
||||
q := h.client.Ue.Query()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUeLists(es)
|
||||
return (*ListUeOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ReadUeOwner handles GET /ues/{id}/owner requests.
|
||||
func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) {
|
||||
q := h.client.Ue.Query().Where(ue.IDEQ(params.ID)).QueryOwner()
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewUeOwnerRead(e), nil
|
||||
}
|
||||
|
||||
// CreateUser handles POST /users requests.
|
||||
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
|
||||
b := h.client.User.Create()
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
//origin-config
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Member.Get(); ok {
|
||||
b.SetMember(v)
|
||||
}
|
||||
@ -537,6 +818,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Badge.Get(); ok {
|
||||
b.SetBadge(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
@ -546,9 +833,7 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
@ -558,12 +843,15 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
@ -576,6 +864,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
@ -585,6 +876,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
@ -603,6 +897,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
@ -612,12 +909,6 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.ModelAttack.Get(); ok {
|
||||
b.SetModelAttack(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelLimit.Get(); ok {
|
||||
b.SetModelLimit(v)
|
||||
}
|
||||
@ -627,6 +918,12 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
if v, ok := req.ModelMode.Get(); ok {
|
||||
b.SetModelMode(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.Game.Get(); ok {
|
||||
b.SetGame(v)
|
||||
}
|
||||
@ -643,8 +940,16 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
b.SetGameLv(v)
|
||||
}
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
// Add all edges.
|
||||
b.AddCardIDs(req.Card...)
|
||||
b.AddUeIDs(req.Ue...)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -705,20 +1010,9 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea
|
||||
// UpdateUser handles PATCH /users/{id} requests.
|
||||
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
|
||||
b := h.client.User.UpdateOneID(params.ID)
|
||||
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
// Add all fields.
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
@ -746,17 +1040,17 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
if v, ok := req.ServerAt.Get(); ok {
|
||||
b.SetServerAt(v)
|
||||
}
|
||||
if v, ok := req.EggAt.Get(); ok {
|
||||
b.SetEggAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
@ -773,6 +1067,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
@ -782,6 +1079,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
@ -800,6 +1100,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
if v, ok := req.Room.Get(); ok {
|
||||
b.SetRoom(v)
|
||||
}
|
||||
if v, ok := req.Model.Get(); ok {
|
||||
b.SetModel(v)
|
||||
}
|
||||
@ -809,12 +1112,6 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.ModelAttack.Get(); ok {
|
||||
b.SetModelAttack(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelLimit.Get(); ok {
|
||||
b.SetModelLimit(v)
|
||||
}
|
||||
@ -824,6 +1121,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v, ok := req.ModelMode.Get(); ok {
|
||||
b.SetModelMode(v)
|
||||
}
|
||||
if v, ok := req.ModelCritical.Get(); ok {
|
||||
b.SetModelCritical(v)
|
||||
}
|
||||
if v, ok := req.ModelCriticalD.Get(); ok {
|
||||
b.SetModelCriticalD(v)
|
||||
}
|
||||
if v, ok := req.Game.Get(); ok {
|
||||
b.SetGame(v)
|
||||
}
|
||||
@ -843,9 +1146,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if req.Card != nil {
|
||||
b.ClearCard().AddCardIDs(req.Card...)
|
||||
}
|
||||
if req.Ue != nil {
|
||||
b.ClearUe().AddUeIDs(req.Ue...)
|
||||
}
|
||||
b.SetToken(v)
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -880,6 +1186,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
// DeleteUser handles DELETE /users/{id} requests.
|
||||
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
|
||||
err := h.client.User.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.User.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -975,3 +1282,39 @@ func (h *OgentHandler) ListUserCard(ctx context.Context, params ListUserCardPara
|
||||
r := NewUserCardLists(es)
|
||||
return (*ListUserCardOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ListUserUe handles GET /users/{id}/ue requests.
|
||||
func (h *OgentHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) {
|
||||
q := h.client.User.Query().Where(user.IDEQ(params.ID)).QueryUe()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUserUeLists(es)
|
||||
return (*ListUserUeOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
18
tmp/ue_add_test.zsh
Executable file
18
tmp/ue_add_test.zsh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo username
|
||||
read
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
|
||||
card=0
|
||||
model=0
|
||||
sword=0
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card, \"model\":$model,\"sword\":$sword,\"password\":\"$pass\"}" -sL $host/ues
|
||||
|
||||
curl -sL api.syui.ai/users/$id/ue
|
@ -12,7 +12,7 @@ data=`curl -sL "$host_users"|jq .`
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
f=/Volumes/ssd/project/yui/Content/user.json
|
||||
f=~/ai/card/public/json/user.json
|
||||
if [ -f $f ];then
|
||||
rm $f
|
||||
fi
|
||||
@ -33,3 +33,5 @@ do
|
||||
done
|
||||
|
||||
echo "}" >> $f
|
||||
|
||||
cat $f|jq .
|
||||
|
Loading…
x
Reference in New Issue
Block a user