fix: shop_players 关系表主键与模型对齐
This commit is contained in:
@@ -3,7 +3,6 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"juwan-backend/app/snowflake/rpc/snowflake"
|
|
||||||
|
|
||||||
"juwan-backend/app/shop/rpc/internal/svc"
|
"juwan-backend/app/shop/rpc/internal/svc"
|
||||||
"juwan-backend/app/shop/rpc/pb"
|
"juwan-backend/app/shop/rpc/pb"
|
||||||
@@ -27,14 +26,7 @@ func NewAddShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ad
|
|||||||
|
|
||||||
// -----------------------shopPlayers-----------------------
|
// -----------------------shopPlayers-----------------------
|
||||||
func (l *AddShopPlayersLogic) AddShopPlayers(in *pb.AddShopPlayersReq) (*pb.AddShopPlayersResp, error) {
|
func (l *AddShopPlayersLogic) AddShopPlayers(in *pb.AddShopPlayersReq) (*pb.AddShopPlayersResp, error) {
|
||||||
idResp, err := l.svcCtx.Snowflake.NextId(l.ctx, &snowflake.NextIdReq{})
|
_, err := l.svcCtx.ShopModelRW.ShopPlayers.Create().
|
||||||
if err != nil {
|
|
||||||
logx.Errorf("addPlayerServices err:%v", err)
|
|
||||||
return nil, errors.New("create player service id failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = l.svcCtx.ShopModelRW.ShopPlayers.Create().
|
|
||||||
SetID(idResp.Id).
|
|
||||||
SetShopID(in.ShopId).
|
SetShopID(in.ShopId).
|
||||||
SetPlayerID(in.PlayerId).
|
SetPlayerID(in.PlayerId).
|
||||||
SetIsPrimary(in.IsPrimary).
|
SetIsPrimary(in.IsPrimary).
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
|
||||||
|
|
||||||
"juwan-backend/app/shop/rpc/internal/svc"
|
"juwan-backend/app/shop/rpc/internal/svc"
|
||||||
"juwan-backend/app/shop/rpc/pb"
|
"juwan-backend/app/shop/rpc/pb"
|
||||||
@@ -25,11 +26,19 @@ func NewDelShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *DelShopPlayersLogic) DelShopPlayers(in *pb.DelShopPlayersReq) (*pb.DelShopPlayersResp, error) {
|
func (l *DelShopPlayersLogic) DelShopPlayers(in *pb.DelShopPlayersReq) (*pb.DelShopPlayersResp, error) {
|
||||||
err := l.svcCtx.ShopModelRO.ShopPlayers.DeleteOneID(in.Id).Exec(l.ctx)
|
affected, err := l.svcCtx.ShopModelRW.ShopPlayers.Delete().
|
||||||
|
Where(
|
||||||
|
shopplayers.ShopIDEQ(in.ShopId),
|
||||||
|
shopplayers.PlayerIDEQ(in.PlayerId),
|
||||||
|
).
|
||||||
|
Exec(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Errorf("delete shop players failed, %s", err.Error())
|
logx.Errorf("delete shop players failed, %s", err.Error())
|
||||||
return nil, errors.New("delete failed")
|
return nil, errors.New("delete failed")
|
||||||
}
|
}
|
||||||
|
if affected == 0 {
|
||||||
|
return nil, errors.New("delete failed")
|
||||||
|
}
|
||||||
|
|
||||||
return &pb.DelShopPlayersResp{}, nil
|
return &pb.DelShopPlayersResp{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ func NewGetShopPlayersByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetShopPlayersByIdLogic) GetShopPlayersById(in *pb.GetShopPlayersByIdReq) (*pb.GetShopPlayersByIdResp, error) {
|
func (l *GetShopPlayersByIdLogic) GetShopPlayersById(in *pb.GetShopPlayersByIdReq) (*pb.GetShopPlayersByIdResp, error) {
|
||||||
shopPlayer, err := l.svcCtx.ShopModelRO.ShopPlayers.Query().Where(shopplayers.IDEQ(in.Id)).First(l.ctx)
|
shopPlayer, err := l.svcCtx.ShopModelRO.ShopPlayers.Query().Where(
|
||||||
|
shopplayers.ShopIDEQ(in.ShopId),
|
||||||
|
shopplayers.PlayerIDEQ(in.PlayerId),
|
||||||
|
).First(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.WithContext(l.ctx).Errorf("GetShopPlayersByIdLogic err: %v", err)
|
logx.WithContext(l.ctx).Errorf("GetShopPlayersByIdLogic err: %v", err)
|
||||||
return nil, errors.New("get shop players by id failed")
|
return nil, errors.New("get shop players by id failed")
|
||||||
|
|||||||
@@ -410,12 +410,6 @@ func (c *ShopPlayersClient) UpdateOne(_m *ShopPlayers) *ShopPlayersUpdateOne {
|
|||||||
return &ShopPlayersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &ShopPlayersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateOneID returns an update builder for the given id.
|
|
||||||
func (c *ShopPlayersClient) UpdateOneID(id int64) *ShopPlayersUpdateOne {
|
|
||||||
mutation := newShopPlayersMutation(c.config, OpUpdateOne, withShopPlayersID(id))
|
|
||||||
return &ShopPlayersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete returns a delete builder for ShopPlayers.
|
// Delete returns a delete builder for ShopPlayers.
|
||||||
func (c *ShopPlayersClient) Delete() *ShopPlayersDelete {
|
func (c *ShopPlayersClient) Delete() *ShopPlayersDelete {
|
||||||
mutation := newShopPlayersMutation(c.config, OpDelete)
|
mutation := newShopPlayersMutation(c.config, OpDelete)
|
||||||
@@ -424,13 +418,10 @@ func (c *ShopPlayersClient) Delete() *ShopPlayersDelete {
|
|||||||
|
|
||||||
// DeleteOne returns a builder for deleting the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *ShopPlayersClient) DeleteOne(_m *ShopPlayers) *ShopPlayersDeleteOne {
|
func (c *ShopPlayersClient) DeleteOne(_m *ShopPlayers) *ShopPlayersDeleteOne {
|
||||||
return c.DeleteOneID(_m.ID)
|
builder := c.Delete().Where(
|
||||||
}
|
shopplayers.ShopIDEQ(_m.ShopID),
|
||||||
|
shopplayers.PlayerIDEQ(_m.PlayerID),
|
||||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
)
|
||||||
func (c *ShopPlayersClient) DeleteOneID(id int64) *ShopPlayersDeleteOne {
|
|
||||||
builder := c.Delete().Where(shopplayers.ID(id))
|
|
||||||
builder.mutation.id = &id
|
|
||||||
builder.mutation.op = OpDeleteOne
|
builder.mutation.op = OpDeleteOne
|
||||||
return &ShopPlayersDeleteOne{builder}
|
return &ShopPlayersDeleteOne{builder}
|
||||||
}
|
}
|
||||||
@@ -444,20 +435,6 @@ func (c *ShopPlayersClient) Query() *ShopPlayersQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns a ShopPlayers entity by its id.
|
|
||||||
func (c *ShopPlayersClient) Get(ctx context.Context, id int64) (*ShopPlayers, error) {
|
|
||||||
return c.Query().Where(shopplayers.ID(id)).Only(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetX is like Get, but panics if an error occurs.
|
|
||||||
func (c *ShopPlayersClient) GetX(ctx context.Context, id int64) *ShopPlayers {
|
|
||||||
obj, err := c.Get(ctx, id)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *ShopPlayersClient) Hooks() []Hook {
|
func (c *ShopPlayersClient) Hooks() []Hook {
|
||||||
return c.hooks.ShopPlayers
|
return c.hooks.ShopPlayers
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ var (
|
|||||||
}
|
}
|
||||||
// ShopPlayersColumns holds the columns for the "shop_players" table.
|
// ShopPlayersColumns holds the columns for the "shop_players" table.
|
||||||
ShopPlayersColumns = []*schema.Column{
|
ShopPlayersColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
|
||||||
{Name: "shop_id", Type: field.TypeInt64},
|
{Name: "shop_id", Type: field.TypeInt64},
|
||||||
{Name: "player_id", Type: field.TypeInt64},
|
{Name: "player_id", Type: field.TypeInt64},
|
||||||
{Name: "is_primary", Type: field.TypeBool, Nullable: true, Default: false},
|
{Name: "is_primary", Type: field.TypeBool, Nullable: true, Default: false},
|
||||||
@@ -60,22 +59,17 @@ var (
|
|||||||
ShopPlayersTable = &schema.Table{
|
ShopPlayersTable = &schema.Table{
|
||||||
Name: "shop_players",
|
Name: "shop_players",
|
||||||
Columns: ShopPlayersColumns,
|
Columns: ShopPlayersColumns,
|
||||||
PrimaryKey: []*schema.Column{ShopPlayersColumns[0]},
|
PrimaryKey: []*schema.Column{ShopPlayersColumns[0], ShopPlayersColumns[1]},
|
||||||
Indexes: []*schema.Index{
|
Indexes: []*schema.Index{
|
||||||
{
|
|
||||||
Name: "shopplayers_shop_id_player_id",
|
|
||||||
Unique: true,
|
|
||||||
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[2]},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "shopplayers_player_id",
|
Name: "shopplayers_player_id",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ShopPlayersColumns[2]},
|
Columns: []*schema.Column{ShopPlayersColumns[1]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "shopplayers_shop_id_joined_at",
|
Name: "shopplayers_shop_id_joined_at",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[4]},
|
Columns: []*schema.Column{ShopPlayersColumns[0], ShopPlayersColumns[3]},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -764,7 +764,6 @@ type ShopPlayersMutation struct {
|
|||||||
config
|
config
|
||||||
op Op
|
op Op
|
||||||
typ string
|
typ string
|
||||||
id *int64
|
|
||||||
shop_id *int64
|
shop_id *int64
|
||||||
addshop_id *int64
|
addshop_id *int64
|
||||||
player_id *int64
|
player_id *int64
|
||||||
@@ -797,35 +796,16 @@ func newShopPlayersMutation(c config, op Op, opts ...shopplayersOption) *ShopPla
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// withShopPlayersID sets the ID field of the mutation.
|
|
||||||
func withShopPlayersID(id int64) shopplayersOption {
|
|
||||||
return func(m *ShopPlayersMutation) {
|
|
||||||
var (
|
|
||||||
err error
|
|
||||||
once sync.Once
|
|
||||||
value *ShopPlayers
|
|
||||||
)
|
|
||||||
m.oldValue = func(ctx context.Context) (*ShopPlayers, error) {
|
|
||||||
once.Do(func() {
|
|
||||||
if m.done {
|
|
||||||
err = errors.New("querying old values post mutation is not allowed")
|
|
||||||
} else {
|
|
||||||
value, err = m.Client().ShopPlayers.Get(ctx, id)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return value, err
|
|
||||||
}
|
|
||||||
m.id = &id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// withShopPlayers sets the old ShopPlayers of the mutation.
|
// withShopPlayers sets the old ShopPlayers of the mutation.
|
||||||
func withShopPlayers(node *ShopPlayers) shopplayersOption {
|
func withShopPlayers(node *ShopPlayers) shopplayersOption {
|
||||||
return func(m *ShopPlayersMutation) {
|
return func(m *ShopPlayersMutation) {
|
||||||
m.oldValue = func(context.Context) (*ShopPlayers, error) {
|
m.oldValue = func(context.Context) (*ShopPlayers, error) {
|
||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
m.id = &node.ID
|
m.predicates = append(m.predicates,
|
||||||
|
shopplayers.ShopIDEQ(node.ShopID),
|
||||||
|
shopplayers.PlayerIDEQ(node.PlayerID),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,38 +828,12 @@ func (m ShopPlayersMutation) Tx() (*Tx, error) {
|
|||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the value of the id field. Note that this
|
|
||||||
// operation is only accepted on creation of ShopPlayers entities.
|
|
||||||
func (m *ShopPlayersMutation) SetID(id int64) {
|
|
||||||
m.id = &id
|
|
||||||
}
|
|
||||||
|
|
||||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
||||||
// if it was provided to the builder or after it was returned from the database.
|
|
||||||
func (m *ShopPlayersMutation) ID() (id int64, exists bool) {
|
|
||||||
if m.id == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return *m.id, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
||||||
// That means, if the mutation is applied within a transaction with an isolation level such
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
||||||
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
||||||
// or updated by the mutation.
|
// or updated by the mutation.
|
||||||
func (m *ShopPlayersMutation) IDs(ctx context.Context) ([]int64, error) {
|
func (m *ShopPlayersMutation) IDs(ctx context.Context) ([]int64, error) {
|
||||||
switch {
|
return nil, fmt.Errorf("IDs is not supported on %s operations for ShopPlayers", m.op)
|
||||||
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
||||||
id, exists := m.ID()
|
|
||||||
if exists {
|
|
||||||
return []int64{id}, nil
|
|
||||||
}
|
|
||||||
fallthrough
|
|
||||||
case m.op.Is(OpUpdate | OpDelete):
|
|
||||||
return m.Client().ShopPlayers.Query().Where(m.predicates...).IDs(ctx)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetShopID sets the "shop_id" field.
|
// SetShopID sets the "shop_id" field.
|
||||||
@@ -904,8 +858,8 @@ func (m *ShopPlayersMutation) OldShopID(ctx context.Context) (v int64, err error
|
|||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldShopID is only allowed on UpdateOne operations")
|
return v, errors.New("OldShopID is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.oldValue == nil {
|
||||||
return v, errors.New("OldShopID requires an ID field in the mutation")
|
return v, errors.New("OldShopID requires the old ShopPlayers value in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -960,8 +914,8 @@ func (m *ShopPlayersMutation) OldPlayerID(ctx context.Context) (v int64, err err
|
|||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldPlayerID is only allowed on UpdateOne operations")
|
return v, errors.New("OldPlayerID is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.oldValue == nil {
|
||||||
return v, errors.New("OldPlayerID requires an ID field in the mutation")
|
return v, errors.New("OldPlayerID requires the old ShopPlayers value in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1015,8 +969,8 @@ func (m *ShopPlayersMutation) OldIsPrimary(ctx context.Context) (v bool, err err
|
|||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldIsPrimary is only allowed on UpdateOne operations")
|
return v, errors.New("OldIsPrimary is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.oldValue == nil {
|
||||||
return v, errors.New("OldIsPrimary requires an ID field in the mutation")
|
return v, errors.New("OldIsPrimary requires the old ShopPlayers value in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1064,8 +1018,8 @@ func (m *ShopPlayersMutation) OldJoinedAt(ctx context.Context) (v time.Time, err
|
|||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldJoinedAt is only allowed on UpdateOne operations")
|
return v, errors.New("OldJoinedAt is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.oldValue == nil {
|
||||||
return v, errors.New("OldJoinedAt requires an ID field in the mutation")
|
return v, errors.New("OldJoinedAt requires the old ShopPlayers value in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1100,8 +1054,8 @@ func (m *ShopPlayersMutation) OldLeftAt(ctx context.Context) (v *time.Time, err
|
|||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldLeftAt is only allowed on UpdateOne operations")
|
return v, errors.New("OldLeftAt is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.oldValue == nil {
|
||||||
return v, errors.New("OldLeftAt requires an ID field in the mutation")
|
return v, errors.New("OldLeftAt requires the old ShopPlayers value in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ func init() {
|
|||||||
shopplayersFields := schema.ShopPlayers{}.Fields()
|
shopplayersFields := schema.ShopPlayers{}.Fields()
|
||||||
_ = shopplayersFields
|
_ = shopplayersFields
|
||||||
// shopplayersDescIsPrimary is the schema descriptor for is_primary field.
|
// shopplayersDescIsPrimary is the schema descriptor for is_primary field.
|
||||||
shopplayersDescIsPrimary := shopplayersFields[3].Descriptor()
|
shopplayersDescIsPrimary := shopplayersFields[2].Descriptor()
|
||||||
// shopplayers.DefaultIsPrimary holds the default value on creation for the is_primary field.
|
// shopplayers.DefaultIsPrimary holds the default value on creation for the is_primary field.
|
||||||
shopplayers.DefaultIsPrimary = shopplayersDescIsPrimary.Default.(bool)
|
shopplayers.DefaultIsPrimary = shopplayersDescIsPrimary.Default.(bool)
|
||||||
// shopplayersDescJoinedAt is the schema descriptor for joined_at field.
|
// shopplayersDescJoinedAt is the schema descriptor for joined_at field.
|
||||||
shopplayersDescJoinedAt := shopplayersFields[4].Descriptor()
|
shopplayersDescJoinedAt := shopplayersFields[3].Descriptor()
|
||||||
// shopplayers.DefaultJoinedAt holds the default value on creation for the joined_at field.
|
// shopplayers.DefaultJoinedAt holds the default value on creation for the joined_at field.
|
||||||
shopplayers.DefaultJoinedAt = shopplayersDescJoinedAt.Default.(func() time.Time)
|
shopplayers.DefaultJoinedAt = shopplayersDescJoinedAt.Default.(func() time.Time)
|
||||||
shopsFields := schema.Shops{}.Fields()
|
shopsFields := schema.Shops{}.Fields()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"entgo.io/ent/schema/index"
|
"entgo.io/ent/schema/index"
|
||||||
)
|
)
|
||||||
@@ -13,10 +14,15 @@ type ShopPlayers struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ShopPlayers) Annotations() []schema.Annotation {
|
||||||
|
return []schema.Annotation{
|
||||||
|
field.ID("shop_id", "player_id"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fields of the ShopPlayers.
|
// Fields of the ShopPlayers.
|
||||||
func (ShopPlayers) Fields() []ent.Field {
|
func (ShopPlayers) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.Int64("id").Immutable().Unique(),
|
|
||||||
field.Int64("shop_id"),
|
field.Int64("shop_id"),
|
||||||
field.Int64("player_id"),
|
field.Int64("player_id"),
|
||||||
field.Bool("is_primary").Optional().Default(false),
|
field.Bool("is_primary").Optional().Default(false),
|
||||||
@@ -28,13 +34,7 @@ func (ShopPlayers) Fields() []ent.Field {
|
|||||||
// Indexes of the ShopPlayers.
|
// Indexes of the ShopPlayers.
|
||||||
func (ShopPlayers) Indexes() []ent.Index {
|
func (ShopPlayers) Indexes() []ent.Index {
|
||||||
return []ent.Index{
|
return []ent.Index{
|
||||||
index.Fields("shop_id", "player_id").Unique(),
|
|
||||||
index.Fields("player_id"),
|
index.Fields("player_id"),
|
||||||
index.Fields("shop_id", "joined_at"),
|
index.Fields("shop_id", "joined_at"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edges of the ShopPlayers.
|
|
||||||
func (ShopPlayers) Edges() []ent.Edge {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import (
|
|||||||
// ShopPlayers is the model entity for the ShopPlayers schema.
|
// ShopPlayers is the model entity for the ShopPlayers schema.
|
||||||
type ShopPlayers struct {
|
type ShopPlayers struct {
|
||||||
config `json:"-"`
|
config `json:"-"`
|
||||||
// ID of the ent.
|
|
||||||
ID int64 `json:"id,omitempty"`
|
|
||||||
// ShopID holds the value of the "shop_id" field.
|
// ShopID holds the value of the "shop_id" field.
|
||||||
ShopID int64 `json:"shop_id,omitempty"`
|
ShopID int64 `json:"shop_id,omitempty"`
|
||||||
// PlayerID holds the value of the "player_id" field.
|
// PlayerID holds the value of the "player_id" field.
|
||||||
@@ -37,7 +35,7 @@ func (*ShopPlayers) scanValues(columns []string) ([]any, error) {
|
|||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case shopplayers.FieldIsPrimary:
|
case shopplayers.FieldIsPrimary:
|
||||||
values[i] = new(sql.NullBool)
|
values[i] = new(sql.NullBool)
|
||||||
case shopplayers.FieldID, shopplayers.FieldShopID, shopplayers.FieldPlayerID:
|
case shopplayers.FieldShopID, shopplayers.FieldPlayerID:
|
||||||
values[i] = new(sql.NullInt64)
|
values[i] = new(sql.NullInt64)
|
||||||
case shopplayers.FieldJoinedAt, shopplayers.FieldLeftAt:
|
case shopplayers.FieldJoinedAt, shopplayers.FieldLeftAt:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
@@ -56,12 +54,6 @@ func (_m *ShopPlayers) assignValues(columns []string, values []any) error {
|
|||||||
}
|
}
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case shopplayers.FieldID:
|
|
||||||
value, ok := values[i].(*sql.NullInt64)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("unexpected type %T for field id", value)
|
|
||||||
}
|
|
||||||
_m.ID = int64(value.Int64)
|
|
||||||
case shopplayers.FieldShopID:
|
case shopplayers.FieldShopID:
|
||||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field shop_id", values[i])
|
return fmt.Errorf("unexpected type %T for field shop_id", values[i])
|
||||||
@@ -128,7 +120,6 @@ func (_m *ShopPlayers) Unwrap() *ShopPlayers {
|
|||||||
func (_m *ShopPlayers) String() string {
|
func (_m *ShopPlayers) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("ShopPlayers(")
|
builder.WriteString("ShopPlayers(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
||||||
builder.WriteString("shop_id=")
|
builder.WriteString("shop_id=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", _m.ShopID))
|
builder.WriteString(fmt.Sprintf("%v", _m.ShopID))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
// Label holds the string label denoting the shopplayers type in the database.
|
// Label holds the string label denoting the shopplayers type in the database.
|
||||||
Label = "shop_players"
|
Label = "shop_players"
|
||||||
// FieldID holds the string denoting the id field in the database.
|
|
||||||
FieldID = "id"
|
|
||||||
// FieldShopID holds the string denoting the shop_id field in the database.
|
// FieldShopID holds the string denoting the shop_id field in the database.
|
||||||
FieldShopID = "shop_id"
|
FieldShopID = "shop_id"
|
||||||
// FieldPlayerID holds the string denoting the player_id field in the database.
|
// FieldPlayerID holds the string denoting the player_id field in the database.
|
||||||
@@ -29,7 +27,6 @@ const (
|
|||||||
|
|
||||||
// Columns holds all SQL columns for shopplayers fields.
|
// Columns holds all SQL columns for shopplayers fields.
|
||||||
var Columns = []string{
|
var Columns = []string{
|
||||||
FieldID,
|
|
||||||
FieldShopID,
|
FieldShopID,
|
||||||
FieldPlayerID,
|
FieldPlayerID,
|
||||||
FieldIsPrimary,
|
FieldIsPrimary,
|
||||||
@@ -57,11 +54,6 @@ var (
|
|||||||
// OrderOption defines the ordering options for the ShopPlayers queries.
|
// OrderOption defines the ordering options for the ShopPlayers queries.
|
||||||
type OrderOption func(*sql.Selector)
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
// ByID orders the results by the id field.
|
|
||||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|
||||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ByShopID orders the results by the shop_id field.
|
// ByShopID orders the results by the shop_id field.
|
||||||
func ByShopID(opts ...sql.OrderTermOption) OrderOption {
|
func ByShopID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
return sql.OrderByField(FieldShopID, opts...).ToFunc()
|
return sql.OrderByField(FieldShopID, opts...).ToFunc()
|
||||||
|
|||||||
@@ -9,51 +9,6 @@ import (
|
|||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ID filters vertices based on their ID field.
|
|
||||||
func ID(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldEQ(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDEQ applies the EQ predicate on the ID field.
|
|
||||||
func IDEQ(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldEQ(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDNEQ applies the NEQ predicate on the ID field.
|
|
||||||
func IDNEQ(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldNEQ(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDIn applies the In predicate on the ID field.
|
|
||||||
func IDIn(ids ...int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldIn(FieldID, ids...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
|
||||||
func IDNotIn(ids ...int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldNotIn(FieldID, ids...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDGT applies the GT predicate on the ID field.
|
|
||||||
func IDGT(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldGT(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDGTE applies the GTE predicate on the ID field.
|
|
||||||
func IDGTE(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldGTE(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDLT applies the LT predicate on the ID field.
|
|
||||||
func IDLT(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldLT(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDLTE applies the LTE predicate on the ID field.
|
|
||||||
func IDLTE(id int64) predicate.ShopPlayers {
|
|
||||||
return predicate.ShopPlayers(sql.FieldLTE(FieldID, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShopID applies equality check predicate on the "shop_id" field. It's identical to ShopIDEQ.
|
// ShopID applies equality check predicate on the "shop_id" field. It's identical to ShopIDEQ.
|
||||||
func ShopID(v int64) predicate.ShopPlayers {
|
func ShopID(v int64) predicate.ShopPlayers {
|
||||||
return predicate.ShopPlayers(sql.FieldEQ(FieldShopID, v))
|
return predicate.ShopPlayers(sql.FieldEQ(FieldShopID, v))
|
||||||
|
|||||||
@@ -74,12 +74,6 @@ func (_c *ShopPlayersCreate) SetNillableLeftAt(v *time.Time) *ShopPlayersCreate
|
|||||||
return _c
|
return _c
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the "id" field.
|
|
||||||
func (_c *ShopPlayersCreate) SetID(v int64) *ShopPlayersCreate {
|
|
||||||
_c.mutation.SetID(v)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mutation returns the ShopPlayersMutation object of the builder.
|
// Mutation returns the ShopPlayersMutation object of the builder.
|
||||||
func (_c *ShopPlayersCreate) Mutation() *ShopPlayersMutation {
|
func (_c *ShopPlayersCreate) Mutation() *ShopPlayersMutation {
|
||||||
return _c.mutation
|
return _c.mutation
|
||||||
@@ -150,11 +144,6 @@ func (_c *ShopPlayersCreate) sqlSave(ctx context.Context) (*ShopPlayers, error)
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _spec.ID.Value != _node.ID {
|
|
||||||
id := _spec.ID.Value.(int64)
|
|
||||||
_node.ID = int64(id)
|
|
||||||
}
|
|
||||||
_c.mutation.id = &_node.ID
|
|
||||||
_c.mutation.done = true
|
_c.mutation.done = true
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
@@ -162,12 +151,8 @@ func (_c *ShopPlayersCreate) sqlSave(ctx context.Context) (*ShopPlayers, error)
|
|||||||
func (_c *ShopPlayersCreate) createSpec() (*ShopPlayers, *sqlgraph.CreateSpec) {
|
func (_c *ShopPlayersCreate) createSpec() (*ShopPlayers, *sqlgraph.CreateSpec) {
|
||||||
var (
|
var (
|
||||||
_node = &ShopPlayers{config: _c.config}
|
_node = &ShopPlayers{config: _c.config}
|
||||||
_spec = sqlgraph.NewCreateSpec(shopplayers.Table, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
_spec = sqlgraph.NewCreateSpec(shopplayers.Table, nil)
|
||||||
)
|
)
|
||||||
if id, ok := _c.mutation.ID(); ok {
|
|
||||||
_node.ID = id
|
|
||||||
_spec.ID.Value = id
|
|
||||||
}
|
|
||||||
if value, ok := _c.mutation.ShopID(); ok {
|
if value, ok := _c.mutation.ShopID(); ok {
|
||||||
_spec.SetField(shopplayers.FieldShopID, field.TypeInt64, value)
|
_spec.SetField(shopplayers.FieldShopID, field.TypeInt64, value)
|
||||||
_node.ShopID = value
|
_node.ShopID = value
|
||||||
@@ -235,11 +220,6 @@ func (_c *ShopPlayersCreateBulk) Save(ctx context.Context) ([]*ShopPlayers, erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
|
||||||
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
||||||
id := specs[i].ID.Value.(int64)
|
|
||||||
nodes[i].ID = int64(id)
|
|
||||||
}
|
|
||||||
mutation.done = true
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
"entgo.io/ent/schema/field"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShopPlayersDelete is the builder for deleting a ShopPlayers entity.
|
// ShopPlayersDelete is the builder for deleting a ShopPlayers entity.
|
||||||
@@ -40,7 +39,7 @@ func (_d *ShopPlayersDelete) ExecX(ctx context.Context) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (_d *ShopPlayersDelete) sqlExec(ctx context.Context) (int, error) {
|
func (_d *ShopPlayersDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
_spec := sqlgraph.NewDeleteSpec(shopplayers.Table, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
_spec := sqlgraph.NewDeleteSpec(shopplayers.Table, nil)
|
||||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
_spec.Predicate = func(selector *sql.Selector) {
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
for i := range ps {
|
for i := range ps {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
"entgo.io/ent/schema/field"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShopPlayersQuery is the builder for querying ShopPlayers entities.
|
// ShopPlayersQuery is the builder for querying ShopPlayers entities.
|
||||||
@@ -80,29 +79,6 @@ func (_q *ShopPlayersQuery) FirstX(ctx context.Context) *ShopPlayers {
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
// FirstID returns the first ShopPlayers ID from the query.
|
|
||||||
// Returns a *NotFoundError when no ShopPlayers ID was found.
|
|
||||||
func (_q *ShopPlayersQuery) FirstID(ctx context.Context) (id int64, err error) {
|
|
||||||
var ids []int64
|
|
||||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(ids) == 0 {
|
|
||||||
err = &NotFoundError{shopplayers.Label}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return ids[0], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
|
||||||
func (_q *ShopPlayersQuery) FirstIDX(ctx context.Context) int64 {
|
|
||||||
id, err := _q.FirstID(ctx)
|
|
||||||
if err != nil && !IsNotFound(err) {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only returns a single ShopPlayers entity found by the query, ensuring it only returns one.
|
// Only returns a single ShopPlayers entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when more than one ShopPlayers entity is found.
|
// Returns a *NotSingularError when more than one ShopPlayers entity is found.
|
||||||
// Returns a *NotFoundError when no ShopPlayers entities are found.
|
// Returns a *NotFoundError when no ShopPlayers entities are found.
|
||||||
@@ -130,34 +106,6 @@ func (_q *ShopPlayersQuery) OnlyX(ctx context.Context) *ShopPlayers {
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only ShopPlayers ID in the query.
|
|
||||||
// Returns a *NotSingularError when more than one ShopPlayers ID is found.
|
|
||||||
// Returns a *NotFoundError when no entities are found.
|
|
||||||
func (_q *ShopPlayersQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
|
||||||
var ids []int64
|
|
||||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(ids) {
|
|
||||||
case 1:
|
|
||||||
id = ids[0]
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{shopplayers.Label}
|
|
||||||
default:
|
|
||||||
err = &NotSingularError{shopplayers.Label}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
|
||||||
func (_q *ShopPlayersQuery) OnlyIDX(ctx context.Context) int64 {
|
|
||||||
id, err := _q.OnlyID(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
|
||||||
// All executes the query and returns a list of ShopPlayersSlice.
|
// All executes the query and returns a list of ShopPlayersSlice.
|
||||||
func (_q *ShopPlayersQuery) All(ctx context.Context) ([]*ShopPlayers, error) {
|
func (_q *ShopPlayersQuery) All(ctx context.Context) ([]*ShopPlayers, error) {
|
||||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
@@ -177,27 +125,6 @@ func (_q *ShopPlayersQuery) AllX(ctx context.Context) []*ShopPlayers {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDs executes the query and returns a list of ShopPlayers IDs.
|
|
||||||
func (_q *ShopPlayersQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
|
||||||
if _q.ctx.Unique == nil && _q.path != nil {
|
|
||||||
_q.Unique(true)
|
|
||||||
}
|
|
||||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
|
||||||
if err = _q.Select(shopplayers.FieldID).Scan(ctx, &ids); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ids, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDsX is like IDs, but panics if an error occurs.
|
|
||||||
func (_q *ShopPlayersQuery) IDsX(ctx context.Context) []int64 {
|
|
||||||
ids, err := _q.IDs(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return ids
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count returns the count of the given query.
|
// Count returns the count of the given query.
|
||||||
func (_q *ShopPlayersQuery) Count(ctx context.Context) (int, error) {
|
func (_q *ShopPlayersQuery) Count(ctx context.Context) (int, error) {
|
||||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
@@ -219,7 +146,7 @@ func (_q *ShopPlayersQuery) CountX(ctx context.Context) int {
|
|||||||
// Exist returns true if the query has elements in the graph.
|
// Exist returns true if the query has elements in the graph.
|
||||||
func (_q *ShopPlayersQuery) Exist(ctx context.Context) (bool, error) {
|
func (_q *ShopPlayersQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
switch _, err := _q.FirstID(ctx); {
|
switch _, err := _q.First(ctx); {
|
||||||
case IsNotFound(err):
|
case IsNotFound(err):
|
||||||
return false, nil
|
return false, nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@@ -365,7 +292,7 @@ func (_q *ShopPlayersQuery) sqlCount(ctx context.Context) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (_q *ShopPlayersQuery) querySpec() *sqlgraph.QuerySpec {
|
func (_q *ShopPlayersQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
_spec := sqlgraph.NewQuerySpec(shopplayers.Table, shopplayers.Columns, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
_spec := sqlgraph.NewQuerySpec(shopplayers.Table, shopplayers.Columns, nil)
|
||||||
_spec.From = _q.sql
|
_spec.From = _q.sql
|
||||||
if unique := _q.ctx.Unique; unique != nil {
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
_spec.Unique = *unique
|
_spec.Unique = *unique
|
||||||
@@ -374,11 +301,8 @@ func (_q *ShopPlayersQuery) querySpec() *sqlgraph.QuerySpec {
|
|||||||
}
|
}
|
||||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, shopplayers.FieldID)
|
|
||||||
for i := range fields {
|
for i := range fields {
|
||||||
if fields[i] != shopplayers.FieldID {
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ps := _q.predicates; len(ps) > 0 {
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"juwan-backend/app/shop/rpc/internal/models/predicate"
|
"juwan-backend/app/shop/rpc/internal/models/predicate"
|
||||||
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
|
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
|
||||||
@@ -143,7 +142,7 @@ func (_u *ShopPlayersUpdate) ExecX(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (_u *ShopPlayersUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
func (_u *ShopPlayersUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||||
_spec := sqlgraph.NewUpdateSpec(shopplayers.Table, shopplayers.Columns, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
_spec := sqlgraph.NewUpdateSpec(shopplayers.Table, shopplayers.Columns)
|
||||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
_spec.Predicate = func(selector *sql.Selector) {
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
for i := range ps {
|
for i := range ps {
|
||||||
@@ -323,22 +322,14 @@ func (_u *ShopPlayersUpdateOne) ExecX(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (_u *ShopPlayersUpdateOne) sqlSave(ctx context.Context) (_node *ShopPlayers, err error) {
|
func (_u *ShopPlayersUpdateOne) sqlSave(ctx context.Context) (_node *ShopPlayers, err error) {
|
||||||
_spec := sqlgraph.NewUpdateSpec(shopplayers.Table, shopplayers.Columns, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
_spec := sqlgraph.NewUpdateSpec(shopplayers.Table, shopplayers.Columns)
|
||||||
id, ok := _u.mutation.ID()
|
|
||||||
if !ok {
|
|
||||||
return nil, &ValidationError{Name: "id", err: errors.New(`models: missing "ShopPlayers.id" for update`)}
|
|
||||||
}
|
|
||||||
_spec.Node.ID.Value = id
|
|
||||||
if fields := _u.fields; len(fields) > 0 {
|
if fields := _u.fields; len(fields) > 0 {
|
||||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, shopplayers.FieldID)
|
|
||||||
for _, f := range fields {
|
for _, f := range fields {
|
||||||
if !shopplayers.ValidColumn(f) {
|
if !shopplayers.ValidColumn(f) {
|
||||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("models: invalid field %q for query", f)}
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("models: invalid field %q for query", f)}
|
||||||
}
|
}
|
||||||
if f != shopplayers.FieldID {
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
|||||||
+31
-13
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.11
|
// protoc-gen-go v1.36.11
|
||||||
// protoc v5.29.6
|
// protoc v3.19.4
|
||||||
// source: shop.proto
|
// source: shop.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -993,7 +993,8 @@ func (*UpdateShopPlayersResp) Descriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
type DelShopPlayersReq struct {
|
type DelShopPlayersReq struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //id
|
ShopId int64 `protobuf:"varint,1,opt,name=shopId,proto3" json:"shopId,omitempty"` //shopId
|
||||||
|
PlayerId int64 `protobuf:"varint,2,opt,name=playerId,proto3" json:"playerId,omitempty"` //playerId
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -1028,9 +1029,16 @@ func (*DelShopPlayersReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_shop_proto_rawDescGZIP(), []int{16}
|
return file_shop_proto_rawDescGZIP(), []int{16}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DelShopPlayersReq) GetId() int64 {
|
func (x *DelShopPlayersReq) GetShopId() int64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.ShopId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DelShopPlayersReq) GetPlayerId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.PlayerId
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -1073,7 +1081,8 @@ func (*DelShopPlayersResp) Descriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
type GetShopPlayersByIdReq struct {
|
type GetShopPlayersByIdReq struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //id
|
ShopId int64 `protobuf:"varint,1,opt,name=shopId,proto3" json:"shopId,omitempty"` //shopId
|
||||||
|
PlayerId int64 `protobuf:"varint,2,opt,name=playerId,proto3" json:"playerId,omitempty"` //playerId
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -1108,9 +1117,16 @@ func (*GetShopPlayersByIdReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_shop_proto_rawDescGZIP(), []int{18}
|
return file_shop_proto_rawDescGZIP(), []int{18}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetShopPlayersByIdReq) GetId() int64 {
|
func (x *GetShopPlayersByIdReq) GetShopId() int64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.ShopId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetShopPlayersByIdReq) GetPlayerId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.PlayerId
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -2346,12 +2362,14 @@ const file_shop_proto_rawDesc = "" +
|
|||||||
"\tisPrimary\x18\x03 \x01(\bR\tisPrimary\x12\x1a\n" +
|
"\tisPrimary\x18\x03 \x01(\bR\tisPrimary\x12\x1a\n" +
|
||||||
"\bjoinedAt\x18\x04 \x01(\x03R\bjoinedAt\x12\x16\n" +
|
"\bjoinedAt\x18\x04 \x01(\x03R\bjoinedAt\x12\x16\n" +
|
||||||
"\x06leftAt\x18\x05 \x01(\x03R\x06leftAt\"\x17\n" +
|
"\x06leftAt\x18\x05 \x01(\x03R\x06leftAt\"\x17\n" +
|
||||||
"\x15UpdateShopPlayersResp\"#\n" +
|
"\x15UpdateShopPlayersResp\"G\n" +
|
||||||
"\x11DelShopPlayersReq\x12\x0e\n" +
|
"\x11DelShopPlayersReq\x12\x16\n" +
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\"\x14\n" +
|
"\x06shopId\x18\x01 \x01(\x03R\x06shopId\x12\x1a\n" +
|
||||||
"\x12DelShopPlayersResp\"'\n" +
|
"\bplayerId\x18\x02 \x01(\x03R\bplayerId\"\x14\n" +
|
||||||
"\x15GetShopPlayersByIdReq\x12\x0e\n" +
|
"\x12DelShopPlayersResp\"K\n" +
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\"K\n" +
|
"\x15GetShopPlayersByIdReq\x12\x16\n" +
|
||||||
|
"\x06shopId\x18\x01 \x01(\x03R\x06shopId\x12\x1a\n" +
|
||||||
|
"\bplayerId\x18\x02 \x01(\x03R\bplayerId\"K\n" +
|
||||||
"\x16GetShopPlayersByIdResp\x121\n" +
|
"\x16GetShopPlayersByIdResp\x121\n" +
|
||||||
"\vshopPlayers\x18\x01 \x01(\v2\x0f.pb.ShopPlayersR\vshopPlayers\"\xc6\x01\n" +
|
"\vshopPlayers\x18\x01 \x01(\v2\x0f.pb.ShopPlayersR\vshopPlayers\"\xc6\x01\n" +
|
||||||
"\x14SearchShopPlayersReq\x12\x12\n" +
|
"\x14SearchShopPlayersReq\x12\x12\n" +
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.6.1
|
// - protoc-gen-go-grpc v1.6.1
|
||||||
// - protoc v5.29.6
|
// - protoc v3.19.4
|
||||||
// source: shop.proto
|
// source: shop.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
|
|||||||
+4
-2
@@ -108,14 +108,16 @@ message UpdateShopPlayersResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message DelShopPlayersReq {
|
message DelShopPlayersReq {
|
||||||
int64 id = 1; //id
|
int64 shopId = 1; //shopId
|
||||||
|
int64 playerId = 2; //playerId
|
||||||
}
|
}
|
||||||
|
|
||||||
message DelShopPlayersResp {
|
message DelShopPlayersResp {
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetShopPlayersByIdReq {
|
message GetShopPlayersByIdReq {
|
||||||
int64 id = 1; //id
|
int64 shopId = 1; //shopId
|
||||||
|
int64 playerId = 2; //playerId
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetShopPlayersByIdResp {
|
message GetShopPlayersByIdResp {
|
||||||
|
|||||||
Reference in New Issue
Block a user