added chat messages

This commit is contained in:
2022-01-29 19:32:13 +01:00
parent 2e6c94de81
commit b036275665
48 changed files with 4167 additions and 353 deletions

View File

@@ -11,6 +11,7 @@ import (
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
@@ -30,6 +31,8 @@ type Client struct {
Match *MatchClient
// MatchPlayer is the client for interacting with the MatchPlayer builders.
MatchPlayer *MatchPlayerClient
// Messages is the client for interacting with the Messages builders.
Messages *MessagesClient
// Player is the client for interacting with the Player builders.
Player *PlayerClient
// RoundStats is the client for interacting with the RoundStats builders.
@@ -53,6 +56,7 @@ func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.Match = NewMatchClient(c.config)
c.MatchPlayer = NewMatchPlayerClient(c.config)
c.Messages = NewMessagesClient(c.config)
c.Player = NewPlayerClient(c.config)
c.RoundStats = NewRoundStatsClient(c.config)
c.Spray = NewSprayClient(c.config)
@@ -92,6 +96,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
config: cfg,
Match: NewMatchClient(cfg),
MatchPlayer: NewMatchPlayerClient(cfg),
Messages: NewMessagesClient(cfg),
Player: NewPlayerClient(cfg),
RoundStats: NewRoundStatsClient(cfg),
Spray: NewSprayClient(cfg),
@@ -113,9 +118,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
ctx: ctx,
config: cfg,
Match: NewMatchClient(cfg),
MatchPlayer: NewMatchPlayerClient(cfg),
Messages: NewMessagesClient(cfg),
Player: NewPlayerClient(cfg),
RoundStats: NewRoundStatsClient(cfg),
Spray: NewSprayClient(cfg),
@@ -151,6 +158,7 @@ func (c *Client) Close() error {
func (c *Client) Use(hooks ...Hook) {
c.Match.Use(hooks...)
c.MatchPlayer.Use(hooks...)
c.Messages.Use(hooks...)
c.Player.Use(hooks...)
c.RoundStats.Use(hooks...)
c.Spray.Use(hooks...)
@@ -444,11 +452,133 @@ func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
return query
}
// QueryMessages queries the messages edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery {
query := &MessagesQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(messages.Table, messages.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn),
)
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *MatchPlayerClient) Hooks() []Hook {
return c.hooks.MatchPlayer
}
// MessagesClient is a client for the Messages schema.
type MessagesClient struct {
config
}
// NewMessagesClient returns a client for the Messages from the given config.
func NewMessagesClient(c config) *MessagesClient {
return &MessagesClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `messages.Hooks(f(g(h())))`.
func (c *MessagesClient) Use(hooks ...Hook) {
c.hooks.Messages = append(c.hooks.Messages, hooks...)
}
// Create returns a create builder for Messages.
func (c *MessagesClient) Create() *MessagesCreate {
mutation := newMessagesMutation(c.config, OpCreate)
return &MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Messages entities.
func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreateBulk {
return &MessagesCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Messages.
func (c *MessagesClient) Update() *MessagesUpdate {
mutation := newMessagesMutation(c.config, OpUpdate)
return &MessagesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne {
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m))
return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *MessagesClient) UpdateOneID(id int) *MessagesUpdateOne {
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessagesID(id))
return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Messages.
func (c *MessagesClient) Delete() *MessagesDelete {
mutation := newMessagesMutation(c.config, OpDelete)
return &MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOneID returns a delete builder for the given id.
func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne {
builder := c.Delete().Where(messages.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &MessagesDeleteOne{builder}
}
// Query returns a query builder for Messages.
func (c *MessagesClient) Query() *MessagesQuery {
return &MessagesQuery{
config: c.config,
}
}
// Get returns a Messages entity by its id.
func (c *MessagesClient) Get(ctx context.Context, id int) (*Messages, error) {
return c.Query().Where(messages.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryMatchPlayer queries the match_player edge of a Messages.
func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(messages.Table, messages.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn),
)
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *MessagesClient) Hooks() []Hook {
return c.hooks.Messages
}
// PlayerClient is a client for the Player schema.
type PlayerClient struct {
config