added chat messages
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
@@ -499,6 +500,21 @@ func (mpc *MatchPlayerCreate) AddSpray(s ...*Spray) *MatchPlayerCreate {
|
||||
return mpc.AddSprayIDs(ids...)
|
||||
}
|
||||
|
||||
// AddMessageIDs adds the "messages" edge to the Messages entity by IDs.
|
||||
func (mpc *MatchPlayerCreate) AddMessageIDs(ids ...int) *MatchPlayerCreate {
|
||||
mpc.mutation.AddMessageIDs(ids...)
|
||||
return mpc
|
||||
}
|
||||
|
||||
// AddMessages adds the "messages" edges to the Messages entity.
|
||||
func (mpc *MatchPlayerCreate) AddMessages(m ...*Messages) *MatchPlayerCreate {
|
||||
ids := make([]int, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
return mpc.AddMessageIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the MatchPlayerMutation object of the builder.
|
||||
func (mpc *MatchPlayerCreate) Mutation() *MatchPlayerMutation {
|
||||
return mpc.mutation
|
||||
@@ -570,29 +586,29 @@ func (mpc *MatchPlayerCreate) ExecX(ctx context.Context) {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mpc *MatchPlayerCreate) check() error {
|
||||
if _, ok := mpc.mutation.TeamID(); !ok {
|
||||
return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "team_id"`)}
|
||||
return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "MatchPlayer.team_id"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Kills(); !ok {
|
||||
return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "kills"`)}
|
||||
return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "MatchPlayer.kills"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Deaths(); !ok {
|
||||
return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "deaths"`)}
|
||||
return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "MatchPlayer.deaths"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Assists(); !ok {
|
||||
return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "assists"`)}
|
||||
return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "MatchPlayer.assists"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Headshot(); !ok {
|
||||
return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "headshot"`)}
|
||||
return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "MatchPlayer.headshot"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Mvp(); !ok {
|
||||
return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "mvp"`)}
|
||||
return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "MatchPlayer.mvp"`)}
|
||||
}
|
||||
if _, ok := mpc.mutation.Score(); !ok {
|
||||
return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "score"`)}
|
||||
return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "MatchPlayer.score"`)}
|
||||
}
|
||||
if v, ok := mpc.mutation.Color(); ok {
|
||||
if err := matchplayer.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "color": %w`, err)}
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "MatchPlayer.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -959,6 +975,25 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := mpc.mutation.MessagesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: matchplayer.MessagesTable,
|
||||
Columns: []string{matchplayer.MessagesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: messages.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user