2917 lines
87 KiB
Go
2917 lines
87 KiB
Go
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package models
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dm"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/um"
|
|
"github.com/Gleipnir-Technology/bob/expr"
|
|
"github.com/Gleipnir-Technology/bob/orm"
|
|
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/aarondl/opt/omit"
|
|
"github.com/aarondl/opt/omitnull"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
// PublicreportReport is an object representing the database table.
|
|
type PublicreportReport struct {
|
|
AddressRaw string `db:"address_raw" `
|
|
AddressNumber string `db:"address_number" `
|
|
AddressStreet string `db:"address_street" `
|
|
AddressLocality string `db:"address_locality" `
|
|
AddressRegion string `db:"address_region" `
|
|
AddressPostalCode string `db:"address_postal_code" `
|
|
AddressCountry string `db:"address_country" `
|
|
AddressID null.Val[int32] `db:"address_id" `
|
|
Created time.Time `db:"created" `
|
|
Location null.Val[string] `db:"location" `
|
|
H3cell null.Val[string] `db:"h3cell" `
|
|
ID int32 `db:"id,pk" `
|
|
LatlngAccuracyType enums.PublicreportAccuracytype `db:"latlng_accuracy_type" `
|
|
LatlngAccuracyValue float32 `db:"latlng_accuracy_value" `
|
|
MapZoom float32 `db:"map_zoom" `
|
|
OrganizationID int32 `db:"organization_id" `
|
|
PublicID string `db:"public_id" `
|
|
ReporterName string `db:"reporter_name" `
|
|
ReporterEmail string `db:"reporter_email" `
|
|
ReporterPhone string `db:"reporter_phone" `
|
|
ReporterContactConsent null.Val[bool] `db:"reporter_contact_consent" `
|
|
ReportType enums.PublicreportReporttype `db:"report_type" `
|
|
Reviewed null.Val[time.Time] `db:"reviewed" `
|
|
ReviewerID null.Val[int32] `db:"reviewer_id" `
|
|
Status enums.PublicreportReportstatustype `db:"status" `
|
|
LocationLatitude null.Val[float64] `db:"location_latitude,generated" `
|
|
LocationLongitude null.Val[float64] `db:"location_longitude,generated" `
|
|
|
|
R publicreportReportR `db:"-" `
|
|
}
|
|
|
|
// PublicreportReportSlice is an alias for a slice of pointers to PublicreportReport.
|
|
// This should almost always be used instead of []*PublicreportReport.
|
|
type PublicreportReportSlice []*PublicreportReport
|
|
|
|
// PublicreportReports contains methods to work with the report table
|
|
var PublicreportReports = psql.NewTablex[*PublicreportReport, PublicreportReportSlice, *PublicreportReportSetter]("publicreport", "report", buildPublicreportReportColumns("publicreport.report"))
|
|
|
|
// PublicreportReportsQuery is a query on the report table
|
|
type PublicreportReportsQuery = *psql.ViewQuery[*PublicreportReport, PublicreportReportSlice]
|
|
|
|
// publicreportReportR is where relationships are stored.
|
|
type publicreportReportR struct {
|
|
TextJobs CommsTextJobSlice // comms.text_job.text_job_report_id_fkey
|
|
NotifyEmails PublicreportNotifyEmailSlice // publicreport.notify_email.notify_email_report_id_fkey
|
|
NotifyPhones PublicreportNotifyPhoneSlice // publicreport.notify_phone.notify_phone_report_id_fkey
|
|
Nuisance *PublicreportNuisance // publicreport.nuisance.nuisance_report_id_fkey
|
|
Address *Address // publicreport.report.report_address_id_fkey
|
|
Organization *Organization // publicreport.report.report_organization_id_fkey
|
|
ReviewerUser *User // publicreport.report.report_reviewer_id_fkey
|
|
Images PublicreportImageSlice // publicreport.report_image.report_image_image_id_fkeypublicreport.report_image.report_image_report_id_fkey
|
|
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_report_id_fkey
|
|
Water *PublicreportWater // publicreport.water.water_report_id_fkey
|
|
ReportTexts ReportTextSlice // report_text.report_text_report_id_fkey
|
|
}
|
|
|
|
func buildPublicreportReportColumns(alias string) publicreportReportColumns {
|
|
return publicreportReportColumns{
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
|
"address_raw", "address_number", "address_street", "address_locality", "address_region", "address_postal_code", "address_country", "address_id", "created", "location", "h3cell", "id", "latlng_accuracy_type", "latlng_accuracy_value", "map_zoom", "organization_id", "public_id", "reporter_name", "reporter_email", "reporter_phone", "reporter_contact_consent", "report_type", "reviewed", "reviewer_id", "status", "location_latitude", "location_longitude",
|
|
).WithParent("publicreport.report"),
|
|
tableAlias: alias,
|
|
AddressRaw: psql.Quote(alias, "address_raw"),
|
|
AddressNumber: psql.Quote(alias, "address_number"),
|
|
AddressStreet: psql.Quote(alias, "address_street"),
|
|
AddressLocality: psql.Quote(alias, "address_locality"),
|
|
AddressRegion: psql.Quote(alias, "address_region"),
|
|
AddressPostalCode: psql.Quote(alias, "address_postal_code"),
|
|
AddressCountry: psql.Quote(alias, "address_country"),
|
|
AddressID: psql.Quote(alias, "address_id"),
|
|
Created: psql.Quote(alias, "created"),
|
|
Location: psql.Quote(alias, "location"),
|
|
H3cell: psql.Quote(alias, "h3cell"),
|
|
ID: psql.Quote(alias, "id"),
|
|
LatlngAccuracyType: psql.Quote(alias, "latlng_accuracy_type"),
|
|
LatlngAccuracyValue: psql.Quote(alias, "latlng_accuracy_value"),
|
|
MapZoom: psql.Quote(alias, "map_zoom"),
|
|
OrganizationID: psql.Quote(alias, "organization_id"),
|
|
PublicID: psql.Quote(alias, "public_id"),
|
|
ReporterName: psql.Quote(alias, "reporter_name"),
|
|
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
|
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
|
ReporterContactConsent: psql.Quote(alias, "reporter_contact_consent"),
|
|
ReportType: psql.Quote(alias, "report_type"),
|
|
Reviewed: psql.Quote(alias, "reviewed"),
|
|
ReviewerID: psql.Quote(alias, "reviewer_id"),
|
|
Status: psql.Quote(alias, "status"),
|
|
LocationLatitude: psql.Quote(alias, "location_latitude"),
|
|
LocationLongitude: psql.Quote(alias, "location_longitude"),
|
|
}
|
|
}
|
|
|
|
type publicreportReportColumns struct {
|
|
expr.ColumnsExpr
|
|
tableAlias string
|
|
AddressRaw psql.Expression
|
|
AddressNumber psql.Expression
|
|
AddressStreet psql.Expression
|
|
AddressLocality psql.Expression
|
|
AddressRegion psql.Expression
|
|
AddressPostalCode psql.Expression
|
|
AddressCountry psql.Expression
|
|
AddressID psql.Expression
|
|
Created psql.Expression
|
|
Location psql.Expression
|
|
H3cell psql.Expression
|
|
ID psql.Expression
|
|
LatlngAccuracyType psql.Expression
|
|
LatlngAccuracyValue psql.Expression
|
|
MapZoom psql.Expression
|
|
OrganizationID psql.Expression
|
|
PublicID psql.Expression
|
|
ReporterName psql.Expression
|
|
ReporterEmail psql.Expression
|
|
ReporterPhone psql.Expression
|
|
ReporterContactConsent psql.Expression
|
|
ReportType psql.Expression
|
|
Reviewed psql.Expression
|
|
ReviewerID psql.Expression
|
|
Status psql.Expression
|
|
LocationLatitude psql.Expression
|
|
LocationLongitude psql.Expression
|
|
}
|
|
|
|
func (c publicreportReportColumns) Alias() string {
|
|
return c.tableAlias
|
|
}
|
|
|
|
func (publicreportReportColumns) AliasedAs(alias string) publicreportReportColumns {
|
|
return buildPublicreportReportColumns(alias)
|
|
}
|
|
|
|
// PublicreportReportSetter is used for insert/upsert/update operations
|
|
// All values are optional, and do not have to be set
|
|
// Generated columns are not included
|
|
type PublicreportReportSetter struct {
|
|
AddressRaw omit.Val[string] `db:"address_raw" `
|
|
AddressNumber omit.Val[string] `db:"address_number" `
|
|
AddressStreet omit.Val[string] `db:"address_street" `
|
|
AddressLocality omit.Val[string] `db:"address_locality" `
|
|
AddressRegion omit.Val[string] `db:"address_region" `
|
|
AddressPostalCode omit.Val[string] `db:"address_postal_code" `
|
|
AddressCountry omit.Val[string] `db:"address_country" `
|
|
AddressID omitnull.Val[int32] `db:"address_id" `
|
|
Created omit.Val[time.Time] `db:"created" `
|
|
Location omitnull.Val[string] `db:"location" `
|
|
H3cell omitnull.Val[string] `db:"h3cell" `
|
|
ID omit.Val[int32] `db:"id,pk" `
|
|
LatlngAccuracyType omit.Val[enums.PublicreportAccuracytype] `db:"latlng_accuracy_type" `
|
|
LatlngAccuracyValue omit.Val[float32] `db:"latlng_accuracy_value" `
|
|
MapZoom omit.Val[float32] `db:"map_zoom" `
|
|
OrganizationID omit.Val[int32] `db:"organization_id" `
|
|
PublicID omit.Val[string] `db:"public_id" `
|
|
ReporterName omit.Val[string] `db:"reporter_name" `
|
|
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
|
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
|
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
|
ReportType omit.Val[enums.PublicreportReporttype] `db:"report_type" `
|
|
Reviewed omitnull.Val[time.Time] `db:"reviewed" `
|
|
ReviewerID omitnull.Val[int32] `db:"reviewer_id" `
|
|
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
|
}
|
|
|
|
func (s PublicreportReportSetter) SetColumns() []string {
|
|
vals := make([]string, 0, 25)
|
|
if s.AddressRaw.IsValue() {
|
|
vals = append(vals, "address_raw")
|
|
}
|
|
if s.AddressNumber.IsValue() {
|
|
vals = append(vals, "address_number")
|
|
}
|
|
if s.AddressStreet.IsValue() {
|
|
vals = append(vals, "address_street")
|
|
}
|
|
if s.AddressLocality.IsValue() {
|
|
vals = append(vals, "address_locality")
|
|
}
|
|
if s.AddressRegion.IsValue() {
|
|
vals = append(vals, "address_region")
|
|
}
|
|
if s.AddressPostalCode.IsValue() {
|
|
vals = append(vals, "address_postal_code")
|
|
}
|
|
if s.AddressCountry.IsValue() {
|
|
vals = append(vals, "address_country")
|
|
}
|
|
if !s.AddressID.IsUnset() {
|
|
vals = append(vals, "address_id")
|
|
}
|
|
if s.Created.IsValue() {
|
|
vals = append(vals, "created")
|
|
}
|
|
if !s.Location.IsUnset() {
|
|
vals = append(vals, "location")
|
|
}
|
|
if !s.H3cell.IsUnset() {
|
|
vals = append(vals, "h3cell")
|
|
}
|
|
if s.ID.IsValue() {
|
|
vals = append(vals, "id")
|
|
}
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
vals = append(vals, "latlng_accuracy_type")
|
|
}
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
vals = append(vals, "latlng_accuracy_value")
|
|
}
|
|
if s.MapZoom.IsValue() {
|
|
vals = append(vals, "map_zoom")
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
vals = append(vals, "organization_id")
|
|
}
|
|
if s.PublicID.IsValue() {
|
|
vals = append(vals, "public_id")
|
|
}
|
|
if s.ReporterName.IsValue() {
|
|
vals = append(vals, "reporter_name")
|
|
}
|
|
if s.ReporterEmail.IsValue() {
|
|
vals = append(vals, "reporter_email")
|
|
}
|
|
if s.ReporterPhone.IsValue() {
|
|
vals = append(vals, "reporter_phone")
|
|
}
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
vals = append(vals, "reporter_contact_consent")
|
|
}
|
|
if s.ReportType.IsValue() {
|
|
vals = append(vals, "report_type")
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
vals = append(vals, "reviewed")
|
|
}
|
|
if !s.ReviewerID.IsUnset() {
|
|
vals = append(vals, "reviewer_id")
|
|
}
|
|
if s.Status.IsValue() {
|
|
vals = append(vals, "status")
|
|
}
|
|
return vals
|
|
}
|
|
|
|
func (s PublicreportReportSetter) Overwrite(t *PublicreportReport) {
|
|
if s.AddressRaw.IsValue() {
|
|
t.AddressRaw = s.AddressRaw.MustGet()
|
|
}
|
|
if s.AddressNumber.IsValue() {
|
|
t.AddressNumber = s.AddressNumber.MustGet()
|
|
}
|
|
if s.AddressStreet.IsValue() {
|
|
t.AddressStreet = s.AddressStreet.MustGet()
|
|
}
|
|
if s.AddressLocality.IsValue() {
|
|
t.AddressLocality = s.AddressLocality.MustGet()
|
|
}
|
|
if s.AddressRegion.IsValue() {
|
|
t.AddressRegion = s.AddressRegion.MustGet()
|
|
}
|
|
if s.AddressPostalCode.IsValue() {
|
|
t.AddressPostalCode = s.AddressPostalCode.MustGet()
|
|
}
|
|
if s.AddressCountry.IsValue() {
|
|
t.AddressCountry = s.AddressCountry.MustGet()
|
|
}
|
|
if !s.AddressID.IsUnset() {
|
|
t.AddressID = s.AddressID.MustGetNull()
|
|
}
|
|
if s.Created.IsValue() {
|
|
t.Created = s.Created.MustGet()
|
|
}
|
|
if !s.Location.IsUnset() {
|
|
t.Location = s.Location.MustGetNull()
|
|
}
|
|
if !s.H3cell.IsUnset() {
|
|
t.H3cell = s.H3cell.MustGetNull()
|
|
}
|
|
if s.ID.IsValue() {
|
|
t.ID = s.ID.MustGet()
|
|
}
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
t.LatlngAccuracyType = s.LatlngAccuracyType.MustGet()
|
|
}
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
t.LatlngAccuracyValue = s.LatlngAccuracyValue.MustGet()
|
|
}
|
|
if s.MapZoom.IsValue() {
|
|
t.MapZoom = s.MapZoom.MustGet()
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
t.OrganizationID = s.OrganizationID.MustGet()
|
|
}
|
|
if s.PublicID.IsValue() {
|
|
t.PublicID = s.PublicID.MustGet()
|
|
}
|
|
if s.ReporterName.IsValue() {
|
|
t.ReporterName = s.ReporterName.MustGet()
|
|
}
|
|
if s.ReporterEmail.IsValue() {
|
|
t.ReporterEmail = s.ReporterEmail.MustGet()
|
|
}
|
|
if s.ReporterPhone.IsValue() {
|
|
t.ReporterPhone = s.ReporterPhone.MustGet()
|
|
}
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
t.ReporterContactConsent = s.ReporterContactConsent.MustGetNull()
|
|
}
|
|
if s.ReportType.IsValue() {
|
|
t.ReportType = s.ReportType.MustGet()
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
t.Reviewed = s.Reviewed.MustGetNull()
|
|
}
|
|
if !s.ReviewerID.IsUnset() {
|
|
t.ReviewerID = s.ReviewerID.MustGetNull()
|
|
}
|
|
if s.Status.IsValue() {
|
|
t.Status = s.Status.MustGet()
|
|
}
|
|
}
|
|
|
|
func (s *PublicreportReportSetter) Apply(q *dialect.InsertQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return PublicreportReports.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
})
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
vals := make([]bob.Expression, 25)
|
|
if s.AddressRaw.IsValue() {
|
|
vals[0] = psql.Arg(s.AddressRaw.MustGet())
|
|
} else {
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressNumber.IsValue() {
|
|
vals[1] = psql.Arg(s.AddressNumber.MustGet())
|
|
} else {
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
vals[2] = psql.Arg(s.AddressStreet.MustGet())
|
|
} else {
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
vals[3] = psql.Arg(s.AddressLocality.MustGet())
|
|
} else {
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
vals[4] = psql.Arg(s.AddressRegion.MustGet())
|
|
} else {
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
vals[5] = psql.Arg(s.AddressPostalCode.MustGet())
|
|
} else {
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
vals[6] = psql.Arg(s.AddressCountry.MustGet())
|
|
} else {
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.AddressID.IsUnset() {
|
|
vals[7] = psql.Arg(s.AddressID.MustGetNull())
|
|
} else {
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Created.IsValue() {
|
|
vals[8] = psql.Arg(s.Created.MustGet())
|
|
} else {
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Location.IsUnset() {
|
|
vals[9] = psql.Arg(s.Location.MustGetNull())
|
|
} else {
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
vals[10] = psql.Arg(s.H3cell.MustGetNull())
|
|
} else {
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.ID.IsValue() {
|
|
vals[11] = psql.Arg(s.ID.MustGet())
|
|
} else {
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
vals[12] = psql.Arg(s.LatlngAccuracyType.MustGet())
|
|
} else {
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
vals[13] = psql.Arg(s.LatlngAccuracyValue.MustGet())
|
|
} else {
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.MapZoom.IsValue() {
|
|
vals[14] = psql.Arg(s.MapZoom.MustGet())
|
|
} else {
|
|
vals[14] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
vals[15] = psql.Arg(s.OrganizationID.MustGet())
|
|
} else {
|
|
vals[15] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.PublicID.IsValue() {
|
|
vals[16] = psql.Arg(s.PublicID.MustGet())
|
|
} else {
|
|
vals[16] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.ReporterName.IsValue() {
|
|
vals[17] = psql.Arg(s.ReporterName.MustGet())
|
|
} else {
|
|
vals[17] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
vals[18] = psql.Arg(s.ReporterEmail.MustGet())
|
|
} else {
|
|
vals[18] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
vals[19] = psql.Arg(s.ReporterPhone.MustGet())
|
|
} else {
|
|
vals[19] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
vals[20] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
|
} else {
|
|
vals[20] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.ReportType.IsValue() {
|
|
vals[21] = psql.Arg(s.ReportType.MustGet())
|
|
} else {
|
|
vals[21] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
vals[22] = psql.Arg(s.Reviewed.MustGetNull())
|
|
} else {
|
|
vals[22] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReviewerID.IsUnset() {
|
|
vals[23] = psql.Arg(s.ReviewerID.MustGetNull())
|
|
} else {
|
|
vals[23] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Status.IsValue() {
|
|
vals[24] = psql.Arg(s.Status.MustGet())
|
|
} else {
|
|
vals[24] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
func (s PublicreportReportSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return um.Set(s.Expressions()...)
|
|
}
|
|
|
|
func (s PublicreportReportSetter) Expressions(prefix ...string) []bob.Expression {
|
|
exprs := make([]bob.Expression, 0, 25)
|
|
|
|
if s.AddressRaw.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_raw")...),
|
|
psql.Arg(s.AddressRaw),
|
|
}})
|
|
}
|
|
|
|
if s.AddressNumber.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_number")...),
|
|
psql.Arg(s.AddressNumber),
|
|
}})
|
|
}
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_street")...),
|
|
psql.Arg(s.AddressStreet),
|
|
}})
|
|
}
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_locality")...),
|
|
psql.Arg(s.AddressLocality),
|
|
}})
|
|
}
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_region")...),
|
|
psql.Arg(s.AddressRegion),
|
|
}})
|
|
}
|
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_postal_code")...),
|
|
psql.Arg(s.AddressPostalCode),
|
|
}})
|
|
}
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_country")...),
|
|
psql.Arg(s.AddressCountry),
|
|
}})
|
|
}
|
|
|
|
if !s.AddressID.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_id")...),
|
|
psql.Arg(s.AddressID),
|
|
}})
|
|
}
|
|
|
|
if s.Created.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "created")...),
|
|
psql.Arg(s.Created),
|
|
}})
|
|
}
|
|
|
|
if !s.Location.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "location")...),
|
|
psql.Arg(s.Location),
|
|
}})
|
|
}
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "h3cell")...),
|
|
psql.Arg(s.H3cell),
|
|
}})
|
|
}
|
|
|
|
if s.ID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "id")...),
|
|
psql.Arg(s.ID),
|
|
}})
|
|
}
|
|
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "latlng_accuracy_type")...),
|
|
psql.Arg(s.LatlngAccuracyType),
|
|
}})
|
|
}
|
|
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "latlng_accuracy_value")...),
|
|
psql.Arg(s.LatlngAccuracyValue),
|
|
}})
|
|
}
|
|
|
|
if s.MapZoom.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "map_zoom")...),
|
|
psql.Arg(s.MapZoom),
|
|
}})
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "organization_id")...),
|
|
psql.Arg(s.OrganizationID),
|
|
}})
|
|
}
|
|
|
|
if s.PublicID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "public_id")...),
|
|
psql.Arg(s.PublicID),
|
|
}})
|
|
}
|
|
|
|
if s.ReporterName.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_name")...),
|
|
psql.Arg(s.ReporterName),
|
|
}})
|
|
}
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_email")...),
|
|
psql.Arg(s.ReporterEmail),
|
|
}})
|
|
}
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_phone")...),
|
|
psql.Arg(s.ReporterPhone),
|
|
}})
|
|
}
|
|
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_contact_consent")...),
|
|
psql.Arg(s.ReporterContactConsent),
|
|
}})
|
|
}
|
|
|
|
if s.ReportType.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "report_type")...),
|
|
psql.Arg(s.ReportType),
|
|
}})
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewed")...),
|
|
psql.Arg(s.Reviewed),
|
|
}})
|
|
}
|
|
|
|
if !s.ReviewerID.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewer_id")...),
|
|
psql.Arg(s.ReviewerID),
|
|
}})
|
|
}
|
|
|
|
if s.Status.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "status")...),
|
|
psql.Arg(s.Status),
|
|
}})
|
|
}
|
|
|
|
return exprs
|
|
}
|
|
|
|
// FindPublicreportReport retrieves a single record by primary key
|
|
// If cols is empty Find will return all columns.
|
|
func FindPublicreportReport(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportReport, error) {
|
|
if len(cols) == 0 {
|
|
return PublicreportReports.Query(
|
|
sm.Where(PublicreportReports.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
return PublicreportReports.Query(
|
|
sm.Where(PublicreportReports.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
sm.Columns(PublicreportReports.Columns.Only(cols...)),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
// PublicreportReportExists checks the presence of a single record by primary key
|
|
func PublicreportReportExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
|
|
return PublicreportReports.Query(
|
|
sm.Where(PublicreportReports.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).Exists(ctx, exec)
|
|
}
|
|
|
|
// AfterQueryHook is called after PublicreportReport is retrieved from the database
|
|
func (o *PublicreportReport) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = PublicreportReports.AfterSelectHooks.RunHooks(ctx, exec, PublicreportReportSlice{o})
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = PublicreportReports.AfterInsertHooks.RunHooks(ctx, exec, PublicreportReportSlice{o})
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = PublicreportReports.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportReportSlice{o})
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = PublicreportReports.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportReportSlice{o})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// primaryKeyVals returns the primary key values of the PublicreportReport
|
|
func (o *PublicreportReport) primaryKeyVals() bob.Expression {
|
|
return psql.Arg(o.ID)
|
|
}
|
|
|
|
func (o *PublicreportReport) pkEQ() dialect.Expression {
|
|
return psql.Quote("publicreport.report", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
|
|
}))
|
|
}
|
|
|
|
// Update uses an executor to update the PublicreportReport
|
|
func (o *PublicreportReport) Update(ctx context.Context, exec bob.Executor, s *PublicreportReportSetter) error {
|
|
v, err := PublicreportReports.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.R = v.R
|
|
*o = *v
|
|
|
|
return nil
|
|
}
|
|
|
|
// Delete deletes a single PublicreportReport record with an executor
|
|
func (o *PublicreportReport) Delete(ctx context.Context, exec bob.Executor) error {
|
|
_, err := PublicreportReports.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
// Reload refreshes the PublicreportReport using the executor
|
|
func (o *PublicreportReport) Reload(ctx context.Context, exec bob.Executor) error {
|
|
o2, err := PublicreportReports.Query(
|
|
sm.Where(PublicreportReports.Columns.ID.EQ(psql.Arg(o.ID))),
|
|
).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o2.R = o.R
|
|
*o = *o2
|
|
|
|
return nil
|
|
}
|
|
|
|
// AfterQueryHook is called after PublicreportReportSlice is retrieved from the database
|
|
func (o PublicreportReportSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = PublicreportReports.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = PublicreportReports.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = PublicreportReports.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = PublicreportReports.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportReportSlice) pkIN() dialect.Expression {
|
|
if len(o) == 0 {
|
|
return psql.Raw("NULL")
|
|
}
|
|
|
|
return psql.Quote("publicreport.report", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
pkPairs := make([]bob.Expression, len(o))
|
|
for i, row := range o {
|
|
pkPairs[i] = row.primaryKeyVals()
|
|
}
|
|
return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
// copyMatchingRows finds models in the given slice that have the same primary key
|
|
// then it first copies the existing relationships from the old model to the new model
|
|
// and then replaces the old model in the slice with the new model
|
|
func (o PublicreportReportSlice) copyMatchingRows(from ...*PublicreportReport) {
|
|
for i, old := range o {
|
|
for _, new := range from {
|
|
if new.ID != old.ID {
|
|
continue
|
|
}
|
|
new.R = old.R
|
|
o[i] = new
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
|
func (o PublicreportReportSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return PublicreportReports.BeforeUpdateHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *PublicreportReport:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*PublicreportReport:
|
|
o.copyMatchingRows(retrieved...)
|
|
case PublicreportReportSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a PublicreportReport or a slice of PublicreportReport
|
|
// then run the AfterUpdateHooks on the slice
|
|
_, err = PublicreportReports.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
func (o PublicreportReportSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
|
|
return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return PublicreportReports.BeforeDeleteHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *PublicreportReport:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*PublicreportReport:
|
|
o.copyMatchingRows(retrieved...)
|
|
case PublicreportReportSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a PublicreportReport or a slice of PublicreportReport
|
|
// then run the AfterDeleteHooks on the slice
|
|
_, err = PublicreportReports.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
func (o PublicreportReportSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportReportSetter) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := PublicreportReports.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportReportSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := PublicreportReports.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportReportSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
o2, err := PublicreportReports.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
return nil
|
|
}
|
|
|
|
// TextJobs starts a query for related objects on comms.text_job
|
|
func (o *PublicreportReport) TextJobs(mods ...bob.Mod[*dialect.SelectQuery]) CommsTextJobsQuery {
|
|
return CommsTextJobs.Query(append(mods,
|
|
sm.Where(CommsTextJobs.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) TextJobs(mods ...bob.Mod[*dialect.SelectQuery]) CommsTextJobsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return CommsTextJobs.Query(append(mods,
|
|
sm.Where(psql.Group(CommsTextJobs.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// NotifyEmails starts a query for related objects on publicreport.notify_email
|
|
func (o *PublicreportReport) NotifyEmails(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyEmailsQuery {
|
|
return PublicreportNotifyEmails.Query(append(mods,
|
|
sm.Where(PublicreportNotifyEmails.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) NotifyEmails(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyEmailsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportNotifyEmails.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNotifyEmails.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// NotifyPhones starts a query for related objects on publicreport.notify_phone
|
|
func (o *PublicreportReport) NotifyPhones(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyPhonesQuery {
|
|
return PublicreportNotifyPhones.Query(append(mods,
|
|
sm.Where(PublicreportNotifyPhones.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) NotifyPhones(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyPhonesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportNotifyPhones.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNotifyPhones.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Nuisance starts a query for related objects on publicreport.nuisance
|
|
func (o *PublicreportReport) Nuisance(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNuisancesQuery {
|
|
return PublicreportNuisances.Query(append(mods,
|
|
sm.Where(PublicreportNuisances.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) Nuisance(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNuisancesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportNuisances.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNuisances.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Address starts a query for related objects on address
|
|
func (o *PublicreportReport) Address(mods ...bob.Mod[*dialect.SelectQuery]) AddressesQuery {
|
|
return Addresses.Query(append(mods,
|
|
sm.Where(Addresses.Columns.ID.EQ(psql.Arg(o.AddressID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) Address(mods ...bob.Mod[*dialect.SelectQuery]) AddressesQuery {
|
|
pkAddressID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkAddressID = append(pkAddressID, o.AddressID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkAddressID), "integer[]")),
|
|
))
|
|
|
|
return Addresses.Query(append(mods,
|
|
sm.Where(psql.Group(Addresses.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Organization starts a query for related objects on organization
|
|
func (o *PublicreportReport) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
pkOrganizationID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
|
|
))
|
|
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerUser starts a query for related objects on user_
|
|
func (o *PublicreportReport) ReviewerUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
return Users.Query(append(mods,
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(o.ReviewerID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) ReviewerUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
pkReviewerID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkReviewerID = append(pkReviewerID, o.ReviewerID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkReviewerID), "integer[]")),
|
|
))
|
|
|
|
return Users.Query(append(mods,
|
|
sm.Where(psql.Group(Users.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Images starts a query for related objects on publicreport.image
|
|
func (o *PublicreportReport) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
|
return PublicreportImages.Query(append(mods,
|
|
sm.InnerJoin(PublicreportReportImages.NameAs()).On(
|
|
PublicreportImages.Columns.ID.EQ(PublicreportReportImages.Columns.ImageID)),
|
|
sm.Where(PublicreportReportImages.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportImages.Query(append(mods,
|
|
sm.InnerJoin(PublicreportReportImages.NameAs()).On(
|
|
PublicreportImages.Columns.ID.EQ(PublicreportReportImages.Columns.ImageID),
|
|
),
|
|
sm.Where(psql.Group(PublicreportReportImages.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReportLogs starts a query for related objects on publicreport.report_log
|
|
func (o *PublicreportReport) ReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
|
return PublicreportReportLogs.Query(append(mods,
|
|
sm.Where(PublicreportReportLogs.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) ReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportReportLogs.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportReportLogs.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Water starts a query for related objects on publicreport.water
|
|
func (o *PublicreportReport) Water(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportWatersQuery {
|
|
return PublicreportWaters.Query(append(mods,
|
|
sm.Where(PublicreportWaters.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) Water(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportWatersQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportWaters.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportWaters.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReportTexts starts a query for related objects on report_text
|
|
func (o *PublicreportReport) ReportTexts(mods ...bob.Mod[*dialect.SelectQuery]) ReportTextsQuery {
|
|
return ReportTexts.Query(append(mods,
|
|
sm.Where(ReportTexts.Columns.ReportID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportReportSlice) ReportTexts(mods ...bob.Mod[*dialect.SelectQuery]) ReportTextsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return ReportTexts.Query(append(mods,
|
|
sm.Where(psql.Group(ReportTexts.Columns.ReportID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
func insertPublicreportReportTextJobs0(ctx context.Context, exec bob.Executor, commsTextJobs1 []*CommsTextJobSetter, publicreportReport0 *PublicreportReport) (CommsTextJobSlice, error) {
|
|
for i := range commsTextJobs1 {
|
|
commsTextJobs1[i].ReportID = omitnull.From(publicreportReport0.ID)
|
|
}
|
|
|
|
ret, err := CommsTextJobs.Insert(bob.ToMods(commsTextJobs1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportTextJobs0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportTextJobs0(ctx context.Context, exec bob.Executor, count int, commsTextJobs1 CommsTextJobSlice, publicreportReport0 *PublicreportReport) (CommsTextJobSlice, error) {
|
|
setter := &CommsTextJobSetter{
|
|
ReportID: omitnull.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := commsTextJobs1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportTextJobs0: %w", err)
|
|
}
|
|
|
|
return commsTextJobs1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertTextJobs(ctx context.Context, exec bob.Executor, related ...*CommsTextJobSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
commsTextJobs1, err := insertPublicreportReportTextJobs0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.TextJobs = append(publicreportReport0.R.TextJobs, commsTextJobs1...)
|
|
|
|
for _, rel := range commsTextJobs1 {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachTextJobs(ctx context.Context, exec bob.Executor, related ...*CommsTextJob) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
commsTextJobs1 := CommsTextJobSlice(related)
|
|
|
|
_, err = attachPublicreportReportTextJobs0(ctx, exec, len(related), commsTextJobs1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.TextJobs = append(publicreportReport0.R.TextJobs, commsTextJobs1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportNotifyEmails0(ctx context.Context, exec bob.Executor, publicreportNotifyEmails1 []*PublicreportNotifyEmailSetter, publicreportReport0 *PublicreportReport) (PublicreportNotifyEmailSlice, error) {
|
|
for i := range publicreportNotifyEmails1 {
|
|
publicreportNotifyEmails1[i].ReportID = omit.From(publicreportReport0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportNotifyEmails.Insert(bob.ToMods(publicreportNotifyEmails1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportNotifyEmails0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportNotifyEmails0(ctx context.Context, exec bob.Executor, count int, publicreportNotifyEmails1 PublicreportNotifyEmailSlice, publicreportReport0 *PublicreportReport) (PublicreportNotifyEmailSlice, error) {
|
|
setter := &PublicreportNotifyEmailSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := publicreportNotifyEmails1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportNotifyEmails0: %w", err)
|
|
}
|
|
|
|
return publicreportNotifyEmails1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertNotifyEmails(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyEmailSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportNotifyEmails1, err := insertPublicreportReportNotifyEmails0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.NotifyEmails = append(publicreportReport0.R.NotifyEmails, publicreportNotifyEmails1...)
|
|
|
|
for _, rel := range publicreportNotifyEmails1 {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachNotifyEmails(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyEmail) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportNotifyEmails1 := PublicreportNotifyEmailSlice(related)
|
|
|
|
_, err = attachPublicreportReportNotifyEmails0(ctx, exec, len(related), publicreportNotifyEmails1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.NotifyEmails = append(publicreportReport0.R.NotifyEmails, publicreportNotifyEmails1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportNotifyPhones0(ctx context.Context, exec bob.Executor, publicreportNotifyPhones1 []*PublicreportNotifyPhoneSetter, publicreportReport0 *PublicreportReport) (PublicreportNotifyPhoneSlice, error) {
|
|
for i := range publicreportNotifyPhones1 {
|
|
publicreportNotifyPhones1[i].ReportID = omit.From(publicreportReport0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportNotifyPhones.Insert(bob.ToMods(publicreportNotifyPhones1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportNotifyPhones0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportNotifyPhones0(ctx context.Context, exec bob.Executor, count int, publicreportNotifyPhones1 PublicreportNotifyPhoneSlice, publicreportReport0 *PublicreportReport) (PublicreportNotifyPhoneSlice, error) {
|
|
setter := &PublicreportNotifyPhoneSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := publicreportNotifyPhones1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportNotifyPhones0: %w", err)
|
|
}
|
|
|
|
return publicreportNotifyPhones1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertNotifyPhones(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyPhoneSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportNotifyPhones1, err := insertPublicreportReportNotifyPhones0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.NotifyPhones = append(publicreportReport0.R.NotifyPhones, publicreportNotifyPhones1...)
|
|
|
|
for _, rel := range publicreportNotifyPhones1 {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachNotifyPhones(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyPhone) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportNotifyPhones1 := PublicreportNotifyPhoneSlice(related)
|
|
|
|
_, err = attachPublicreportReportNotifyPhones0(ctx, exec, len(related), publicreportNotifyPhones1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.NotifyPhones = append(publicreportReport0.R.NotifyPhones, publicreportNotifyPhones1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportNuisance0(ctx context.Context, exec bob.Executor, publicreportNuisance1 *PublicreportNuisanceSetter, publicreportReport0 *PublicreportReport) (*PublicreportNuisance, error) {
|
|
publicreportNuisance1.ReportID = omit.From(publicreportReport0.ID)
|
|
|
|
ret, err := PublicreportNuisances.Insert(publicreportNuisance1).One(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportNuisance0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportNuisance0(ctx context.Context, exec bob.Executor, count int, publicreportNuisance1 *PublicreportNuisance, publicreportReport0 *PublicreportReport) (*PublicreportNuisance, error) {
|
|
setter := &PublicreportNuisanceSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := publicreportNuisance1.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportNuisance0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisance1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertNuisance(ctx context.Context, exec bob.Executor, related *PublicreportNuisanceSetter) error {
|
|
var err error
|
|
|
|
publicreportNuisance1, err := insertPublicreportReportNuisance0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Nuisance = publicreportNuisance1
|
|
|
|
publicreportNuisance1.R.Report = publicreportReport0
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachNuisance(ctx context.Context, exec bob.Executor, publicreportNuisance1 *PublicreportNuisance) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportReportNuisance0(ctx, exec, 1, publicreportNuisance1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Nuisance = publicreportNuisance1
|
|
|
|
publicreportNuisance1.R.Report = publicreportReport0
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportReportAddress0(ctx context.Context, exec bob.Executor, count int, publicreportReport0 *PublicreportReport, address1 *Address) (*PublicreportReport, error) {
|
|
setter := &PublicreportReportSetter{
|
|
AddressID: omitnull.From(address1.ID),
|
|
}
|
|
|
|
err := publicreportReport0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportAddress0: %w", err)
|
|
}
|
|
|
|
return publicreportReport0, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertAddress(ctx context.Context, exec bob.Executor, related *AddressSetter) error {
|
|
var err error
|
|
|
|
address1, err := Addresses.Insert(related).One(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
|
|
_, err = attachPublicreportReportAddress0(ctx, exec, 1, publicreportReport0, address1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Address = address1
|
|
|
|
address1.R.Reports = append(address1.R.Reports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachAddress(ctx context.Context, exec bob.Executor, address1 *Address) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportReportAddress0(ctx, exec, 1, publicreportReport0, address1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Address = address1
|
|
|
|
address1.R.Reports = append(address1.R.Reports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportReportOrganization0(ctx context.Context, exec bob.Executor, count int, publicreportReport0 *PublicreportReport, organization1 *Organization) (*PublicreportReport, error) {
|
|
setter := &PublicreportReportSetter{
|
|
OrganizationID: omit.From(organization1.ID),
|
|
}
|
|
|
|
err := publicreportReport0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportOrganization0: %w", err)
|
|
}
|
|
|
|
return publicreportReport0, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
|
|
var err error
|
|
|
|
organization1, err := Organizations.Insert(related).One(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
|
|
_, err = attachPublicreportReportOrganization0(ctx, exec, 1, publicreportReport0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Organization = organization1
|
|
|
|
organization1.R.Reports = append(organization1.R.Reports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportReportOrganization0(ctx, exec, 1, publicreportReport0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Organization = organization1
|
|
|
|
organization1.R.Reports = append(organization1.R.Reports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportReportReviewerUser0(ctx context.Context, exec bob.Executor, count int, publicreportReport0 *PublicreportReport, user1 *User) (*PublicreportReport, error) {
|
|
setter := &PublicreportReportSetter{
|
|
ReviewerID: omitnull.From(user1.ID),
|
|
}
|
|
|
|
err := publicreportReport0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportReviewerUser0: %w", err)
|
|
}
|
|
|
|
return publicreportReport0, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertReviewerUser(ctx context.Context, exec bob.Executor, related *UserSetter) error {
|
|
var err error
|
|
|
|
user1, err := Users.Insert(related).One(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
|
|
_, err = attachPublicreportReportReviewerUser0(ctx, exec, 1, publicreportReport0, user1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReviewerUser = user1
|
|
|
|
user1.R.ReviewerReports = append(user1.R.ReviewerReports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachReviewerUser(ctx context.Context, exec bob.Executor, user1 *User) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportReportReviewerUser0(ctx, exec, 1, publicreportReport0, user1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReviewerUser = user1
|
|
|
|
user1.R.ReviewerReports = append(user1.R.ReviewerReports, publicreportReport0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportReportImages0(ctx context.Context, exec bob.Executor, count int, publicreportReport0 *PublicreportReport, publicreportImages2 PublicreportImageSlice) (PublicreportReportImageSlice, error) {
|
|
setters := make([]*PublicreportReportImageSetter, count)
|
|
for i := range count {
|
|
setters[i] = &PublicreportReportImageSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
ImageID: omit.From(publicreportImages2[i].ID),
|
|
}
|
|
}
|
|
|
|
publicreportReportImages1, err := PublicreportReportImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportImages0: %w", err)
|
|
}
|
|
|
|
return publicreportReportImages1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImageSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
inserted, err := PublicreportImages.Insert(bob.ToMods(related...)).All(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
publicreportImages2 := PublicreportImageSlice(inserted)
|
|
|
|
_, err = attachPublicreportReportImages0(ctx, exec, len(related), publicreportReport0, publicreportImages2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Images = append(publicreportReport0.R.Images, publicreportImages2...)
|
|
|
|
for _, rel := range publicreportImages2 {
|
|
rel.R.Reports = append(rel.R.Reports, publicreportReport0)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImage) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportImages2 := PublicreportImageSlice(related)
|
|
|
|
_, err = attachPublicreportReportImages0(ctx, exec, len(related), publicreportReport0, publicreportImages2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Images = append(publicreportReport0.R.Images, publicreportImages2...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Reports = append(rel.R.Reports, publicreportReport0)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportReportLogs0(ctx context.Context, exec bob.Executor, publicreportReportLogs1 []*PublicreportReportLogSetter, publicreportReport0 *PublicreportReport) (PublicreportReportLogSlice, error) {
|
|
for i := range publicreportReportLogs1 {
|
|
publicreportReportLogs1[i].ReportID = omit.From(publicreportReport0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportReportLogs.Insert(bob.ToMods(publicreportReportLogs1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportReportLogs0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportReportLogs0(ctx context.Context, exec bob.Executor, count int, publicreportReportLogs1 PublicreportReportLogSlice, publicreportReport0 *PublicreportReport) (PublicreportReportLogSlice, error) {
|
|
setter := &PublicreportReportLogSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := publicreportReportLogs1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportReportLogs0: %w", err)
|
|
}
|
|
|
|
return publicreportReportLogs1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertReportLogs(ctx context.Context, exec bob.Executor, related ...*PublicreportReportLogSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportReportLogs1, err := insertPublicreportReportReportLogs0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReportLogs = append(publicreportReport0.R.ReportLogs, publicreportReportLogs1...)
|
|
|
|
for _, rel := range publicreportReportLogs1 {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachReportLogs(ctx context.Context, exec bob.Executor, related ...*PublicreportReportLog) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportReportLogs1 := PublicreportReportLogSlice(related)
|
|
|
|
_, err = attachPublicreportReportReportLogs0(ctx, exec, len(related), publicreportReportLogs1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReportLogs = append(publicreportReport0.R.ReportLogs, publicreportReportLogs1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportWater0(ctx context.Context, exec bob.Executor, publicreportWater1 *PublicreportWaterSetter, publicreportReport0 *PublicreportReport) (*PublicreportWater, error) {
|
|
publicreportWater1.ReportID = omit.From(publicreportReport0.ID)
|
|
|
|
ret, err := PublicreportWaters.Insert(publicreportWater1).One(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportWater0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportWater0(ctx context.Context, exec bob.Executor, count int, publicreportWater1 *PublicreportWater, publicreportReport0 *PublicreportReport) (*PublicreportWater, error) {
|
|
setter := &PublicreportWaterSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := publicreportWater1.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportWater0: %w", err)
|
|
}
|
|
|
|
return publicreportWater1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertWater(ctx context.Context, exec bob.Executor, related *PublicreportWaterSetter) error {
|
|
var err error
|
|
|
|
publicreportWater1, err := insertPublicreportReportWater0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Water = publicreportWater1
|
|
|
|
publicreportWater1.R.Report = publicreportReport0
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachWater(ctx context.Context, exec bob.Executor, publicreportWater1 *PublicreportWater) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportReportWater0(ctx, exec, 1, publicreportWater1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.Water = publicreportWater1
|
|
|
|
publicreportWater1.R.Report = publicreportReport0
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportReportReportTexts0(ctx context.Context, exec bob.Executor, reportTexts1 []*ReportTextSetter, publicreportReport0 *PublicreportReport) (ReportTextSlice, error) {
|
|
for i := range reportTexts1 {
|
|
reportTexts1[i].ReportID = omit.From(publicreportReport0.ID)
|
|
}
|
|
|
|
ret, err := ReportTexts.Insert(bob.ToMods(reportTexts1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportReportReportTexts0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportReportReportTexts0(ctx context.Context, exec bob.Executor, count int, reportTexts1 ReportTextSlice, publicreportReport0 *PublicreportReport) (ReportTextSlice, error) {
|
|
setter := &ReportTextSetter{
|
|
ReportID: omit.From(publicreportReport0.ID),
|
|
}
|
|
|
|
err := reportTexts1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportReportReportTexts0: %w", err)
|
|
}
|
|
|
|
return reportTexts1, nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) InsertReportTexts(ctx context.Context, exec bob.Executor, related ...*ReportTextSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
reportTexts1, err := insertPublicreportReportReportTexts0(ctx, exec, related, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReportTexts = append(publicreportReport0.R.ReportTexts, reportTexts1...)
|
|
|
|
for _, rel := range reportTexts1 {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportReport0 *PublicreportReport) AttachReportTexts(ctx context.Context, exec bob.Executor, related ...*ReportText) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
reportTexts1 := ReportTextSlice(related)
|
|
|
|
_, err = attachPublicreportReportReportTexts0(ctx, exec, len(related), reportTexts1, publicreportReport0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportReport0.R.ReportTexts = append(publicreportReport0.R.ReportTexts, reportTexts1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = publicreportReport0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type publicreportReportWhere[Q psql.Filterable] struct {
|
|
AddressRaw psql.WhereMod[Q, string]
|
|
AddressNumber psql.WhereMod[Q, string]
|
|
AddressStreet psql.WhereMod[Q, string]
|
|
AddressLocality psql.WhereMod[Q, string]
|
|
AddressRegion psql.WhereMod[Q, string]
|
|
AddressPostalCode psql.WhereMod[Q, string]
|
|
AddressCountry psql.WhereMod[Q, string]
|
|
AddressID psql.WhereNullMod[Q, int32]
|
|
Created psql.WhereMod[Q, time.Time]
|
|
Location psql.WhereNullMod[Q, string]
|
|
H3cell psql.WhereNullMod[Q, string]
|
|
ID psql.WhereMod[Q, int32]
|
|
LatlngAccuracyType psql.WhereMod[Q, enums.PublicreportAccuracytype]
|
|
LatlngAccuracyValue psql.WhereMod[Q, float32]
|
|
MapZoom psql.WhereMod[Q, float32]
|
|
OrganizationID psql.WhereMod[Q, int32]
|
|
PublicID psql.WhereMod[Q, string]
|
|
ReporterName psql.WhereMod[Q, string]
|
|
ReporterEmail psql.WhereMod[Q, string]
|
|
ReporterPhone psql.WhereMod[Q, string]
|
|
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
|
ReportType psql.WhereMod[Q, enums.PublicreportReporttype]
|
|
Reviewed psql.WhereNullMod[Q, time.Time]
|
|
ReviewerID psql.WhereNullMod[Q, int32]
|
|
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
|
LocationLatitude psql.WhereNullMod[Q, float64]
|
|
LocationLongitude psql.WhereNullMod[Q, float64]
|
|
}
|
|
|
|
func (publicreportReportWhere[Q]) AliasedAs(alias string) publicreportReportWhere[Q] {
|
|
return buildPublicreportReportWhere[Q](buildPublicreportReportColumns(alias))
|
|
}
|
|
|
|
func buildPublicreportReportWhere[Q psql.Filterable](cols publicreportReportColumns) publicreportReportWhere[Q] {
|
|
return publicreportReportWhere[Q]{
|
|
AddressRaw: psql.Where[Q, string](cols.AddressRaw),
|
|
AddressNumber: psql.Where[Q, string](cols.AddressNumber),
|
|
AddressStreet: psql.Where[Q, string](cols.AddressStreet),
|
|
AddressLocality: psql.Where[Q, string](cols.AddressLocality),
|
|
AddressRegion: psql.Where[Q, string](cols.AddressRegion),
|
|
AddressPostalCode: psql.Where[Q, string](cols.AddressPostalCode),
|
|
AddressCountry: psql.Where[Q, string](cols.AddressCountry),
|
|
AddressID: psql.WhereNull[Q, int32](cols.AddressID),
|
|
Created: psql.Where[Q, time.Time](cols.Created),
|
|
Location: psql.WhereNull[Q, string](cols.Location),
|
|
H3cell: psql.WhereNull[Q, string](cols.H3cell),
|
|
ID: psql.Where[Q, int32](cols.ID),
|
|
LatlngAccuracyType: psql.Where[Q, enums.PublicreportAccuracytype](cols.LatlngAccuracyType),
|
|
LatlngAccuracyValue: psql.Where[Q, float32](cols.LatlngAccuracyValue),
|
|
MapZoom: psql.Where[Q, float32](cols.MapZoom),
|
|
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
|
|
PublicID: psql.Where[Q, string](cols.PublicID),
|
|
ReporterName: psql.Where[Q, string](cols.ReporterName),
|
|
ReporterEmail: psql.Where[Q, string](cols.ReporterEmail),
|
|
ReporterPhone: psql.Where[Q, string](cols.ReporterPhone),
|
|
ReporterContactConsent: psql.WhereNull[Q, bool](cols.ReporterContactConsent),
|
|
ReportType: psql.Where[Q, enums.PublicreportReporttype](cols.ReportType),
|
|
Reviewed: psql.WhereNull[Q, time.Time](cols.Reviewed),
|
|
ReviewerID: psql.WhereNull[Q, int32](cols.ReviewerID),
|
|
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
|
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
|
|
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
|
|
}
|
|
}
|
|
|
|
func (o *PublicreportReport) Preload(name string, retrieved any) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
switch name {
|
|
case "TextJobs":
|
|
rels, ok := retrieved.(CommsTextJobSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.TextJobs = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
}
|
|
return nil
|
|
case "NotifyEmails":
|
|
rels, ok := retrieved.(PublicreportNotifyEmailSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.NotifyEmails = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
}
|
|
return nil
|
|
case "NotifyPhones":
|
|
rels, ok := retrieved.(PublicreportNotifyPhoneSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.NotifyPhones = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
}
|
|
return nil
|
|
case "Nuisance":
|
|
rel, ok := retrieved.(*PublicreportNuisance)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Nuisance = rel
|
|
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
return nil
|
|
case "Address":
|
|
rel, ok := retrieved.(*Address)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Address = rel
|
|
|
|
if rel != nil {
|
|
rel.R.Reports = PublicreportReportSlice{o}
|
|
}
|
|
return nil
|
|
case "Organization":
|
|
rel, ok := retrieved.(*Organization)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Organization = rel
|
|
|
|
if rel != nil {
|
|
rel.R.Reports = PublicreportReportSlice{o}
|
|
}
|
|
return nil
|
|
case "ReviewerUser":
|
|
rel, ok := retrieved.(*User)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerUser = rel
|
|
|
|
if rel != nil {
|
|
rel.R.ReviewerReports = PublicreportReportSlice{o}
|
|
}
|
|
return nil
|
|
case "Images":
|
|
rels, ok := retrieved.(PublicreportImageSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Images = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Reports = PublicreportReportSlice{o}
|
|
}
|
|
}
|
|
return nil
|
|
case "ReportLogs":
|
|
rels, ok := retrieved.(PublicreportReportLogSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReportLogs = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
}
|
|
return nil
|
|
case "Water":
|
|
rel, ok := retrieved.(*PublicreportWater)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Water = rel
|
|
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
return nil
|
|
case "ReportTexts":
|
|
rels, ok := retrieved.(ReportTextSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReportTexts = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.Report = o
|
|
}
|
|
}
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("publicreportReport has no relationship %q", name)
|
|
}
|
|
}
|
|
|
|
type publicreportReportPreloader struct {
|
|
Nuisance func(...psql.PreloadOption) psql.Preloader
|
|
Address func(...psql.PreloadOption) psql.Preloader
|
|
Organization func(...psql.PreloadOption) psql.Preloader
|
|
ReviewerUser func(...psql.PreloadOption) psql.Preloader
|
|
Water func(...psql.PreloadOption) psql.Preloader
|
|
}
|
|
|
|
func buildPublicreportReportPreloader() publicreportReportPreloader {
|
|
return publicreportReportPreloader{
|
|
Nuisance: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*PublicreportNuisance, PublicreportNuisanceSlice](psql.PreloadRel{
|
|
Name: "Nuisance",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportReports,
|
|
To: PublicreportNuisances,
|
|
FromColumns: []string{"id"},
|
|
ToColumns: []string{"report_id"},
|
|
},
|
|
},
|
|
}, PublicreportNuisances.Columns.Names(), opts...)
|
|
},
|
|
Address: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Address, AddressSlice](psql.PreloadRel{
|
|
Name: "Address",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportReports,
|
|
To: Addresses,
|
|
FromColumns: []string{"address_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Addresses.Columns.Names(), opts...)
|
|
},
|
|
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
|
Name: "Organization",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportReports,
|
|
To: Organizations,
|
|
FromColumns: []string{"organization_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Organizations.Columns.Names(), opts...)
|
|
},
|
|
ReviewerUser: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*User, UserSlice](psql.PreloadRel{
|
|
Name: "ReviewerUser",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportReports,
|
|
To: Users,
|
|
FromColumns: []string{"reviewer_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Users.Columns.Names(), opts...)
|
|
},
|
|
Water: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*PublicreportWater, PublicreportWaterSlice](psql.PreloadRel{
|
|
Name: "Water",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportReports,
|
|
To: PublicreportWaters,
|
|
FromColumns: []string{"id"},
|
|
ToColumns: []string{"report_id"},
|
|
},
|
|
},
|
|
}, PublicreportWaters.Columns.Names(), opts...)
|
|
},
|
|
}
|
|
}
|
|
|
|
type publicreportReportThenLoader[Q orm.Loadable] struct {
|
|
TextJobs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
NotifyEmails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
NotifyPhones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Nuisance func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Address func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Water func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
}
|
|
|
|
func buildPublicreportReportThenLoader[Q orm.Loadable]() publicreportReportThenLoader[Q] {
|
|
type TextJobsLoadInterface interface {
|
|
LoadTextJobs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type NotifyEmailsLoadInterface interface {
|
|
LoadNotifyEmails(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type NotifyPhonesLoadInterface interface {
|
|
LoadNotifyPhones(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type NuisanceLoadInterface interface {
|
|
LoadNuisance(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type AddressLoadInterface interface {
|
|
LoadAddress(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type OrganizationLoadInterface interface {
|
|
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerUserLoadInterface interface {
|
|
LoadReviewerUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ImagesLoadInterface interface {
|
|
LoadImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReportLogsLoadInterface interface {
|
|
LoadReportLogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type WaterLoadInterface interface {
|
|
LoadWater(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReportTextsLoadInterface interface {
|
|
LoadReportTexts(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
|
|
return publicreportReportThenLoader[Q]{
|
|
TextJobs: thenLoadBuilder[Q](
|
|
"TextJobs",
|
|
func(ctx context.Context, exec bob.Executor, retrieved TextJobsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadTextJobs(ctx, exec, mods...)
|
|
},
|
|
),
|
|
NotifyEmails: thenLoadBuilder[Q](
|
|
"NotifyEmails",
|
|
func(ctx context.Context, exec bob.Executor, retrieved NotifyEmailsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadNotifyEmails(ctx, exec, mods...)
|
|
},
|
|
),
|
|
NotifyPhones: thenLoadBuilder[Q](
|
|
"NotifyPhones",
|
|
func(ctx context.Context, exec bob.Executor, retrieved NotifyPhonesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadNotifyPhones(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Nuisance: thenLoadBuilder[Q](
|
|
"Nuisance",
|
|
func(ctx context.Context, exec bob.Executor, retrieved NuisanceLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadNuisance(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Address: thenLoadBuilder[Q](
|
|
"Address",
|
|
func(ctx context.Context, exec bob.Executor, retrieved AddressLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadAddress(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Organization: thenLoadBuilder[Q](
|
|
"Organization",
|
|
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadOrganization(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReviewerUser: thenLoadBuilder[Q](
|
|
"ReviewerUser",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerUser(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Images: thenLoadBuilder[Q](
|
|
"Images",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadImages(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReportLogs: thenLoadBuilder[Q](
|
|
"ReportLogs",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReportLogsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReportLogs(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Water: thenLoadBuilder[Q](
|
|
"Water",
|
|
func(ctx context.Context, exec bob.Executor, retrieved WaterLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadWater(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReportTexts: thenLoadBuilder[Q](
|
|
"ReportTexts",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReportTextsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReportTexts(ctx, exec, mods...)
|
|
},
|
|
),
|
|
}
|
|
}
|
|
|
|
// LoadTextJobs loads the publicreportReport's TextJobs into the .R struct
|
|
func (o *PublicreportReport) LoadTextJobs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.TextJobs = nil
|
|
|
|
related, err := o.TextJobs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = o
|
|
}
|
|
|
|
o.R.TextJobs = related
|
|
return nil
|
|
}
|
|
|
|
// LoadTextJobs loads the publicreportReport's TextJobs into the .R struct
|
|
func (os PublicreportReportSlice) LoadTextJobs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
commsTextJobs, err := os.TextJobs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.TextJobs = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range commsTextJobs {
|
|
|
|
if !rel.ReportID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.ReportID.IsValue() && o.ID == rel.ReportID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.TextJobs = append(o.R.TextJobs, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadNotifyEmails loads the publicreportReport's NotifyEmails into the .R struct
|
|
func (o *PublicreportReport) LoadNotifyEmails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.NotifyEmails = nil
|
|
|
|
related, err := o.NotifyEmails(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = o
|
|
}
|
|
|
|
o.R.NotifyEmails = related
|
|
return nil
|
|
}
|
|
|
|
// LoadNotifyEmails loads the publicreportReport's NotifyEmails into the .R struct
|
|
func (os PublicreportReportSlice) LoadNotifyEmails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNotifyEmails, err := os.NotifyEmails(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.NotifyEmails = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNotifyEmails {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.NotifyEmails = append(o.R.NotifyEmails, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadNotifyPhones loads the publicreportReport's NotifyPhones into the .R struct
|
|
func (o *PublicreportReport) LoadNotifyPhones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.NotifyPhones = nil
|
|
|
|
related, err := o.NotifyPhones(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = o
|
|
}
|
|
|
|
o.R.NotifyPhones = related
|
|
return nil
|
|
}
|
|
|
|
// LoadNotifyPhones loads the publicreportReport's NotifyPhones into the .R struct
|
|
func (os PublicreportReportSlice) LoadNotifyPhones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNotifyPhones, err := os.NotifyPhones(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.NotifyPhones = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNotifyPhones {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.NotifyPhones = append(o.R.NotifyPhones, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadNuisance loads the publicreportReport's Nuisance into the .R struct
|
|
func (o *PublicreportReport) LoadNuisance(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Nuisance = nil
|
|
|
|
related, err := o.Nuisance(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.Report = o
|
|
|
|
o.R.Nuisance = related
|
|
return nil
|
|
}
|
|
|
|
// LoadNuisance loads the publicreportReport's Nuisance into the .R struct
|
|
func (os PublicreportReportSlice) LoadNuisance(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNuisances, err := os.Nuisance(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNuisances {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.Nuisance = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadAddress loads the publicreportReport's Address into the .R struct
|
|
func (o *PublicreportReport) LoadAddress(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Address = nil
|
|
|
|
related, err := o.Address(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.Reports = PublicreportReportSlice{o}
|
|
|
|
o.R.Address = related
|
|
return nil
|
|
}
|
|
|
|
// LoadAddress loads the publicreportReport's Address into the .R struct
|
|
func (os PublicreportReportSlice) LoadAddress(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
addresses, err := os.Address(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range addresses {
|
|
if !o.AddressID.IsValue() {
|
|
continue
|
|
}
|
|
|
|
if !(o.AddressID.IsValue() && o.AddressID.MustGet() == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Reports = append(rel.R.Reports, o)
|
|
|
|
o.R.Address = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the publicreportReport's Organization into the .R struct
|
|
func (o *PublicreportReport) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Organization = nil
|
|
|
|
related, err := o.Organization(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.Reports = PublicreportReportSlice{o}
|
|
|
|
o.R.Organization = related
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the publicreportReport's Organization into the .R struct
|
|
func (os PublicreportReportSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
organizations, err := os.Organization(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range organizations {
|
|
|
|
if !(o.OrganizationID == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Reports = append(rel.R.Reports, o)
|
|
|
|
o.R.Organization = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerUser loads the publicreportReport's ReviewerUser into the .R struct
|
|
func (o *PublicreportReport) LoadReviewerUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerUser = nil
|
|
|
|
related, err := o.ReviewerUser(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.ReviewerReports = PublicreportReportSlice{o}
|
|
|
|
o.R.ReviewerUser = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerUser loads the publicreportReport's ReviewerUser into the .R struct
|
|
func (os PublicreportReportSlice) LoadReviewerUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
users, err := os.ReviewerUser(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range users {
|
|
if !o.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
|
|
if !(o.ReviewerID.IsValue() && o.ReviewerID.MustGet() == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerReports = append(rel.R.ReviewerReports, o)
|
|
|
|
o.R.ReviewerUser = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadImages loads the publicreportReport's Images into the .R struct
|
|
func (o *PublicreportReport) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Images = nil
|
|
|
|
related, err := o.Images(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Reports = PublicreportReportSlice{o}
|
|
}
|
|
|
|
o.R.Images = related
|
|
return nil
|
|
}
|
|
|
|
// LoadImages loads the publicreportReport's Images into the .R struct
|
|
func (os PublicreportReportSlice) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
// since we are changing the columns, we need to check if the original columns were set or add the defaults
|
|
sq := dialect.SelectQuery{}
|
|
for _, mod := range mods {
|
|
mod.Apply(&sq)
|
|
}
|
|
|
|
if len(sq.SelectList.Columns) == 0 {
|
|
mods = append(mods, sm.Columns(PublicreportImages.Columns))
|
|
}
|
|
|
|
q := os.Images(append(
|
|
mods,
|
|
sm.Columns(PublicreportReportImages.Columns.ReportID.As("related_publicreport.report.ID")),
|
|
)...)
|
|
|
|
IDSlice := []int32{}
|
|
|
|
mapper := scan.Mod(scan.StructMapper[*PublicreportImage](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
|
|
return func(row *scan.Row) (any, error) {
|
|
IDSlice = append(IDSlice, *new(int32))
|
|
row.ScheduleScanByName("related_publicreport.report.ID", &IDSlice[len(IDSlice)-1])
|
|
|
|
return nil, nil
|
|
},
|
|
func(any, any) error {
|
|
return nil
|
|
}
|
|
})
|
|
|
|
publicreportImages, err := bob.Allx[bob.SliceTransformer[*PublicreportImage, PublicreportImageSlice]](ctx, exec, q, mapper)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
o.R.Images = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
for i, rel := range publicreportImages {
|
|
if !(o.ID == IDSlice[i]) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Reports = append(rel.R.Reports, o)
|
|
|
|
o.R.Images = append(o.R.Images, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReportLogs loads the publicreportReport's ReportLogs into the .R struct
|
|
func (o *PublicreportReport) LoadReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReportLogs = nil
|
|
|
|
related, err := o.ReportLogs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = o
|
|
}
|
|
|
|
o.R.ReportLogs = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReportLogs loads the publicreportReport's ReportLogs into the .R struct
|
|
func (os PublicreportReportSlice) LoadReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportReportLogs, err := os.ReportLogs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReportLogs = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportReportLogs {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.ReportLogs = append(o.R.ReportLogs, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadWater loads the publicreportReport's Water into the .R struct
|
|
func (o *PublicreportReport) LoadWater(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Water = nil
|
|
|
|
related, err := o.Water(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.Report = o
|
|
|
|
o.R.Water = related
|
|
return nil
|
|
}
|
|
|
|
// LoadWater loads the publicreportReport's Water into the .R struct
|
|
func (os PublicreportReportSlice) LoadWater(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportWaters, err := os.Water(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportWaters {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.Water = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReportTexts loads the publicreportReport's ReportTexts into the .R struct
|
|
func (o *PublicreportReport) LoadReportTexts(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReportTexts = nil
|
|
|
|
related, err := o.ReportTexts(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.Report = o
|
|
}
|
|
|
|
o.R.ReportTexts = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReportTexts loads the publicreportReport's ReportTexts into the .R struct
|
|
func (os PublicreportReportSlice) LoadReportTexts(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
reportTexts, err := os.ReportTexts(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReportTexts = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range reportTexts {
|
|
|
|
if !(o.ID == rel.ReportID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.Report = o
|
|
|
|
o.R.ReportTexts = append(o.R.ReportTexts, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|