Use dedicated type for each order field
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -55,10 +55,15 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c Control) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (c Control) CursorKey(orderBy ControlOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case ControlOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(c.ID, c.CreatedAt)
|
return page.NewCursorKey(c.ID, c.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Control) LoadByID(
|
func (c *Control) LoadByID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
@@ -170,7 +175,7 @@ func (c *Controls) LoadByFrameworkID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
frameworkID gid.GID,
|
frameworkID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[ControlOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
40
pkg/coredata/control_order_field.go
Normal file
40
pkg/coredata/control_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
ControlOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ControlOrderFieldCreatedAt ControlOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p ControlOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ControlOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ControlOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ControlOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = ControlOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -42,10 +42,15 @@ type (
|
|||||||
Evidences []*Evidence
|
Evidences []*Evidence
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e Evidence) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (e Evidence) CursorKey(orderBy EvidenceOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case EvidenceOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(e.ID, e.CreatedAt)
|
return page.NewCursorKey(e.ID, e.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (e Evidence) Insert(
|
func (e Evidence) Insert(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
@@ -145,7 +150,7 @@ func (e *Evidences) LoadByTaskID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
taskID gid.GID,
|
taskID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[EvidenceOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
40
pkg/coredata/evidence_order_field.go
Normal file
40
pkg/coredata/evidence_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
EvidenceOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
EvidenceOrderFieldCreatedAt EvidenceOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p EvidenceOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p EvidenceOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p EvidenceOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *EvidenceOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = EvidenceOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -47,16 +47,21 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f Framework) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (f Framework) CursorKey(orderBy FrameworkOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case FrameworkOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(f.ID, f.CreatedAt)
|
return page.NewCursorKey(f.ID, f.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Frameworks) LoadByOrganizationID(
|
func (f *Frameworks) LoadByOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[FrameworkOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
40
pkg/coredata/framework_order_field.go
Normal file
40
pkg/coredata/framework_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
FrameworkOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FrameworkOrderFieldCreatedAt FrameworkOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p FrameworkOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p FrameworkOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p FrameworkOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *FrameworkOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = FrameworkOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -39,10 +39,15 @@ type (
|
|||||||
Organizations []*Organization
|
Organizations []*Organization
|
||||||
)
|
)
|
||||||
|
|
||||||
func (o Organization) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (o Organization) CursorKey(orderBy OrganizationOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case OrganizationOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(o.ID, o.CreatedAt)
|
return page.NewCursorKey(o.ID, o.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (o *Organization) LoadByID(
|
func (o *Organization) LoadByID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
|
|||||||
40
pkg/coredata/organization_order_field.go
Normal file
40
pkg/coredata/organization_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
OrganizationOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
OrganizationOrderFieldCreatedAt OrganizationOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p OrganizationOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p OrganizationOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p OrganizationOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *OrganizationOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = OrganizationOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -50,8 +50,15 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p People) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (p People) CursorKey(orderBy PeopleOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case PeopleOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(p.ID, p.CreatedAt)
|
return page.NewCursorKey(p.ID, p.CreatedAt)
|
||||||
|
case PeopleOrderFieldFullName:
|
||||||
|
return page.NewCursorKey(p.ID, p.FullName)
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *People) LoadByID(
|
func (p *People) LoadByID(
|
||||||
@@ -171,8 +178,9 @@ func (p *Peoples) LoadByOrganizationID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[PeopleOrderField],
|
||||||
) error {
|
) error {
|
||||||
|
// Base query
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
|||||||
41
pkg/coredata/people_order_field.go
Normal file
41
pkg/coredata/people_order_field.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
PeopleOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PeopleOrderFieldCreatedAt PeopleOrderField = "CREATED_AT"
|
||||||
|
PeopleOrderFieldFullName PeopleOrderField = "FULL_NAME"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p PeopleOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PeopleOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PeopleOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PeopleOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = PeopleOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -38,8 +38,15 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p Policy) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (p Policy) CursorKey(orderBy PolicyOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case PolicyOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(p.ID, p.CreatedAt)
|
return page.NewCursorKey(p.ID, p.CreatedAt)
|
||||||
|
case PolicyOrderFieldName:
|
||||||
|
return page.NewCursorKey(p.ID, p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Policy) LoadByID(
|
func (p *Policy) LoadByID(
|
||||||
@@ -93,7 +100,7 @@ func (p *Policies) LoadByOrganizationID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[PolicyOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
41
pkg/coredata/policy_order_field.go
Normal file
41
pkg/coredata/policy_order_field.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
PolicyOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PolicyOrderFieldCreatedAt PolicyOrderField = "CREATED_AT"
|
||||||
|
PolicyOrderFieldName PolicyOrderField = "NAME"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p PolicyOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PolicyOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PolicyOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PolicyOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = PolicyOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -38,10 +38,15 @@ type (
|
|||||||
SessionData struct{}
|
SessionData struct{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s Session) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (s Session) CursorKey(orderBy SessionOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case SessionOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(s.ID, s.CreatedAt)
|
return page.NewCursorKey(s.ID, s.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) LoadByID(
|
func (s *Session) LoadByID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
|
|||||||
40
pkg/coredata/session_order_field.go
Normal file
40
pkg/coredata/session_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
SessionOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SessionOrderFieldCreatedAt SessionOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p SessionOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p SessionOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p SessionOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *SessionOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = SessionOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -53,10 +53,15 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t Task) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (t Task) CursorKey(orderBy TaskOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case TaskOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(t.ID, t.CreatedAt)
|
return page.NewCursorKey(t.ID, t.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Task) LoadByID(
|
func (t *Task) LoadByID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
@@ -163,7 +168,7 @@ func (t *Tasks) LoadByControlID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
controlID gid.GID,
|
controlID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[TaskOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
40
pkg/coredata/task_order_field.go
Normal file
40
pkg/coredata/task_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
TaskOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TaskOrderFieldCreatedAt TaskOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p TaskOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p TaskOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p TaskOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *TaskOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = TaskOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -59,15 +59,20 @@ func (e ErrUserAlreadyExists) Error() string {
|
|||||||
return e.message
|
return e.message
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (u User) CursorKey(orderBy UserOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case UserOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(u.ID, u.CreatedAt)
|
return page.NewCursorKey(u.ID, u.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
|
}
|
||||||
|
|
||||||
func (u *Users) LoadByOrganizationID(
|
func (u *Users) LoadByOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[UserOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
40
pkg/coredata/user_order_field.go
Normal file
40
pkg/coredata/user_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
UserOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserOrderFieldCreatedAt UserOrderField = "CREATED_AT"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p UserOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p UserOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p UserOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *UserOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = UserOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -63,17 +63,15 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v Vendor) CursorKey(orderBy page.OrderField) page.CursorKey {
|
func (v Vendor) CursorKey(orderBy VendorOrderField) page.CursorKey {
|
||||||
switch orderBy {
|
switch orderBy {
|
||||||
case page.OrderFieldCreatedAt:
|
case VendorOrderFieldCreatedAt:
|
||||||
return page.NewCursorKey(v.ID, v.CreatedAt)
|
return page.NewCursorKey(v.ID, v.CreatedAt)
|
||||||
case page.OrderFieldUpdatedAt:
|
case VendorOrderFieldName:
|
||||||
return page.NewCursorKey(v.ID, v.UpdatedAt)
|
|
||||||
case page.OrderFieldName:
|
|
||||||
return page.NewCursorKey(v.ID, v.Name)
|
return page.NewCursorKey(v.ID, v.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Sprintf("unknown order by: %s", orderBy))
|
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Vendor) LoadByID(
|
func (v *Vendor) LoadByID(
|
||||||
@@ -213,7 +211,7 @@ func (v *Vendors) LoadByOrganizationID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[VendorOrderField],
|
||||||
) error {
|
) error {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
41
pkg/coredata/vendor_order_field.go
Normal file
41
pkg/coredata/vendor_order_field.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
VendorOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VendorOrderFieldCreatedAt VendorOrderField = "CREATED_AT"
|
||||||
|
VendorOrderFieldName VendorOrderField = "NAME"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p VendorOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p VendorOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p VendorOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *VendorOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = VendorOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -19,17 +19,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Cursor struct {
|
Cursor[T OrderField] struct {
|
||||||
Size int
|
Size int
|
||||||
Position Position
|
Position Position
|
||||||
Key *CursorKey
|
Key *CursorKey
|
||||||
OrderBy OrderBy
|
OrderBy OrderBy[T]
|
||||||
}
|
}
|
||||||
|
|
||||||
Position string
|
Position string
|
||||||
|
|
||||||
OrderBy struct {
|
OrderBy[T OrderField] struct {
|
||||||
Field OrderField
|
Field T
|
||||||
Direction OrderDirection
|
Direction OrderDirection
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -41,27 +41,20 @@ const (
|
|||||||
Head Position = "HEAD"
|
Head Position = "HEAD"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCursor(size int, from *CursorKey, pos Position, orderBy *OrderBy) *Cursor {
|
func NewCursor[T OrderField](size int, from *CursorKey, pos Position, orderBy OrderBy[T]) *Cursor[T] {
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
size = DefaultCursorSize
|
size = DefaultCursorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
if orderBy == nil {
|
return &Cursor[T]{
|
||||||
orderBy = &OrderBy{
|
|
||||||
Field: OrderFieldCreatedAt,
|
|
||||||
Direction: OrderDirectionDesc,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Cursor{
|
|
||||||
Size: size,
|
Size: size,
|
||||||
Key: from,
|
Key: from,
|
||||||
Position: pos,
|
Position: pos,
|
||||||
OrderBy: *orderBy,
|
OrderBy: orderBy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cursor) SQLFragment() string {
|
func (c *Cursor[T]) SQLFragment() string {
|
||||||
fieldName := c.OrderBy.Field.Column()
|
fieldName := c.OrderBy.Field.Column()
|
||||||
|
|
||||||
var orderDirection string
|
var orderDirection string
|
||||||
@@ -88,7 +81,7 @@ func (c *Cursor) SQLFragment() string {
|
|||||||
return whereClause + " ORDER BY " + orderByClause + " LIMIT @cursor_limit"
|
return whereClause + " ORDER BY " + orderByClause + " LIMIT @cursor_limit"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cursor) SQLArguments() pgx.NamedArgs {
|
func (c *Cursor[T]) SQLArguments() pgx.NamedArgs {
|
||||||
var size = c.Size
|
var size = c.Size
|
||||||
if c.Key == nil {
|
if c.Key == nil {
|
||||||
size += 1
|
size += 1
|
||||||
|
|||||||
@@ -21,51 +21,6 @@ import (
|
|||||||
type (
|
type (
|
||||||
OrderField interface {
|
OrderField interface {
|
||||||
Column() string
|
Column() string
|
||||||
|
fmt.Stringer
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericOrderField string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
OrderFieldCreatedAt GenericOrderField = "CREATED_AT"
|
|
||||||
OrderFieldUpdatedAt GenericOrderField = "UPDATED_AT"
|
|
||||||
OrderFieldName GenericOrderField = "NAME"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (of GenericOrderField) String() string {
|
|
||||||
return string(of)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (of GenericOrderField) Column() string {
|
|
||||||
switch of {
|
|
||||||
case OrderFieldCreatedAt:
|
|
||||||
return "created_at"
|
|
||||||
case OrderFieldUpdatedAt:
|
|
||||||
return "updated_at"
|
|
||||||
case OrderFieldName:
|
|
||||||
return "name"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (of GenericOrderField) MarshalText() ([]byte, error) {
|
|
||||||
return []byte(of.String()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (of *GenericOrderField) UnmarshalText(data []byte) error {
|
|
||||||
val := string(data)
|
|
||||||
|
|
||||||
switch val {
|
|
||||||
case OrderFieldCreatedAt.String():
|
|
||||||
*of = OrderFieldCreatedAt
|
|
||||||
case OrderFieldUpdatedAt.String():
|
|
||||||
*of = OrderFieldUpdatedAt
|
|
||||||
case OrderFieldName.String():
|
|
||||||
*of = OrderFieldName
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid GenericOrderField value: %q", val)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
package page
|
package page
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Paginable interface {
|
Paginable[T OrderField] interface {
|
||||||
CursorKey(orderBy OrderField) CursorKey
|
CursorKey(orderBy T) CursorKey
|
||||||
}
|
}
|
||||||
|
|
||||||
PageInfo struct {
|
PageInfo struct {
|
||||||
@@ -24,14 +24,14 @@ type (
|
|||||||
HasPrev bool
|
HasPrev bool
|
||||||
}
|
}
|
||||||
|
|
||||||
Page[T Paginable] struct {
|
Page[T Paginable[U], U OrderField] struct {
|
||||||
Info *PageInfo
|
Info *PageInfo
|
||||||
Cursor *Cursor
|
Cursor *Cursor[U]
|
||||||
Data []T
|
Data []T
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Page[T]) First() T {
|
func (p *Page[T, U]) First() T {
|
||||||
if len(p.Data) == 0 {
|
if len(p.Data) == 0 {
|
||||||
var zero T
|
var zero T
|
||||||
return zero
|
return zero
|
||||||
@@ -40,7 +40,7 @@ func (p *Page[T]) First() T {
|
|||||||
return p.Data[0]
|
return p.Data[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page[T]) Last() T {
|
func (p *Page[T, U]) Last() T {
|
||||||
if len(p.Data) == 0 {
|
if len(p.Data) == 0 {
|
||||||
var zero T
|
var zero T
|
||||||
return zero
|
return zero
|
||||||
@@ -49,11 +49,11 @@ func (p *Page[T]) Last() T {
|
|||||||
return p.Data[len(p.Data)-1]
|
return p.Data[len(p.Data)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPage[T Paginable](data []T, c *Cursor) *Page[T] {
|
func NewPage[T Paginable[U], U OrderField](data []T, c *Cursor[U]) *Page[T, U] {
|
||||||
pi := &PageInfo{}
|
pi := &PageInfo{}
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return &Page[T]{
|
return &Page[T, U]{
|
||||||
Info: pi,
|
Info: pi,
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ func NewPage[T Paginable](data []T, c *Cursor) *Page[T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Page[T]{
|
return &Page[T, U]{
|
||||||
Info: pi,
|
Info: pi,
|
||||||
Cursor: c,
|
Cursor: c,
|
||||||
Data: edges,
|
Data: edges,
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ func (s ControlService) Update(
|
|||||||
func (s ControlService) ListForFrameworkID(
|
func (s ControlService) ListForFrameworkID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
frameworkID gid.GID,
|
frameworkID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.ControlOrderField],
|
||||||
) (*page.Page[*coredata.Control], error) {
|
) (*page.Page[*coredata.Control, coredata.ControlOrderField], error) {
|
||||||
var controls coredata.Controls
|
var controls coredata.Controls
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ func (s EvidenceService) GenerateFileURL(
|
|||||||
func (s EvidenceService) ListForTaskID(
|
func (s EvidenceService) ListForTaskID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
taskID gid.GID,
|
taskID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.EvidenceOrderField],
|
||||||
) (*page.Page[*coredata.Evidence], error) {
|
) (*page.Page[*coredata.Evidence, coredata.EvidenceOrderField], error) {
|
||||||
var evidences coredata.Evidences
|
var evidences coredata.Evidences
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ func (s FrameworkService) Create(
|
|||||||
func (s FrameworkService) ListForOrganizationID(
|
func (s FrameworkService) ListForOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.FrameworkOrderField],
|
||||||
) (*page.Page[*coredata.Framework], error) {
|
) (*page.Page[*coredata.Framework, coredata.FrameworkOrderField], error) {
|
||||||
var frameworks coredata.Frameworks
|
var frameworks coredata.Frameworks
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ func (s PeopleService) Get(
|
|||||||
func (s PeopleService) ListForOrganizationID(
|
func (s PeopleService) ListForOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.PeopleOrderField],
|
||||||
) (*page.Page[*coredata.People], error) {
|
) (*page.Page[*coredata.People, coredata.PeopleOrderField], error) {
|
||||||
var peoples coredata.Peoples
|
var peoples coredata.Peoples
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ func (s *PolicyService) Delete(
|
|||||||
func (s *PolicyService) ListByOrganizationID(
|
func (s *PolicyService) ListByOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.PolicyOrderField],
|
||||||
) (*page.Page[*coredata.Policy], error) {
|
) (*page.Page[*coredata.Policy, coredata.PolicyOrderField], error) {
|
||||||
var policies coredata.Policies
|
var policies coredata.Policies
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ func (s TaskService) Update(
|
|||||||
func (s TaskService) ListForControlID(
|
func (s TaskService) ListForControlID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
controlID gid.GID,
|
controlID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.TaskOrderField],
|
||||||
) (*page.Page[*coredata.Task], error) {
|
) (*page.Page[*coredata.Task, coredata.TaskOrderField], error) {
|
||||||
var tasks coredata.Tasks
|
var tasks coredata.Tasks
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ type (
|
|||||||
func (s VendorService) ListForOrganizationID(
|
func (s VendorService) ListForOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.VendorOrderField],
|
||||||
) (*page.Page[*coredata.Vendor], error) {
|
) (*page.Page[*coredata.Vendor, coredata.VendorOrderField], error) {
|
||||||
var vendors coredata.Vendors
|
var vendors coredata.Vendors
|
||||||
|
|
||||||
err := s.svc.pg.WithConn(
|
err := s.svc.pg.WithConn(
|
||||||
|
|||||||
@@ -511,8 +511,8 @@ func (s Service) ConfirmEmail(ctx context.Context, tokenString string) error {
|
|||||||
func (s Service) ListUsersForTenant(
|
func (s Service) ListUsersForTenant(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
cursor *page.Cursor,
|
cursor *page.Cursor[coredata.UserOrderField],
|
||||||
) (*page.Page[*coredata.User], error) {
|
) (*page.Page[*coredata.User, coredata.UserOrderField], error) {
|
||||||
users := coredata.Users{}
|
users := coredata.Users{}
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
err := s.pg.WithConn(
|
||||||
|
|||||||
Reference in New Issue
Block a user