mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-09 02:03:26 +08:00
- 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.
176 lines
6.2 KiB
Go
176 lines
6.2 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package workspacefile
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the workspacefile type in the database.
|
|
Label = "workspace_file"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldUserID holds the string denoting the user_id field in the database.
|
|
FieldUserID = "user_id"
|
|
// FieldWorkspaceID holds the string denoting the workspace_id field in the database.
|
|
FieldWorkspaceID = "workspace_id"
|
|
// FieldPath holds the string denoting the path field in the database.
|
|
FieldPath = "path"
|
|
// FieldContent holds the string denoting the content field in the database.
|
|
FieldContent = "content"
|
|
// FieldHash holds the string denoting the hash field in the database.
|
|
FieldHash = "hash"
|
|
// FieldLanguage holds the string denoting the language field in the database.
|
|
FieldLanguage = "language"
|
|
// FieldSize holds the string denoting the size field in the database.
|
|
FieldSize = "size"
|
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
|
FieldCreatedAt = "created_at"
|
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
|
FieldUpdatedAt = "updated_at"
|
|
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
|
EdgeOwner = "owner"
|
|
// EdgeWorkspace holds the string denoting the workspace edge name in mutations.
|
|
EdgeWorkspace = "workspace"
|
|
// Table holds the table name of the workspacefile in the database.
|
|
Table = "workspace_files"
|
|
// OwnerTable is the table that holds the owner relation/edge.
|
|
OwnerTable = "workspace_files"
|
|
// OwnerInverseTable is the table name for the User entity.
|
|
// It exists in this package in order to avoid circular dependency with the "user" package.
|
|
OwnerInverseTable = "users"
|
|
// OwnerColumn is the table column denoting the owner relation/edge.
|
|
OwnerColumn = "user_id"
|
|
// WorkspaceTable is the table that holds the workspace relation/edge.
|
|
WorkspaceTable = "workspace_files"
|
|
// WorkspaceInverseTable is the table name for the Workspace entity.
|
|
// It exists in this package in order to avoid circular dependency with the "workspace" package.
|
|
WorkspaceInverseTable = "workspaces"
|
|
// WorkspaceColumn is the table column denoting the workspace relation/edge.
|
|
WorkspaceColumn = "workspace_id"
|
|
)
|
|
|
|
// Columns holds all SQL columns for workspacefile fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldUserID,
|
|
FieldWorkspaceID,
|
|
FieldPath,
|
|
FieldContent,
|
|
FieldHash,
|
|
FieldLanguage,
|
|
FieldSize,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
}
|
|
|
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
|
func ValidColumn(column string) bool {
|
|
for i := range Columns {
|
|
if column == Columns[i] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var (
|
|
// PathValidator is a validator for the "path" field. It is called by the builders before save.
|
|
PathValidator func(string) error
|
|
// HashValidator is a validator for the "hash" field. It is called by the builders before save.
|
|
HashValidator func(string) error
|
|
// DefaultSize holds the default value on creation for the "size" field.
|
|
DefaultSize int64
|
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
|
DefaultCreatedAt func() time.Time
|
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
|
DefaultUpdatedAt func() time.Time
|
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
|
UpdateDefaultUpdatedAt func() time.Time
|
|
)
|
|
|
|
// OrderOption defines the ordering options for the WorkspaceFile queries.
|
|
type OrderOption func(*sql.Selector)
|
|
|
|
// ByID orders the results by the id field.
|
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUserID orders the results by the user_id field.
|
|
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUserID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByWorkspaceID orders the results by the workspace_id field.
|
|
func ByWorkspaceID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldWorkspaceID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPath orders the results by the path field.
|
|
func ByPath(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPath, opts...).ToFunc()
|
|
}
|
|
|
|
// ByContent orders the results by the content field.
|
|
func ByContent(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldContent, opts...).ToFunc()
|
|
}
|
|
|
|
// ByHash orders the results by the hash field.
|
|
func ByHash(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldHash, opts...).ToFunc()
|
|
}
|
|
|
|
// ByLanguage orders the results by the language field.
|
|
func ByLanguage(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldLanguage, opts...).ToFunc()
|
|
}
|
|
|
|
// BySize orders the results by the size field.
|
|
func BySize(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldSize, opts...).ToFunc()
|
|
}
|
|
|
|
// ByCreatedAt orders the results by the created_at field.
|
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUpdatedAt orders the results by the updated_at field.
|
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByOwnerField orders the results by owner field.
|
|
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
|
|
}
|
|
}
|
|
|
|
// ByWorkspaceField orders the results by workspace field.
|
|
func ByWorkspaceField(field string, opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newWorkspaceStep(), sql.OrderByField(field, opts...))
|
|
}
|
|
}
|
|
func newOwnerStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(OwnerInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
|
)
|
|
}
|
|
func newWorkspaceStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(WorkspaceInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, WorkspaceTable, WorkspaceColumn),
|
|
)
|
|
}
|