13
pkg/probo/coredata/control.go
Normal file
13
pkg/probo/coredata/control.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package coredata
|
||||
|
||||
import "time"
|
||||
|
||||
type (
|
||||
Control struct {
|
||||
ID string
|
||||
FrameworkID string
|
||||
ContentID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
)
|
||||
13
pkg/probo/coredata/evidence.go
Normal file
13
pkg/probo/coredata/evidence.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package coredata
|
||||
|
||||
import "time"
|
||||
|
||||
type (
|
||||
Evidence struct {
|
||||
ID string
|
||||
TaskID string
|
||||
ContentID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
)
|
||||
60
pkg/probo/coredata/framework.go
Normal file
60
pkg/probo/coredata/framework.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type (
|
||||
Framework struct {
|
||||
ID string
|
||||
OrganizationID string
|
||||
ContentID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
)
|
||||
|
||||
func (f *Framework) scan(r pgx.Row) error {
|
||||
return r.Scan(
|
||||
&f.ID,
|
||||
&f.OrganizationID,
|
||||
&f.ContentID,
|
||||
&f.CreatedAt,
|
||||
&f.UpdatedAt,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *Framework) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
frameworkID string,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
framework_id,
|
||||
organization_id,
|
||||
content_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
frameworks
|
||||
WHERE
|
||||
framework_id = @framework_id
|
||||
LIMIT 1;
|
||||
`
|
||||
args := pgx.NamedArgs{"framework_id": frameworkID}
|
||||
r := conn.QueryRow(ctx, q, args)
|
||||
|
||||
f2 := Framework{}
|
||||
if err := r.Scan(&f2); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*f = f2
|
||||
|
||||
return nil
|
||||
}
|
||||
58
pkg/probo/coredata/organization.go
Normal file
58
pkg/probo/coredata/organization.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type (
|
||||
Organization struct {
|
||||
ID string
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
)
|
||||
|
||||
func (o *Organization) scan(r pgx.Row) error {
|
||||
return r.Scan(
|
||||
&o.ID,
|
||||
&o.Name,
|
||||
&o.CreatedAt,
|
||||
&o.UpdatedAt,
|
||||
)
|
||||
}
|
||||
|
||||
func (o *Organization) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
organizationID string,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
organization_id,
|
||||
name,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
organizations
|
||||
WHERE
|
||||
organization_id = @organization_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
args := pgx.NamedArgs{"organization_id": organizationID}
|
||||
r := conn.QueryRow(ctx, q, args)
|
||||
|
||||
o2 := Organization{}
|
||||
if err := r.Scan(&o2); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = o2
|
||||
|
||||
return nil
|
||||
}
|
||||
12
pkg/probo/coredata/task.go
Normal file
12
pkg/probo/coredata/task.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package coredata
|
||||
|
||||
import "time"
|
||||
|
||||
type (
|
||||
Task struct {
|
||||
ID string
|
||||
ContentID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user