|
| 1 | +// Copyright (c) 2025 Probo Inc <hello@getprobo.com>. |
| 2 | +// |
| 3 | +// Permission to use, copy, modify, and/or distribute this software for any |
| 4 | +// purpose with or without fee is hereby granted, provided that the above |
| 5 | +// copyright notice and this permission notice appear in all copies. |
| 6 | +// |
| 7 | +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 8 | +// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 9 | +// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 10 | +// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 11 | +// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 12 | +// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 13 | +// PERFORMANCE OF THIS SOFTWARE. |
| 14 | + |
| 15 | +package probo |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + |
| 20 | + "github.com/getprobo/probo/pkg/gid" |
| 21 | + "github.com/getprobo/probo/pkg/page" |
| 22 | + "github.com/getprobo/probo/pkg/probo/coredata" |
| 23 | + "go.gearno.de/kit/pg" |
| 24 | +) |
| 25 | + |
| 26 | +func (s Service) ListControlStateTransitions( |
| 27 | + ctx context.Context, |
| 28 | + controlID gid.GID, |
| 29 | + cursor *page.Cursor, |
| 30 | +) (*page.Page[*coredata.ControlStateTransition], error) { |
| 31 | + var controlStateTransitions coredata.ControlStateTransitions |
| 32 | + |
| 33 | + err := s.pg.WithConn( |
| 34 | + ctx, |
| 35 | + func(conn pg.Conn) error { |
| 36 | + return controlStateTransitions.LoadByControlID( |
| 37 | + ctx, |
| 38 | + conn, |
| 39 | + s.scope, |
| 40 | + controlID, |
| 41 | + cursor, |
| 42 | + ) |
| 43 | + }, |
| 44 | + ) |
| 45 | + |
| 46 | + if err != nil { |
| 47 | + return nil, err |
| 48 | + } |
| 49 | + |
| 50 | + return page.NewPage(controlStateTransitions, cursor), nil |
| 51 | +} |
0 commit comments