12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "wechat-api/ent/employee"
- "wechat-api/ent/predicate"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // EmployeeDelete is the builder for deleting a Employee entity.
- type EmployeeDelete struct {
- config
- hooks []Hook
- mutation *EmployeeMutation
- }
- // Where appends a list predicates to the EmployeeDelete builder.
- func (ed *EmployeeDelete) Where(ps ...predicate.Employee) *EmployeeDelete {
- ed.mutation.Where(ps...)
- return ed
- }
- // Exec executes the deletion query and returns how many vertices were deleted.
- func (ed *EmployeeDelete) Exec(ctx context.Context) (int, error) {
- return withHooks(ctx, ed.sqlExec, ed.mutation, ed.hooks)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ed *EmployeeDelete) ExecX(ctx context.Context) int {
- n, err := ed.Exec(ctx)
- if err != nil {
- panic(err)
- }
- return n
- }
- func (ed *EmployeeDelete) sqlExec(ctx context.Context) (int, error) {
- _spec := sqlgraph.NewDeleteSpec(employee.Table, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64))
- if ps := ed.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- affected, err := sqlgraph.DeleteNodes(ctx, ed.driver, _spec)
- if err != nil && sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- ed.mutation.done = true
- return affected, err
- }
- // EmployeeDeleteOne is the builder for deleting a single Employee entity.
- type EmployeeDeleteOne struct {
- ed *EmployeeDelete
- }
- // Where appends a list predicates to the EmployeeDelete builder.
- func (edo *EmployeeDeleteOne) Where(ps ...predicate.Employee) *EmployeeDeleteOne {
- edo.ed.mutation.Where(ps...)
- return edo
- }
- // Exec executes the deletion query.
- func (edo *EmployeeDeleteOne) Exec(ctx context.Context) error {
- n, err := edo.ed.Exec(ctx)
- switch {
- case err != nil:
- return err
- case n == 0:
- return &NotFoundError{employee.Label}
- default:
- return nil
- }
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (edo *EmployeeDeleteOne) ExecX(ctx context.Context) {
- if err := edo.Exec(ctx); err != nil {
- panic(err)
- }
- }
|