Initial work on getting communication context
Committing now to debug build process.
This commit is contained in:
parent
bab00db3ee
commit
b369361a43
31 changed files with 1352 additions and 4 deletions
53
db/query/comms/email_log.go
Normal file
53
db/query/comms/email_log.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package comms
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
//"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/enum"
|
||||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/model"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/table"
|
||||
)
|
||||
|
||||
/*
|
||||
func CommunicationInsert(ctx context.Context, txn db.Tx, m model.Communication) (model.Communication, error) {
|
||||
statement := table.Communication.INSERT(table.Communication.MutableColumns).
|
||||
MODEL(m).
|
||||
RETURNING(table.Communication.AllColumns)
|
||||
return db.ExecuteOneTx[model.Communication](ctx, txn, statement)
|
||||
}
|
||||
func CommunicationFromID(ctx context.Context, comm_id int64) (model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.ID.EQ(postgres.Int(comm_id)))
|
||||
return db.ExecuteOne[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationsFromOrganization(ctx context.Context, org_id int64) ([]model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id))).
|
||||
ORDER_BY(table.Communication.Created.DESC())
|
||||
return db.ExecuteMany[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationSetStatus(ctx context.Context, txn db.Tx, org_id int64, comm_id int64, status model.Communicationstatus) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(
|
||||
table.Communication.Status.SET(postgres.NewEnumValue(status.String())),
|
||||
).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
|
||||
table.Communication.ID.EQ(postgres.Int(comm_id))))
|
||||
return db.ExecuteNoneTx(ctx, txn, statement)
|
||||
}
|
||||
*/
|
||||
|
||||
func EmailLogFromID(ctx context.Context, id int64) (model.EmailLog, error) {
|
||||
statement := table.EmailLog.SELECT(
|
||||
table.EmailLog.AllColumns,
|
||||
).FROM(table.EmailLog).
|
||||
WHERE(table.EmailLog.ID.EQ(postgres.Int(id)))
|
||||
return db.ExecuteOne[model.EmailLog](ctx, statement)
|
||||
}
|
||||
18
db/query/comms/text_log.go
Normal file
18
db/query/comms/text_log.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package comms
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/model"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/table"
|
||||
)
|
||||
|
||||
func TextLogFromID(ctx context.Context, id int64) (model.TextLog, error) {
|
||||
statement := table.TextLog.SELECT(
|
||||
table.TextLog.AllColumns,
|
||||
).FROM(table.TextLog).
|
||||
WHERE(table.TextLog.ID.EQ(postgres.Int(id)))
|
||||
return db.ExecuteOne[model.TextLog](ctx, statement)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue