1118 lines
33 KiB
Go
1118 lines
33 KiB
Go
// ENT数据库文件,请勿编辑。
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"likedream-goframe/internal/ent/cpschool"
|
|
"likedream-goframe/internal/ent/cptask"
|
|
"likedream-goframe/internal/ent/cptasklog"
|
|
"likedream-goframe/internal/ent/cpuser"
|
|
"likedream-goframe/internal/ent/internal"
|
|
"likedream-goframe/internal/ent/predicate"
|
|
"likedream-goframe/internal/ent/sysuser"
|
|
"likedream-goframe/internal/framework/ent2"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// CpUserUpdate is the builder for updating CpUser entities.
|
|
type CpUserUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *CpUserMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the CpUserUpdate builder.
|
|
func (_u *CpUserUpdate) Where(ps ...predicate.CpUser) *CpUserUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *CpUserUpdate) SetUpdateTime(v *ent2.CustomTime) *CpUserUpdate {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *CpUserUpdate) SetUserID(v int64) *CpUserUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableUserID(v *int64) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_u *CpUserUpdate) SetUsername(v string) *CpUserUpdate {
|
|
_u.mutation.SetUsername(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableUsername(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetUsername(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *CpUserUpdate) SetPassword(v string) *CpUserUpdate {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillablePassword(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (_u *CpUserUpdate) SetSchoolID(v string) *CpUserUpdate {
|
|
_u.mutation.SetSchoolID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSchoolID sets the "school_id" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableSchoolID(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetSchoolID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *CpUserUpdate) SetEmail(v string) *CpUserUpdate {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableEmail(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (_u *CpUserUpdate) ClearEmail() *CpUserUpdate {
|
|
_u.mutation.ClearEmail()
|
|
return _u
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (_u *CpUserUpdate) SetMobileCode(v string) *CpUserUpdate {
|
|
_u.mutation.SetMobileCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMobileCode sets the "mobile_code" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableMobileCode(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetMobileCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMobileCode clears the value of the "mobile_code" field.
|
|
func (_u *CpUserUpdate) ClearMobileCode() *CpUserUpdate {
|
|
_u.mutation.ClearMobileCode()
|
|
return _u
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (_u *CpUserUpdate) SetCookie(v string) *CpUserUpdate {
|
|
_u.mutation.SetCookie(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCookie sets the "cookie" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableCookie(v *string) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetCookie(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCookie clears the value of the "cookie" field.
|
|
func (_u *CpUserUpdate) ClearCookie() *CpUserUpdate {
|
|
_u.mutation.ClearCookie()
|
|
return _u
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (_u *CpUserUpdate) SetMobileType(v cpuser.MobileType) *CpUserUpdate {
|
|
_u.mutation.SetMobileType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMobileType sets the "mobile_type" field if the given value is not nil.
|
|
func (_u *CpUserUpdate) SetNillableMobileType(v *cpuser.MobileType) *CpUserUpdate {
|
|
if v != nil {
|
|
_u.SetMobileType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCptaskIDs adds the "cptasks" edge to the CpTask entity by IDs.
|
|
func (_u *CpUserUpdate) AddCptaskIDs(ids ...int64) *CpUserUpdate {
|
|
_u.mutation.AddCptaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddCptasks adds the "cptasks" edges to the CpTask entity.
|
|
func (_u *CpUserUpdate) AddCptasks(v ...*CpTask) *CpUserUpdate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCptaskIDs(ids...)
|
|
}
|
|
|
|
// SetSysuserID sets the "sysuser" edge to the SysUser entity by ID.
|
|
func (_u *CpUserUpdate) SetSysuserID(id int64) *CpUserUpdate {
|
|
_u.mutation.SetSysuserID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetSysuser sets the "sysuser" edge to the SysUser entity.
|
|
func (_u *CpUserUpdate) SetSysuser(v *SysUser) *CpUserUpdate {
|
|
return _u.SetSysuserID(v.ID)
|
|
}
|
|
|
|
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
|
|
func (_u *CpUserUpdate) AddCpTaskLogIDs(ids ...int64) *CpUserUpdate {
|
|
_u.mutation.AddCpTaskLogIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddCpTaskLogs adds the "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_u *CpUserUpdate) AddCpTaskLogs(v ...*CpTaskLog) *CpUserUpdate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// SetSchool sets the "school" edge to the CpSchool entity.
|
|
func (_u *CpUserUpdate) SetSchool(v *CpSchool) *CpUserUpdate {
|
|
return _u.SetSchoolID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the CpUserMutation object of the builder.
|
|
func (_u *CpUserUpdate) Mutation() *CpUserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCptasks clears all "cptasks" edges to the CpTask entity.
|
|
func (_u *CpUserUpdate) ClearCptasks() *CpUserUpdate {
|
|
_u.mutation.ClearCptasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCptaskIDs removes the "cptasks" edge to CpTask entities by IDs.
|
|
func (_u *CpUserUpdate) RemoveCptaskIDs(ids ...int64) *CpUserUpdate {
|
|
_u.mutation.RemoveCptaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveCptasks removes "cptasks" edges to CpTask entities.
|
|
func (_u *CpUserUpdate) RemoveCptasks(v ...*CpTask) *CpUserUpdate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCptaskIDs(ids...)
|
|
}
|
|
|
|
// ClearSysuser clears the "sysuser" edge to the SysUser entity.
|
|
func (_u *CpUserUpdate) ClearSysuser() *CpUserUpdate {
|
|
_u.mutation.ClearSysuser()
|
|
return _u
|
|
}
|
|
|
|
// ClearCpTaskLogs clears all "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_u *CpUserUpdate) ClearCpTaskLogs() *CpUserUpdate {
|
|
_u.mutation.ClearCpTaskLogs()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCpTaskLogIDs removes the "cp_task_logs" edge to CpTaskLog entities by IDs.
|
|
func (_u *CpUserUpdate) RemoveCpTaskLogIDs(ids ...int64) *CpUserUpdate {
|
|
_u.mutation.RemoveCpTaskLogIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveCpTaskLogs removes "cp_task_logs" edges to CpTaskLog entities.
|
|
func (_u *CpUserUpdate) RemoveCpTaskLogs(v ...*CpTaskLog) *CpUserUpdate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// ClearSchool clears the "school" edge to the CpSchool entity.
|
|
func (_u *CpUserUpdate) ClearSchool() *CpUserUpdate {
|
|
_u.mutation.ClearSchool()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *CpUserUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *CpUserUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *CpUserUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *CpUserUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *CpUserUpdate) check() error {
|
|
if v, ok := _u.mutation.Username(); ok {
|
|
if err := cpuser.UsernameValidator(v); err != nil {
|
|
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "CpUser.username": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Password(); ok {
|
|
if err := cpuser.PasswordValidator(v); err != nil {
|
|
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "CpUser.password": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SchoolID(); ok {
|
|
if err := cpuser.SchoolIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "school_id", err: fmt.Errorf(`ent: validator failed for field "CpUser.school_id": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MobileType(); ok {
|
|
if err := cpuser.MobileTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "mobile_type", err: fmt.Errorf(`ent: validator failed for field "CpUser.mobile_type": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.SysuserCleared() && len(_u.mutation.SysuserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpUser.sysuser"`)
|
|
}
|
|
if _u.mutation.SchoolCleared() && len(_u.mutation.SchoolIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpUser.school"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *CpUserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CpUserUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *CpUserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(cpuser.Table, cpuser.Columns, sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Username(); ok {
|
|
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
_spec.SetField(cpuser.FieldPassword, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(cpuser.FieldEmail, field.TypeString, value)
|
|
}
|
|
if _u.mutation.EmailCleared() {
|
|
_spec.ClearField(cpuser.FieldEmail, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.MobileCode(); ok {
|
|
_spec.SetField(cpuser.FieldMobileCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MobileCodeCleared() {
|
|
_spec.ClearField(cpuser.FieldMobileCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Cookie(); ok {
|
|
_spec.SetField(cpuser.FieldCookie, field.TypeString, value)
|
|
}
|
|
if _u.mutation.CookieCleared() {
|
|
_spec.ClearField(cpuser.FieldCookie, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.MobileType(); ok {
|
|
_spec.SetField(cpuser.FieldMobileType, field.TypeEnum, value)
|
|
}
|
|
if _u.mutation.CptasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCptasksIDs(); len(nodes) > 0 && !_u.mutation.CptasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CptasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SysuserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SysuserTable,
|
|
Columns: []string{cpuser.SysuserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SysuserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SysuserTable,
|
|
Columns: []string{cpuser.SysuserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.CpTaskLogsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCpTaskLogsIDs(); len(nodes) > 0 && !_u.mutation.CpTaskLogsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpTaskLogsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SchoolCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SchoolTable,
|
|
Columns: []string{cpuser.SchoolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpschool.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SchoolIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SchoolTable,
|
|
Columns: []string{cpuser.SchoolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpschool.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.Node.Schema = _u.schemaConfig.CpUser
|
|
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{cpuser.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// CpUserUpdateOne is the builder for updating a single CpUser entity.
|
|
type CpUserUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *CpUserMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *CpUserUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CpUserUpdateOne {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *CpUserUpdateOne) SetUserID(v int64) *CpUserUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableUserID(v *int64) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_u *CpUserUpdateOne) SetUsername(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetUsername(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableUsername(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetUsername(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *CpUserUpdateOne) SetPassword(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillablePassword(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (_u *CpUserUpdateOne) SetSchoolID(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetSchoolID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSchoolID sets the "school_id" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableSchoolID(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetSchoolID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *CpUserUpdateOne) SetEmail(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableEmail(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (_u *CpUserUpdateOne) ClearEmail() *CpUserUpdateOne {
|
|
_u.mutation.ClearEmail()
|
|
return _u
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (_u *CpUserUpdateOne) SetMobileCode(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetMobileCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMobileCode sets the "mobile_code" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableMobileCode(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetMobileCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMobileCode clears the value of the "mobile_code" field.
|
|
func (_u *CpUserUpdateOne) ClearMobileCode() *CpUserUpdateOne {
|
|
_u.mutation.ClearMobileCode()
|
|
return _u
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (_u *CpUserUpdateOne) SetCookie(v string) *CpUserUpdateOne {
|
|
_u.mutation.SetCookie(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCookie sets the "cookie" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableCookie(v *string) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetCookie(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCookie clears the value of the "cookie" field.
|
|
func (_u *CpUserUpdateOne) ClearCookie() *CpUserUpdateOne {
|
|
_u.mutation.ClearCookie()
|
|
return _u
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (_u *CpUserUpdateOne) SetMobileType(v cpuser.MobileType) *CpUserUpdateOne {
|
|
_u.mutation.SetMobileType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMobileType sets the "mobile_type" field if the given value is not nil.
|
|
func (_u *CpUserUpdateOne) SetNillableMobileType(v *cpuser.MobileType) *CpUserUpdateOne {
|
|
if v != nil {
|
|
_u.SetMobileType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCptaskIDs adds the "cptasks" edge to the CpTask entity by IDs.
|
|
func (_u *CpUserUpdateOne) AddCptaskIDs(ids ...int64) *CpUserUpdateOne {
|
|
_u.mutation.AddCptaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddCptasks adds the "cptasks" edges to the CpTask entity.
|
|
func (_u *CpUserUpdateOne) AddCptasks(v ...*CpTask) *CpUserUpdateOne {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCptaskIDs(ids...)
|
|
}
|
|
|
|
// SetSysuserID sets the "sysuser" edge to the SysUser entity by ID.
|
|
func (_u *CpUserUpdateOne) SetSysuserID(id int64) *CpUserUpdateOne {
|
|
_u.mutation.SetSysuserID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetSysuser sets the "sysuser" edge to the SysUser entity.
|
|
func (_u *CpUserUpdateOne) SetSysuser(v *SysUser) *CpUserUpdateOne {
|
|
return _u.SetSysuserID(v.ID)
|
|
}
|
|
|
|
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
|
|
func (_u *CpUserUpdateOne) AddCpTaskLogIDs(ids ...int64) *CpUserUpdateOne {
|
|
_u.mutation.AddCpTaskLogIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddCpTaskLogs adds the "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_u *CpUserUpdateOne) AddCpTaskLogs(v ...*CpTaskLog) *CpUserUpdateOne {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// SetSchool sets the "school" edge to the CpSchool entity.
|
|
func (_u *CpUserUpdateOne) SetSchool(v *CpSchool) *CpUserUpdateOne {
|
|
return _u.SetSchoolID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the CpUserMutation object of the builder.
|
|
func (_u *CpUserUpdateOne) Mutation() *CpUserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCptasks clears all "cptasks" edges to the CpTask entity.
|
|
func (_u *CpUserUpdateOne) ClearCptasks() *CpUserUpdateOne {
|
|
_u.mutation.ClearCptasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCptaskIDs removes the "cptasks" edge to CpTask entities by IDs.
|
|
func (_u *CpUserUpdateOne) RemoveCptaskIDs(ids ...int64) *CpUserUpdateOne {
|
|
_u.mutation.RemoveCptaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveCptasks removes "cptasks" edges to CpTask entities.
|
|
func (_u *CpUserUpdateOne) RemoveCptasks(v ...*CpTask) *CpUserUpdateOne {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCptaskIDs(ids...)
|
|
}
|
|
|
|
// ClearSysuser clears the "sysuser" edge to the SysUser entity.
|
|
func (_u *CpUserUpdateOne) ClearSysuser() *CpUserUpdateOne {
|
|
_u.mutation.ClearSysuser()
|
|
return _u
|
|
}
|
|
|
|
// ClearCpTaskLogs clears all "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_u *CpUserUpdateOne) ClearCpTaskLogs() *CpUserUpdateOne {
|
|
_u.mutation.ClearCpTaskLogs()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCpTaskLogIDs removes the "cp_task_logs" edge to CpTaskLog entities by IDs.
|
|
func (_u *CpUserUpdateOne) RemoveCpTaskLogIDs(ids ...int64) *CpUserUpdateOne {
|
|
_u.mutation.RemoveCpTaskLogIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveCpTaskLogs removes "cp_task_logs" edges to CpTaskLog entities.
|
|
func (_u *CpUserUpdateOne) RemoveCpTaskLogs(v ...*CpTaskLog) *CpUserUpdateOne {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// ClearSchool clears the "school" edge to the CpSchool entity.
|
|
func (_u *CpUserUpdateOne) ClearSchool() *CpUserUpdateOne {
|
|
_u.mutation.ClearSchool()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the CpUserUpdate builder.
|
|
func (_u *CpUserUpdateOne) Where(ps ...predicate.CpUser) *CpUserUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *CpUserUpdateOne) Select(field string, fields ...string) *CpUserUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated CpUser entity.
|
|
func (_u *CpUserUpdateOne) Save(ctx context.Context) (*CpUser, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *CpUserUpdateOne) SaveX(ctx context.Context) *CpUser {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *CpUserUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *CpUserUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *CpUserUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Username(); ok {
|
|
if err := cpuser.UsernameValidator(v); err != nil {
|
|
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "CpUser.username": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Password(); ok {
|
|
if err := cpuser.PasswordValidator(v); err != nil {
|
|
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "CpUser.password": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SchoolID(); ok {
|
|
if err := cpuser.SchoolIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "school_id", err: fmt.Errorf(`ent: validator failed for field "CpUser.school_id": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MobileType(); ok {
|
|
if err := cpuser.MobileTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "mobile_type", err: fmt.Errorf(`ent: validator failed for field "CpUser.mobile_type": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.SysuserCleared() && len(_u.mutation.SysuserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpUser.sysuser"`)
|
|
}
|
|
if _u.mutation.SchoolCleared() && len(_u.mutation.SchoolIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpUser.school"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *CpUserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CpUserUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *CpUserUpdateOne) sqlSave(ctx context.Context) (_node *CpUser, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(cpuser.Table, cpuser.Columns, sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CpUser.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, cpuser.FieldID)
|
|
for _, f := range fields {
|
|
if !cpuser.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != cpuser.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Username(); ok {
|
|
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
_spec.SetField(cpuser.FieldPassword, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(cpuser.FieldEmail, field.TypeString, value)
|
|
}
|
|
if _u.mutation.EmailCleared() {
|
|
_spec.ClearField(cpuser.FieldEmail, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.MobileCode(); ok {
|
|
_spec.SetField(cpuser.FieldMobileCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MobileCodeCleared() {
|
|
_spec.ClearField(cpuser.FieldMobileCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Cookie(); ok {
|
|
_spec.SetField(cpuser.FieldCookie, field.TypeString, value)
|
|
}
|
|
if _u.mutation.CookieCleared() {
|
|
_spec.ClearField(cpuser.FieldCookie, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.MobileType(); ok {
|
|
_spec.SetField(cpuser.FieldMobileType, field.TypeEnum, value)
|
|
}
|
|
if _u.mutation.CptasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCptasksIDs(); len(nodes) > 0 && !_u.mutation.CptasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CptasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CptasksTable,
|
|
Columns: []string{cpuser.CptasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTask
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SysuserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SysuserTable,
|
|
Columns: []string{cpuser.SysuserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SysuserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SysuserTable,
|
|
Columns: []string{cpuser.SysuserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.CpTaskLogsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCpTaskLogsIDs(); len(nodes) > 0 && !_u.mutation.CpTaskLogsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpTaskLogsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpTaskLogsTable,
|
|
Columns: []string{cpuser.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SchoolCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SchoolTable,
|
|
Columns: []string{cpuser.SchoolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpschool.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SchoolIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cpuser.SchoolTable,
|
|
Columns: []string{cpuser.SchoolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpschool.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.Node.Schema = _u.schemaConfig.CpUser
|
|
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &CpUser{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{cpuser.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|