Files
MonkeyCode/backend/db/workspacefile_delete.go
Haoxin Li b5ecb92371 feat: feat: Implement workspace and real-time file synchronization
- Added WorkspaceFileHandler for handling workspace file operations including create, update, delete, and list functionalities.
- Introduced WorkspaceFileRepo for database interactions related to workspace files.
- Created WorkspaceFileUsecase to encapsulate business logic for workspace file management.
- Implemented API endpoints for workspace file operations with appropriate request and response structures.
- Added database migrations for creating workspaces and workspace_files tables with necessary constraints and indexes.
- Enhanced user authentication and authorization for workspace file operations.
2025-07-23 17:42:20 +08:00

89 lines
2.4 KiB
Go

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