57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package publicreport
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
|
//"github.com/Gleipnir-Technology/nidus-sync/config"
|
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
|
//"github.com/google/uuid"
|
|
//"github.com/rs/zerolog/log"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
func compliance(ctx context.Context, public_id string, report *types.PublicReport) (*types.PublicReportCompliance, error) {
|
|
row, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select(
|
|
sm.Columns(
|
|
"access_instructions",
|
|
"availability_notes",
|
|
"comments",
|
|
"gate_code",
|
|
"has_dog",
|
|
"permission_type",
|
|
"report_id",
|
|
"report_phone_can_text",
|
|
"wants_scheduled",
|
|
),
|
|
sm.From("publicreport.compliance"),
|
|
sm.Where(psql.Quote("report_id").EQ(
|
|
psql.Arg(report.ID),
|
|
)),
|
|
), scan.StructMapper[types.PublicReportCompliance]())
|
|
if err != nil {
|
|
return nil, fmt.Errorf("query compliance: %w", err)
|
|
}
|
|
copyReportContent(report, &row.PublicReport)
|
|
return &row, nil
|
|
|
|
}
|
|
func copyReportContent(src *types.PublicReport, dst *types.PublicReport) {
|
|
dst.Address = src.Address
|
|
dst.Created = src.Created
|
|
dst.ID = src.ID
|
|
dst.Images = src.Images
|
|
dst.Location = src.Location
|
|
dst.Log = src.Log
|
|
dst.DistrictID = src.DistrictID
|
|
dst.District = src.District
|
|
dst.PublicID = src.PublicID
|
|
dst.Reporter = src.Reporter
|
|
dst.Status = src.Status
|
|
dst.Type = src.Type
|
|
dst.URI = src.URI
|
|
}
|