9
9
10
10
"github.com/pkg/errors"
11
11
"github.com/volatiletech/sqlboiler/boil"
12
+ "github.com/volatiletech/sqlboiler/queries/qm"
12
13
13
14
"github.com/ProgrammingLab/prolab-accounts/infra/record"
14
15
"github.com/ProgrammingLab/prolab-accounts/infra/store"
@@ -33,11 +34,24 @@ const (
33
34
)
34
35
35
36
func (s * invitationStoreImpl ) ListInvitations () ([]* record.Invitation , error ) {
36
- panic ("not implemented" )
37
+ mods := []qm.QueryMod {
38
+ qm .OrderBy (record .InvitationColumns .CreatedAt ),
39
+ }
40
+
41
+ invs , err := record .Invitations (mods ... ).All (s .ctx , s .db )
42
+ if err != nil {
43
+ return nil , errors .WithStack (err )
44
+ }
45
+
46
+ return invs , nil
37
47
}
38
48
39
49
func (s * invitationStoreImpl ) GetInvitation (id int64 ) (* record.Invitation , error ) {
40
- panic ("not implemented" )
50
+ inv , err := record .FindInvitation (s .ctx , s .db , id )
51
+ if err != nil {
52
+ return nil , errors .WithStack (err )
53
+ }
54
+ return inv , nil
41
55
}
42
56
43
57
func (s * invitationStoreImpl ) CreateInvitation (inviter model.UserID , email string ) (* record.Invitation , error ) {
@@ -65,7 +79,8 @@ func (s *invitationStoreImpl) CreateInvitation(inviter model.UserID, email strin
65
79
}
66
80
67
81
func (s * invitationStoreImpl ) DeleteInvitation (id int64 ) error {
68
- panic ("not implemented" )
82
+ _ , err := record .Invitations (record .InvitationWhere .ID .EQ (id )).DeleteAll (s .ctx , s .db )
83
+ return errors .WithStack (err )
69
84
}
70
85
71
86
func generateInvitationCode () (string , error ) {
0 commit comments