1265 lines
36 KiB
Go
1265 lines
36 KiB
Go
// ENT数据库文件,请勿编辑。
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"likedream-goframe/internal/ent/cpleave"
|
|
"likedream-goframe/internal/ent/cpschool"
|
|
"likedream-goframe/internal/ent/cptask"
|
|
"likedream-goframe/internal/ent/cptasklog"
|
|
"likedream-goframe/internal/ent/cpuser"
|
|
"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"
|
|
)
|
|
|
|
// CpUserCreate is the builder for creating a CpUser entity.
|
|
type CpUserCreate struct {
|
|
config
|
|
mutation *CpUserMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_c *CpUserCreate) SetCreateTime(v *ent2.CustomTime) *CpUserCreate {
|
|
_c.mutation.SetCreateTime(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_c *CpUserCreate) SetUpdateTime(v *ent2.CustomTime) *CpUserCreate {
|
|
_c.mutation.SetUpdateTime(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *CpUserCreate) SetUserID(v int64) *CpUserCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_c *CpUserCreate) SetUsername(v string) *CpUserCreate {
|
|
_c.mutation.SetUsername(v)
|
|
return _c
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_c *CpUserCreate) SetPassword(v string) *CpUserCreate {
|
|
_c.mutation.SetPassword(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_c *CpUserCreate) SetNillablePassword(v *string) *CpUserCreate {
|
|
if v != nil {
|
|
_c.SetPassword(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (_c *CpUserCreate) SetSchoolID(v string) *CpUserCreate {
|
|
_c.mutation.SetSchoolID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_c *CpUserCreate) SetEmail(v string) *CpUserCreate {
|
|
_c.mutation.SetEmail(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_c *CpUserCreate) SetNillableEmail(v *string) *CpUserCreate {
|
|
if v != nil {
|
|
_c.SetEmail(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (_c *CpUserCreate) SetMobileCode(v string) *CpUserCreate {
|
|
_c.mutation.SetMobileCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMobileCode sets the "mobile_code" field if the given value is not nil.
|
|
func (_c *CpUserCreate) SetNillableMobileCode(v *string) *CpUserCreate {
|
|
if v != nil {
|
|
_c.SetMobileCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (_c *CpUserCreate) SetCookie(v string) *CpUserCreate {
|
|
_c.mutation.SetCookie(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCookie sets the "cookie" field if the given value is not nil.
|
|
func (_c *CpUserCreate) SetNillableCookie(v *string) *CpUserCreate {
|
|
if v != nil {
|
|
_c.SetCookie(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (_c *CpUserCreate) SetMobileType(v cpuser.MobileType) *CpUserCreate {
|
|
_c.mutation.SetMobileType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetLoginType sets the "login_type" field.
|
|
func (_c *CpUserCreate) SetLoginType(v cpuser.LoginType) *CpUserCreate {
|
|
_c.mutation.SetLoginType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableLoginType sets the "login_type" field if the given value is not nil.
|
|
func (_c *CpUserCreate) SetNillableLoginType(v *cpuser.LoginType) *CpUserCreate {
|
|
if v != nil {
|
|
_c.SetLoginType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// AddCptaskIDs adds the "cptasks" edge to the CpTask entity by IDs.
|
|
func (_c *CpUserCreate) AddCptaskIDs(ids ...int64) *CpUserCreate {
|
|
_c.mutation.AddCptaskIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddCptasks adds the "cptasks" edges to the CpTask entity.
|
|
func (_c *CpUserCreate) AddCptasks(v ...*CpTask) *CpUserCreate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddCptaskIDs(ids...)
|
|
}
|
|
|
|
// AddCpLeaveIDs adds the "cp_leave" edge to the CpLeave entity by IDs.
|
|
func (_c *CpUserCreate) AddCpLeaveIDs(ids ...int64) *CpUserCreate {
|
|
_c.mutation.AddCpLeaveIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddCpLeave adds the "cp_leave" edges to the CpLeave entity.
|
|
func (_c *CpUserCreate) AddCpLeave(v ...*CpLeave) *CpUserCreate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddCpLeaveIDs(ids...)
|
|
}
|
|
|
|
// SetSysuserID sets the "sysuser" edge to the SysUser entity by ID.
|
|
func (_c *CpUserCreate) SetSysuserID(id int64) *CpUserCreate {
|
|
_c.mutation.SetSysuserID(id)
|
|
return _c
|
|
}
|
|
|
|
// SetSysuser sets the "sysuser" edge to the SysUser entity.
|
|
func (_c *CpUserCreate) SetSysuser(v *SysUser) *CpUserCreate {
|
|
return _c.SetSysuserID(v.ID)
|
|
}
|
|
|
|
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
|
|
func (_c *CpUserCreate) AddCpTaskLogIDs(ids ...int64) *CpUserCreate {
|
|
_c.mutation.AddCpTaskLogIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddCpTaskLogs adds the "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_c *CpUserCreate) AddCpTaskLogs(v ...*CpTaskLog) *CpUserCreate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// SetSchool sets the "school" edge to the CpSchool entity.
|
|
func (_c *CpUserCreate) SetSchool(v *CpSchool) *CpUserCreate {
|
|
return _c.SetSchoolID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the CpUserMutation object of the builder.
|
|
func (_c *CpUserCreate) Mutation() *CpUserMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the CpUser in the database.
|
|
func (_c *CpUserCreate) Save(ctx context.Context) (*CpUser, error) {
|
|
if err := _c.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *CpUserCreate) SaveX(ctx context.Context) *CpUser {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CpUserCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CpUserCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *CpUserCreate) defaults() error {
|
|
if _, ok := _c.mutation.CreateTime(); !ok {
|
|
if cpuser.DefaultCreateTime == nil {
|
|
return fmt.Errorf("ent: uninitialized cpuser.DefaultCreateTime (forgotten import ent/runtime?)")
|
|
}
|
|
v := cpuser.DefaultCreateTime()
|
|
_c.mutation.SetCreateTime(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdateTime(); !ok {
|
|
if cpuser.DefaultUpdateTime == nil {
|
|
return fmt.Errorf("ent: uninitialized cpuser.DefaultUpdateTime (forgotten import ent/runtime?)")
|
|
}
|
|
v := cpuser.DefaultUpdateTime()
|
|
_c.mutation.SetUpdateTime(v)
|
|
}
|
|
if _, ok := _c.mutation.LoginType(); !ok {
|
|
v := cpuser.DefaultLoginType
|
|
_c.mutation.SetLoginType(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *CpUserCreate) check() error {
|
|
if _, ok := _c.mutation.CreateTime(); !ok {
|
|
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CpUser.create_time"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdateTime(); !ok {
|
|
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CpUser.update_time"`)}
|
|
}
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "CpUser.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Username(); !ok {
|
|
return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "CpUser.username"`)}
|
|
}
|
|
if v, ok := _c.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 _, ok := _c.mutation.SchoolID(); !ok {
|
|
return &ValidationError{Name: "school_id", err: errors.New(`ent: missing required field "CpUser.school_id"`)}
|
|
}
|
|
if v, ok := _c.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 _, ok := _c.mutation.MobileType(); !ok {
|
|
return &ValidationError{Name: "mobile_type", err: errors.New(`ent: missing required field "CpUser.mobile_type"`)}
|
|
}
|
|
if v, ok := _c.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 _, ok := _c.mutation.LoginType(); !ok {
|
|
return &ValidationError{Name: "login_type", err: errors.New(`ent: missing required field "CpUser.login_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.LoginType(); ok {
|
|
if err := cpuser.LoginTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "login_type", err: fmt.Errorf(`ent: validator failed for field "CpUser.login_type": %w`, err)}
|
|
}
|
|
}
|
|
if len(_c.mutation.SysuserIDs()) == 0 {
|
|
return &ValidationError{Name: "sysuser", err: errors.New(`ent: missing required edge "CpUser.sysuser"`)}
|
|
}
|
|
if len(_c.mutation.SchoolIDs()) == 0 {
|
|
return &ValidationError{Name: "school", err: errors.New(`ent: missing required edge "CpUser.school"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *CpUserCreate) sqlSave(ctx context.Context) (*CpUser, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int64(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *CpUserCreate) createSpec() (*CpUser, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &CpUser{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(cpuser.Table, sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64))
|
|
)
|
|
_spec.Schema = _c.schemaConfig.CpUser
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.CreateTime(); ok {
|
|
_spec.SetField(cpuser.FieldCreateTime, field.TypeString, value)
|
|
_node.CreateTime = value
|
|
}
|
|
if value, ok := _c.mutation.UpdateTime(); ok {
|
|
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
|
_node.UpdateTime = value
|
|
}
|
|
if value, ok := _c.mutation.Username(); ok {
|
|
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
|
_node.Username = value
|
|
}
|
|
if value, ok := _c.mutation.Password(); ok {
|
|
_spec.SetField(cpuser.FieldPassword, field.TypeString, value)
|
|
_node.Password = value
|
|
}
|
|
if value, ok := _c.mutation.Email(); ok {
|
|
_spec.SetField(cpuser.FieldEmail, field.TypeString, value)
|
|
_node.Email = value
|
|
}
|
|
if value, ok := _c.mutation.MobileCode(); ok {
|
|
_spec.SetField(cpuser.FieldMobileCode, field.TypeString, value)
|
|
_node.MobileCode = value
|
|
}
|
|
if value, ok := _c.mutation.Cookie(); ok {
|
|
_spec.SetField(cpuser.FieldCookie, field.TypeString, value)
|
|
_node.Cookie = value
|
|
}
|
|
if value, ok := _c.mutation.MobileType(); ok {
|
|
_spec.SetField(cpuser.FieldMobileType, field.TypeEnum, value)
|
|
_node.MobileType = value
|
|
}
|
|
if value, ok := _c.mutation.LoginType(); ok {
|
|
_spec.SetField(cpuser.FieldLoginType, field.TypeEnum, value)
|
|
_node.LoginType = value
|
|
}
|
|
if nodes := _c.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 = _c.schemaConfig.CpTask
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.CpLeaveIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cpuser.CpLeaveTable,
|
|
Columns: []string{cpuser.CpLeaveColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpleave.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _c.schemaConfig.CpLeave
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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 = _c.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.UserID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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 = _c.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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 = _c.schemaConfig.CpUser
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.SchoolID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.CpUser.Create().
|
|
// SetCreateTime(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.CpUserUpsert) {
|
|
// SetCreateTime(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *CpUserCreate) OnConflict(opts ...sql.ConflictOption) *CpUserUpsertOne {
|
|
_c.conflict = opts
|
|
return &CpUserUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *CpUserCreate) OnConflictColumns(columns ...string) *CpUserUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &CpUserUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// CpUserUpsertOne is the builder for "upsert"-ing
|
|
// one CpUser node.
|
|
CpUserUpsertOne struct {
|
|
create *CpUserCreate
|
|
}
|
|
|
|
// CpUserUpsert is the "OnConflict" setter.
|
|
CpUserUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (u *CpUserUpsert) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsert {
|
|
u.Set(cpuser.FieldUpdateTime, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateUpdateTime() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldUpdateTime)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpUserUpsert) SetUserID(v int64) *CpUserUpsert {
|
|
u.Set(cpuser.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateUserID() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *CpUserUpsert) SetUsername(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldUsername, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateUsername() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldUsername)
|
|
return u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *CpUserUpsert) SetPassword(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldPassword, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdatePassword() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldPassword)
|
|
return u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *CpUserUpsert) ClearPassword() *CpUserUpsert {
|
|
u.SetNull(cpuser.FieldPassword)
|
|
return u
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (u *CpUserUpsert) SetSchoolID(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldSchoolID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSchoolID sets the "school_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateSchoolID() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldSchoolID)
|
|
return u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *CpUserUpsert) SetEmail(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldEmail, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateEmail() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *CpUserUpsert) ClearEmail() *CpUserUpsert {
|
|
u.SetNull(cpuser.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (u *CpUserUpsert) SetMobileCode(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldMobileCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMobileCode sets the "mobile_code" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateMobileCode() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldMobileCode)
|
|
return u
|
|
}
|
|
|
|
// ClearMobileCode clears the value of the "mobile_code" field.
|
|
func (u *CpUserUpsert) ClearMobileCode() *CpUserUpsert {
|
|
u.SetNull(cpuser.FieldMobileCode)
|
|
return u
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (u *CpUserUpsert) SetCookie(v string) *CpUserUpsert {
|
|
u.Set(cpuser.FieldCookie, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCookie sets the "cookie" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateCookie() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldCookie)
|
|
return u
|
|
}
|
|
|
|
// ClearCookie clears the value of the "cookie" field.
|
|
func (u *CpUserUpsert) ClearCookie() *CpUserUpsert {
|
|
u.SetNull(cpuser.FieldCookie)
|
|
return u
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (u *CpUserUpsert) SetMobileType(v cpuser.MobileType) *CpUserUpsert {
|
|
u.Set(cpuser.FieldMobileType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMobileType sets the "mobile_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateMobileType() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldMobileType)
|
|
return u
|
|
}
|
|
|
|
// SetLoginType sets the "login_type" field.
|
|
func (u *CpUserUpsert) SetLoginType(v cpuser.LoginType) *CpUserUpsert {
|
|
u.Set(cpuser.FieldLoginType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateLoginType sets the "login_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsert) UpdateLoginType() *CpUserUpsert {
|
|
u.SetExcluded(cpuser.FieldLoginType)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *CpUserUpsertOne) UpdateNewValues() *CpUserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
if _, exists := u.create.mutation.CreateTime(); exists {
|
|
s.SetIgnore(cpuser.FieldCreateTime)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *CpUserUpsertOne) Ignore() *CpUserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *CpUserUpsertOne) DoNothing() *CpUserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the CpUserCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *CpUserUpsertOne) Update(set func(*CpUserUpsert)) *CpUserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&CpUserUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (u *CpUserUpsertOne) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUpdateTime(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateUpdateTime() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUpdateTime()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpUserUpsertOne) SetUserID(v int64) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateUserID() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *CpUserUpsertOne) SetUsername(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUsername(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateUsername() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUsername()
|
|
})
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *CpUserUpsertOne) SetPassword(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetPassword(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdatePassword() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdatePassword()
|
|
})
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *CpUserUpsertOne) ClearPassword() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearPassword()
|
|
})
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (u *CpUserUpsertOne) SetSchoolID(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetSchoolID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSchoolID sets the "school_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateSchoolID() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateSchoolID()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *CpUserUpsertOne) SetEmail(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateEmail() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *CpUserUpsertOne) ClearEmail() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (u *CpUserUpsertOne) SetMobileCode(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetMobileCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMobileCode sets the "mobile_code" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateMobileCode() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateMobileCode()
|
|
})
|
|
}
|
|
|
|
// ClearMobileCode clears the value of the "mobile_code" field.
|
|
func (u *CpUserUpsertOne) ClearMobileCode() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearMobileCode()
|
|
})
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (u *CpUserUpsertOne) SetCookie(v string) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetCookie(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCookie sets the "cookie" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateCookie() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateCookie()
|
|
})
|
|
}
|
|
|
|
// ClearCookie clears the value of the "cookie" field.
|
|
func (u *CpUserUpsertOne) ClearCookie() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearCookie()
|
|
})
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (u *CpUserUpsertOne) SetMobileType(v cpuser.MobileType) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetMobileType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMobileType sets the "mobile_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateMobileType() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateMobileType()
|
|
})
|
|
}
|
|
|
|
// SetLoginType sets the "login_type" field.
|
|
func (u *CpUserUpsertOne) SetLoginType(v cpuser.LoginType) *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetLoginType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateLoginType sets the "login_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsertOne) UpdateLoginType() *CpUserUpsertOne {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateLoginType()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *CpUserUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for CpUserCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *CpUserUpsertOne) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
func (u *CpUserUpsertOne) ID(ctx context.Context) (id int64, err error) {
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *CpUserUpsertOne) IDX(ctx context.Context) int64 {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// CpUserCreateBulk is the builder for creating many CpUser entities in bulk.
|
|
type CpUserCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*CpUserCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the CpUser entities in the database.
|
|
func (_c *CpUserCreateBulk) Save(ctx context.Context) ([]*CpUser, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*CpUser, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*CpUserMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = _c.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int64(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *CpUserCreateBulk) SaveX(ctx context.Context) []*CpUser {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CpUserCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CpUserCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.CpUser.CreateBulk(builders...).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.CpUserUpsert) {
|
|
// SetCreateTime(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *CpUserCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpUserUpsertBulk {
|
|
_c.conflict = opts
|
|
return &CpUserUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *CpUserCreateBulk) OnConflictColumns(columns ...string) *CpUserUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &CpUserUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// CpUserUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of CpUser nodes.
|
|
type CpUserUpsertBulk struct {
|
|
create *CpUserCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *CpUserUpsertBulk) UpdateNewValues() *CpUserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
for _, b := range u.create.builders {
|
|
if _, exists := b.mutation.CreateTime(); exists {
|
|
s.SetIgnore(cpuser.FieldCreateTime)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpUser.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *CpUserUpsertBulk) Ignore() *CpUserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *CpUserUpsertBulk) DoNothing() *CpUserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the CpUserCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *CpUserUpsertBulk) Update(set func(*CpUserUpsert)) *CpUserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&CpUserUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (u *CpUserUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUpdateTime(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateUpdateTime() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUpdateTime()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpUserUpsertBulk) SetUserID(v int64) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateUserID() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *CpUserUpsertBulk) SetUsername(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetUsername(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateUsername() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateUsername()
|
|
})
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *CpUserUpsertBulk) SetPassword(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetPassword(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdatePassword() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdatePassword()
|
|
})
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *CpUserUpsertBulk) ClearPassword() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearPassword()
|
|
})
|
|
}
|
|
|
|
// SetSchoolID sets the "school_id" field.
|
|
func (u *CpUserUpsertBulk) SetSchoolID(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetSchoolID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSchoolID sets the "school_id" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateSchoolID() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateSchoolID()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *CpUserUpsertBulk) SetEmail(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateEmail() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *CpUserUpsertBulk) ClearEmail() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetMobileCode sets the "mobile_code" field.
|
|
func (u *CpUserUpsertBulk) SetMobileCode(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetMobileCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMobileCode sets the "mobile_code" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateMobileCode() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateMobileCode()
|
|
})
|
|
}
|
|
|
|
// ClearMobileCode clears the value of the "mobile_code" field.
|
|
func (u *CpUserUpsertBulk) ClearMobileCode() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearMobileCode()
|
|
})
|
|
}
|
|
|
|
// SetCookie sets the "cookie" field.
|
|
func (u *CpUserUpsertBulk) SetCookie(v string) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetCookie(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCookie sets the "cookie" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateCookie() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateCookie()
|
|
})
|
|
}
|
|
|
|
// ClearCookie clears the value of the "cookie" field.
|
|
func (u *CpUserUpsertBulk) ClearCookie() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.ClearCookie()
|
|
})
|
|
}
|
|
|
|
// SetMobileType sets the "mobile_type" field.
|
|
func (u *CpUserUpsertBulk) SetMobileType(v cpuser.MobileType) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetMobileType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMobileType sets the "mobile_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateMobileType() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateMobileType()
|
|
})
|
|
}
|
|
|
|
// SetLoginType sets the "login_type" field.
|
|
func (u *CpUserUpsertBulk) SetLoginType(v cpuser.LoginType) *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.SetLoginType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateLoginType sets the "login_type" field to the value that was provided on create.
|
|
func (u *CpUserUpsertBulk) UpdateLoginType() *CpUserUpsertBulk {
|
|
return u.Update(func(s *CpUserUpsert) {
|
|
s.UpdateLoginType()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *CpUserUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CpUserCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for CpUserCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *CpUserUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|