mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-23 21:19:31 -06:00
Add executions service with CRUD operations
This commit is contained in:
13
internal/service/executions/create_execution.go
Normal file
13
internal/service/executions/create_execution.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package executions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
)
|
||||
|
||||
func (s *Service) CreateExecution(
|
||||
ctx context.Context, params dbgen.ExecutionsServiceCreateExecutionParams,
|
||||
) (dbgen.Execution, error) {
|
||||
return s.dbgen.ExecutionsServiceCreateExecution(ctx, params)
|
||||
}
|
||||
4
internal/service/executions/create_execution.sql
Normal file
4
internal/service/executions/create_execution.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- name: ExecutionsServiceCreateExecution :one
|
||||
INSERT INTO executions (status, message, path)
|
||||
VALUES (@status, @message, @path)
|
||||
RETURNING *;
|
||||
13
internal/service/executions/delete_execution.go
Normal file
13
internal/service/executions/delete_execution.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package executions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (s *Service) DeleteExecution(
|
||||
ctx context.Context, id uuid.UUID,
|
||||
) error {
|
||||
return s.dbgen.ExecutionsServiceDeleteExecution(ctx, id)
|
||||
}
|
||||
3
internal/service/executions/delete_execution.sql
Normal file
3
internal/service/executions/delete_execution.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- name: ExecutionsServiceDeleteExecution :exec
|
||||
DELETE FROM executions
|
||||
WHERE id = @id;
|
||||
13
internal/service/executions/executions.go
Normal file
13
internal/service/executions/executions.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package executions
|
||||
|
||||
import "github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
|
||||
type Service struct {
|
||||
dbgen *dbgen.Queries
|
||||
}
|
||||
|
||||
func New(dbgen *dbgen.Queries) *Service {
|
||||
return &Service{
|
||||
dbgen: dbgen,
|
||||
}
|
||||
}
|
||||
14
internal/service/executions/get_execution.go
Normal file
14
internal/service/executions/get_execution.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package executions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (s *Service) GetExecution(
|
||||
ctx context.Context, id uuid.UUID,
|
||||
) (dbgen.Execution, error) {
|
||||
return s.dbgen.ExecutionsServiceGetExecution(ctx, id)
|
||||
}
|
||||
3
internal/service/executions/get_execution.sql
Normal file
3
internal/service/executions/get_execution.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- name: ExecutionsServiceGetExecution :one
|
||||
SELECT * FROM executions
|
||||
WHERE id = @id;
|
||||
13
internal/service/executions/list_executions.go
Normal file
13
internal/service/executions/list_executions.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package executions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
)
|
||||
|
||||
func (s *Service) ListExecutions(
|
||||
ctx context.Context,
|
||||
) ([]dbgen.Execution, error) {
|
||||
return s.dbgen.ExecutionsServiceListExecutions(ctx)
|
||||
}
|
||||
2
internal/service/executions/list_executions.sql
Normal file
2
internal/service/executions/list_executions.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- name: ExecutionsServiceListExecutions :many
|
||||
SELECT * FROM executions;
|
||||
13
internal/service/executions/update_execution.go
Normal file
13
internal/service/executions/update_execution.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package executions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
)
|
||||
|
||||
func (s *Service) UpdateExecution(
|
||||
ctx context.Context, params dbgen.ExecutionsServiceUpdateExecutionParams,
|
||||
) (dbgen.Execution, error) {
|
||||
return s.dbgen.ExecutionsServiceUpdateExecution(ctx, params)
|
||||
}
|
||||
10
internal/service/executions/update_execution.sql
Normal file
10
internal/service/executions/update_execution.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- name: ExecutionsServiceUpdateExecution :one
|
||||
UPDATE executions
|
||||
SET
|
||||
status = @status,
|
||||
message = @message,
|
||||
path = @path,
|
||||
finished_at = @finished_at,
|
||||
deleted_at = @deleted_at
|
||||
WHERE id = @id
|
||||
RETURNING *;
|
||||
Reference in New Issue
Block a user