added roundstats with eco info, switched to avatar hash
This commit is contained in:
129
ent/client.go
129
ent/client.go
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/stats"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
|
||||
@@ -28,6 +29,8 @@ type Client struct {
|
||||
Match *MatchClient
|
||||
// Player is the client for interacting with the Player builders.
|
||||
Player *PlayerClient
|
||||
// RoundStats is the client for interacting with the RoundStats builders.
|
||||
RoundStats *RoundStatsClient
|
||||
// Stats is the client for interacting with the Stats builders.
|
||||
Stats *StatsClient
|
||||
// WeaponStats is the client for interacting with the WeaponStats builders.
|
||||
@@ -47,6 +50,7 @@ func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.Match = NewMatchClient(c.config)
|
||||
c.Player = NewPlayerClient(c.config)
|
||||
c.RoundStats = NewRoundStatsClient(c.config)
|
||||
c.Stats = NewStatsClient(c.config)
|
||||
c.WeaponStats = NewWeaponStatsClient(c.config)
|
||||
}
|
||||
@@ -84,6 +88,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
config: cfg,
|
||||
Match: NewMatchClient(cfg),
|
||||
Player: NewPlayerClient(cfg),
|
||||
RoundStats: NewRoundStatsClient(cfg),
|
||||
Stats: NewStatsClient(cfg),
|
||||
WeaponStats: NewWeaponStatsClient(cfg),
|
||||
}, nil
|
||||
@@ -106,6 +111,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
config: cfg,
|
||||
Match: NewMatchClient(cfg),
|
||||
Player: NewPlayerClient(cfg),
|
||||
RoundStats: NewRoundStatsClient(cfg),
|
||||
Stats: NewStatsClient(cfg),
|
||||
WeaponStats: NewWeaponStatsClient(cfg),
|
||||
}, nil
|
||||
@@ -139,6 +145,7 @@ func (c *Client) Close() error {
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.Match.Use(hooks...)
|
||||
c.Player.Use(hooks...)
|
||||
c.RoundStats.Use(hooks...)
|
||||
c.Stats.Use(hooks...)
|
||||
c.WeaponStats.Use(hooks...)
|
||||
}
|
||||
@@ -387,6 +394,112 @@ func (c *PlayerClient) Hooks() []Hook {
|
||||
return c.hooks.Player
|
||||
}
|
||||
|
||||
// RoundStatsClient is a client for the RoundStats schema.
|
||||
type RoundStatsClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewRoundStatsClient returns a client for the RoundStats from the given config.
|
||||
func NewRoundStatsClient(c config) *RoundStatsClient {
|
||||
return &RoundStatsClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `roundstats.Hooks(f(g(h())))`.
|
||||
func (c *RoundStatsClient) Use(hooks ...Hook) {
|
||||
c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for RoundStats.
|
||||
func (c *RoundStatsClient) Create() *RoundStatsCreate {
|
||||
mutation := newRoundStatsMutation(c.config, OpCreate)
|
||||
return &RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of RoundStats entities.
|
||||
func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStatsCreateBulk {
|
||||
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for RoundStats.
|
||||
func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdate)
|
||||
return &RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs))
|
||||
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *RoundStatsClient) UpdateOneID(id int) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStatsID(id))
|
||||
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for RoundStats.
|
||||
func (c *RoundStatsClient) Delete() *RoundStatsDelete {
|
||||
mutation := newRoundStatsMutation(c.config, OpDelete)
|
||||
return &RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
|
||||
return c.DeleteOneID(rs.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
|
||||
builder := c.Delete().Where(roundstats.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &RoundStatsDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for RoundStats.
|
||||
func (c *RoundStatsClient) Query() *RoundStatsQuery {
|
||||
return &RoundStatsQuery{
|
||||
config: c.config,
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a RoundStats entity by its id.
|
||||
func (c *RoundStatsClient) Get(ctx context.Context, id int) (*RoundStats, error) {
|
||||
return c.Query().Where(roundstats.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryStat queries the stat edge of a RoundStats.
|
||||
func (c *RoundStatsClient) QueryStat(rs *RoundStats) *StatsQuery {
|
||||
query := &StatsQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := rs.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(roundstats.Table, roundstats.FieldID, id),
|
||||
sqlgraph.To(stats.Table, stats.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.StatTable, roundstats.StatColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *RoundStatsClient) Hooks() []Hook {
|
||||
return c.hooks.RoundStats
|
||||
}
|
||||
|
||||
// StatsClient is a client for the Stats schema.
|
||||
type StatsClient struct {
|
||||
config
|
||||
@@ -520,6 +633,22 @@ func (c *StatsClient) QueryWeaponStats(s *Stats) *WeaponStatsQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoundStats queries the round_stats edge of a Stats.
|
||||
func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery {
|
||||
query := &RoundStatsQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := s.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(stats.Table, stats.FieldID, id),
|
||||
sqlgraph.To(roundstats.Table, roundstats.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *StatsClient) Hooks() []Hook {
|
||||
return c.hooks.Stats
|
||||
|
Reference in New Issue
Block a user