thing

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package thing provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.

Package thing provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.

Index

Constants

View Source
const (
	FieldCannotBeEmpty           = "field %s cannot be empty or contain only spaces"
	FieldMinLengthIsN            = "field %s minimum length is %d"
	FoundNum                     = ", found %d"
	FunctionNReturnedNoResults   = "%s returned no results "
	OnlyAdminCanManageTypeThings = "only admin user can manage type thing"
	SelectFailedInNWithErrorE    = "pgxscan.Select unexpectedly failed in %s, error : %v"
)
View Source
const (
	JWTAuthScopes = "JWTAuth.Scopes"
)
View Source
const (
	MinNameLength = 5
)

Variables

This section is empty.

Functions

func GetJwtCustomClaims added in v0.0.6

func GetJwtCustomClaims(ctx echo.Context) (goserver.JwtCustomClaims, error)

GetJwtCustomClaims returns the JWT Custom claims from the received context jwtdata

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type CountParams

type CountParams struct {
	// text keywords to filter the things to return
	Keywords *string `form:"keywords,omitempty" json:"keywords,omitempty"`

	// TypeThing id to filter by the things to return
	Type *int32 `form:"type,omitempty" json:"type,omitempty"`

	// id of the creator to filter by the things to return
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// inactivated flag to filter the things to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`

	// validation flag to filter the things to return
	Validated *bool `form:"validated,omitempty" json:"validated,omitempty"`
}

CountParams defines parameters for Count.

type CreateJSONBody

type CreateJSONBody = Thing

CreateJSONBody defines parameters for Create.

type CreateJSONRequestBody

type CreateJSONRequestBody = CreateJSONBody

CreateJSONRequestBody defines body for Create for application/json ContentType.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

Error defines model for Error.

type Feature added in v0.0.6

type Feature struct {
	// GeoJSon geometry collection
	Geometry   GeometryCollection      `json:"geometry"`
	Id         *interface{}            `json:"id,omitempty"`
	Properties *map[string]interface{} `json:"properties,omitempty"`
	Type       FeatureType             `json:"type"`
}

GeoJSon Feature

type FeatureCollection added in v0.0.6

type FeatureCollection struct {
	Features []Feature             `json:"features"`
	Type     FeatureCollectionType `json:"type"`
}

GeoJSon Feature collection

type FeatureCollectionType added in v0.0.6

type FeatureCollectionType string

FeatureCollectionType defines model for FeatureCollection.Type.

const (
	FeatureCollectionTypeFeatureCollection FeatureCollectionType = "FeatureCollection"
)

Defines values for FeatureCollectionType.

type FeatureType added in v0.0.6

type FeatureType string

FeatureType defines model for Feature.Type.

const (
	FeatureTypeFeature FeatureType = "Feature"
)

Defines values for FeatureType.

type GeoJsonParams added in v0.0.6

type GeoJsonParams struct {
	// TypeThing id to filter by the things to return
	Type *int32 `form:"type,omitempty" json:"type,omitempty"`

	// id of the creator to filter by the things to return
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// inactivated flag to filter the things to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`

	// validation flag to filter the things to return
	Validated *bool `form:"validated,omitempty" json:"validated,omitempty"`

	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`

	// offset rows to skip before returning rows
	Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"`
}

GeoJsonParams defines parameters for GeoJson.

type Geometry added in v0.0.6

type Geometry struct {
	// the geometry type
	Type interface{} `json:"type"`
}

GeoJSon geometry

type GeometryCollection added in v0.0.6

type GeometryCollection struct {
	Geometries []Geometry             `json:"geometries"`
	Type       GeometryCollectionType `json:"type"`
}

GeoJSon geometry collection

type GeometryCollectionType added in v0.0.6

type GeometryCollectionType string

GeometryCollectionType defines model for GeometryCollection.Type.

const (
	GeometryCollectionTypeGeometryCollection GeometryCollectionType = "GeometryCollection"
)

Defines values for GeometryCollectionType.

type LineString added in v0.0.6

type LineString struct {
	Coordinates *[]Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

LineString defines model for LineString.

type ListByExternalIdParams

type ListByExternalIdParams struct {
	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`

	// offset rows to skip before returning rows
	Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"`
}

ListByExternalIdParams defines parameters for ListByExternalId.

type ListParams

type ListParams struct {
	// TypeThing id to filter by the things to return
	Type *int32 `form:"type,omitempty" json:"type,omitempty"`

	// id of the creator to filter by the things to return
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// inactivated flag to filter the things to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`

	// validation flag to filter the things to return
	Validated *bool `form:"validated,omitempty" json:"validated,omitempty"`

	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`

	// offset rows to skip before returning rows
	Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"`
}

ListParams defines parameters for List.

type MultiLineString added in v0.0.6

type MultiLineString struct {
	Coordinates *[][]Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

MultiLineString defines model for MultiLineString.

type MultiPoint added in v0.0.6

type MultiPoint struct {
	Coordinates *[]Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

MultiPoint defines model for MultiPoint.

type MultiPolygon added in v0.0.6

type MultiPolygon struct {
	Coordinates *[][][]Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

MultiPolygon defines model for MultiPolygon.

type PGX

type PGX struct {
	Conn *pgxpool.Pool
	// contains filtered or unexported fields
}

func (*PGX) Count

func (db *PGX) Count(params CountParams) (int32, error)

Count returns the number of thing stored in DB

func (*PGX) CountTypeThing

func (db *PGX) CountTypeThing(params TypeThingCountParams) (int32, error)

CountTypeThing returns the number of TypeThing based on search criteria

func (*PGX) Create

func (db *PGX) Create(t Thing) (*Thing, error)

Create will store the new Thing in the database

func (*PGX) CreateTypeThing

func (db *PGX) CreateTypeThing(tt TypeThing) (*TypeThing, error)

CreateTypeThing will store the new TypeThing in the database

func (*PGX) Delete

func (db *PGX) Delete(id uuid.UUID, userId int32) error

Delete the thing stored in DB with given id

func (*PGX) DeleteTypeThing

func (db *PGX) DeleteTypeThing(id int32, userId int32) error

DeleteTypeThing deletes the TypeThing stored in DB with given id

func (*PGX) Exist

func (db *PGX) Exist(id uuid.UUID) bool

Exist returns true only if a thing with the specified id exists in store.

func (*PGX) GeoJson added in v0.0.6

func (db *PGX) GeoJson(offset, limit int, params GeoJsonParams) (string, error)

func (*PGX) Get

func (db *PGX) Get(id uuid.UUID) (*Thing, error)

Get will retrieve the thing with given id

func (*PGX) GetTypeThing

func (db *PGX) GetTypeThing(id int32) (*TypeThing, error)

GetTypeThing will retrieve the TypeThing with given id

func (*PGX) GetTypeThingMaxId

func (db *PGX) GetTypeThingMaxId(id int32) (int32, error)

GetTypeThingMaxId will retrieve maximum value of TypeThing id existing in store.

func (*PGX) IsThingActive

func (db *PGX) IsThingActive(id uuid.UUID) bool

IsThingActive returns true if the thing with the specified id has the inactivated attribute set to false

func (*PGX) IsUserOwner

func (db *PGX) IsUserOwner(id uuid.UUID, userId int32) bool

IsUserOwner returns true only if userId is the creator of the record (owner) of this thing in store.

func (*PGX) List

func (db *PGX) List(offset, limit int, params ListParams) ([]*ThingList, error)

List returns the list of existing things with the given offset and limit.

func (*PGX) ListByExternalId

func (db *PGX) ListByExternalId(offset, limit int, externalId int) ([]*ThingList, error)

ListByExternalId returns the list of existing things having given externalId with the given offset and limit.

func (*PGX) ListTypeThing

func (db *PGX) ListTypeThing(offset, limit int, params TypeThingListParams) ([]*TypeThingList, error)

ListTypeThing returns the list of existing TypeThing with the given offset and limit.

func (*PGX) Search

func (db *PGX) Search(offset, limit int, params SearchParams) ([]*ThingList, error)

func (*PGX) Update

func (db *PGX) Update(id uuid.UUID, t Thing) (*Thing, error)

Update the thing stored in DB with given id and other information in struct

func (*PGX) UpdateTypeThing

func (db *PGX) UpdateTypeThing(id int32, tt TypeThing) (*TypeThing, error)

UpdateTypeThing updates the TypeThing stored in DB with given id and other information in struct

type Permission

type Permission int8 // enum
const (
	R Permission = iota // Read implies List (SELECT in DB, or GET in API)
	W                   // implies INSERT,UPDATE, DELETE
	M                   // Update or Put only
	D                   // Delete only
	C                   // Create only (Insert, Post)
	P                   // change Permissions of one thing
	O                   // change Owner of one Thing
	A                   // Audit log of changes of one thing and read only special _fields like _created_by
)

func (Permission) String

func (s Permission) String() string

type Point added in v0.0.6

type Point struct {
	// Point in 3D space
	Coordinates *Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

Point defines model for Point.

type Point3D added in v0.0.6

type Point3D = []float32

Point in 3D space

type Polygon added in v0.0.6

type Polygon struct {
	Coordinates *[][]Point3D `json:"coordinates,omitempty"`

	// the geometry type
	Type interface{} `json:"type"`
}

Polygon defines model for Polygon.

type SearchParams

type SearchParams struct {
	// text keywords to filter the things to return
	Keywords *string `form:"keywords,omitempty" json:"keywords,omitempty"`

	// TypeThing id to filter by the things to return
	Type *int32 `form:"type,omitempty" json:"type,omitempty"`

	// id of the creator to filter by the things to return
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// inactivated flag to filter the things to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`

	// validation flag to filter the things to return
	Validated *bool `form:"validated,omitempty" json:"validated,omitempty"`

	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`

	// offset rows to skip before returning rows
	Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"`
}

SearchParams defines parameters for Search.

type ServerInterface

type ServerInterface interface {
	// List returns a list of thing
	// (GET /thing)
	List(ctx echo.Context, params ListParams) error
	// Create will create a new thing
	// (POST /thing)
	Create(ctx echo.Context) error
	// ListByExternalId returns a list of thing filtered by externalId
	// (GET /thing/by-external-id/{externalId})
	ListByExternalId(ctx echo.Context, externalId int32, params ListByExternalIdParams) error
	// Count returns the number of thing based on search criterias
	// (GET /thing/count)
	Count(ctx echo.Context, params CountParams) error
	// List returns a geoJson of things found
	// (GET /thing/geojson)
	GeoJson(ctx echo.Context, params GeoJsonParams) error
	// Search returns a list of thing based on search criterias
	// (GET /thing/search)
	Search(ctx echo.Context, params SearchParams) error
	// Delete allows to delete a specific thingId
	// (DELETE /thing/{thingId})
	Delete(ctx echo.Context, thingId openapi_types.UUID) error
	// Get will retrieve in backend all information about a specific thingId
	// (GET /thing/{thingId})
	Get(ctx echo.Context, thingId openapi_types.UUID) error
	// Update allows to modify information about a specific thingId
	// (PUT /thing/{thingId})
	Update(ctx echo.Context, thingId openapi_types.UUID) error
	// TypeThingList returns a list of types
	// (GET /types)
	TypeThingList(ctx echo.Context, params TypeThingListParams) error
	// TypeThingCreate will create a new group
	// (POST /types)
	TypeThingCreate(ctx echo.Context) error
	// Count returns the number of TypeThing based on search criterias
	// (GET /types/count)
	TypeThingCount(ctx echo.Context, params TypeThingCountParams) error
	// TypeThingDelete allows to delete a specific typeThingId
	// (DELETE /types/{typeThingId})
	TypeThingDelete(ctx echo.Context, typeThingId int32) error
	// TypeThingGet will retrieve in backend all information about a specific typeThingId
	// (GET /types/{typeThingId})
	TypeThingGet(ctx echo.Context, typeThingId int32) error
	// TypeThingUpdate allows to modify information about a specific typeThingId
	// (PUT /types/{typeThingId})
	TypeThingUpdate(ctx echo.Context, typeThingId int32) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) Count

func (w *ServerInterfaceWrapper) Count(ctx echo.Context) error

Count converts echo context to params.

func (*ServerInterfaceWrapper) Create

func (w *ServerInterfaceWrapper) Create(ctx echo.Context) error

Create converts echo context to params.

func (*ServerInterfaceWrapper) Delete

func (w *ServerInterfaceWrapper) Delete(ctx echo.Context) error

Delete converts echo context to params.

func (*ServerInterfaceWrapper) GeoJson added in v0.0.6

func (w *ServerInterfaceWrapper) GeoJson(ctx echo.Context) error

GeoJson converts echo context to params.

func (*ServerInterfaceWrapper) Get

func (w *ServerInterfaceWrapper) Get(ctx echo.Context) error

Get converts echo context to params.

func (*ServerInterfaceWrapper) List

func (w *ServerInterfaceWrapper) List(ctx echo.Context) error

List converts echo context to params.

func (*ServerInterfaceWrapper) ListByExternalId

func (w *ServerInterfaceWrapper) ListByExternalId(ctx echo.Context) error

ListByExternalId converts echo context to params.

func (*ServerInterfaceWrapper) Search

func (w *ServerInterfaceWrapper) Search(ctx echo.Context) error

Search converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingCount

func (w *ServerInterfaceWrapper) TypeThingCount(ctx echo.Context) error

TypeThingCount converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingCreate

func (w *ServerInterfaceWrapper) TypeThingCreate(ctx echo.Context) error

TypeThingCreate converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingDelete

func (w *ServerInterfaceWrapper) TypeThingDelete(ctx echo.Context) error

TypeThingDelete converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingGet

func (w *ServerInterfaceWrapper) TypeThingGet(ctx echo.Context) error

TypeThingGet converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingList

func (w *ServerInterfaceWrapper) TypeThingList(ctx echo.Context) error

TypeThingList converts echo context to params.

func (*ServerInterfaceWrapper) TypeThingUpdate

func (w *ServerInterfaceWrapper) TypeThingUpdate(ctx echo.Context) error

TypeThingUpdate converts echo context to params.

func (*ServerInterfaceWrapper) Update

func (w *ServerInterfaceWrapper) Update(ctx echo.Context) error

Update converts echo context to params.

type Service

type Service struct {
	Log              golog.MyLogger
	DbConn           database.DB
	Store            Storage
	JwtSecret        []byte
	JwtDuration      int
	ListDefaultLimit int
}

func (Service) Count

func (s Service) Count(ctx echo.Context, params CountParams) error

Count returns the number of things found after filtering data with any given CountParams curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing/count' |jq

func (Service) Create

func (s Service) Create(ctx echo.Context) error

Create allows to insert a new thing curl -s -XPOST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"id": "3999971f-53d7-4eb6-8898-97f257ea5f27","type_id": 3,"name": "Gil-Parcelle","description": "just a nice parcelle test","external_id": 345678912,"inactivated": false,"managed_by": 999, "more_data": NULL,"pos_x":2537603.0 ,"pos_y":1152613.0 }' 'http://localhost:9090/goapi/v1/thing'

func (Service) Delete

func (s Service) Delete(ctx echo.Context, thingId uuid.UUID) error

Delete will remove the given thingId entry from the store, and if not present will return 400 Bad Request curl -v -XDELETE -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/users/3' -> 204 No Content if present and delete it curl -v -XDELETE -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/users/93333' -> 400 Bad Request

func (Service) GeoJson added in v0.0.6

func (s Service) GeoJson(ctx echo.Context, params GeoJsonParams) error

func (Service) Get

func (s Service) Get(ctx echo.Context, thingId uuid.UUID) error

Get will retrieve the Thing with the given id in the store and return it curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing/9999971f-53d7-4eb6-8898-97f257ea5f27' |jq

func (Service) List

func (s Service) List(ctx echo.Context, params ListParams) error

List sends a list of things in the store based on the given parameters filters curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing?limit=3&ofset=0' |jq curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing?limit=3&type=112' |jq

func (Service) ListByExternalId

func (s Service) ListByExternalId(ctx echo.Context, externalId int32, params ListByExternalIdParams) error

ListByExternalId sends a list of things in the store as json based of the given filters curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing/by-external-id/345678912?limit=3&ofset=0' |jq

func (Service) Search

func (s Service) Search(ctx echo.Context, params SearchParams) error

Search returns a list of things in the store as json based of the given search criteria curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing/search?limit=3&ofset=0' |jq curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" 'http://localhost:9090/goapi/v1/thing/search?limit=3&type=112' |jq

func (Service) TypeThingCount

func (s Service) TypeThingCount(ctx echo.Context, params TypeThingCountParams) error

func (Service) TypeThingCreate

func (s Service) TypeThingCreate(ctx echo.Context) error

TypeThingCreate will insert a new TypeThing in the store

func (Service) TypeThingDelete

func (s Service) TypeThingDelete(ctx echo.Context, typeThingId int32) error

TypeThingDelete will remove the given TypeThing entry from the store, and if not present will return 400 Bad Request

func (Service) TypeThingGet

func (s Service) TypeThingGet(ctx echo.Context, typeThingId int32) error

TypeThingGet will retrieve the Thing with the given id in the store and return it

func (Service) TypeThingList

func (s Service) TypeThingList(ctx echo.Context, params TypeThingListParams) error

TypeThingList sends a list of TypeThing based on the given TypeThingListParams parameters filters

func (Service) TypeThingUpdate

func (s Service) TypeThingUpdate(ctx echo.Context, typeThingId int32) error

func (Service) Update

func (s Service) Update(ctx echo.Context, thingId uuid.UUID) error

Update will change the attributes values for the thing identified by the given thingId curl -s -XPUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"id": "3999971f-53d7-4eb6-8898-97f257ea5f27","type_id": 3,"name": "Gil-Parcelle","description": "just a nice parcelle test by GIL","external_id": 345678912,"inactivated": false,"managed_by": 999, "more_data": {"info_value": 3230 },"pos_x":2537603.0 ,"pos_y":1152613.0 }' 'http://localhost:9090/goapi/v1/thing/3999971f-53d7-4eb6-8898-97f257ea5f27' |jq

type Storage

type Storage interface {
	// GeoJson returns a geoJson of existing things with the given offset and limit.
	GeoJson(offset, limit int, params GeoJsonParams) (string, error)
	// List returns the list of existing things with the given offset and limit.
	List(offset, limit int, params ListParams) ([]*ThingList, error)
	// ListByExternalId returns the list of existing things having the given externalId with the given offset and limit.
	ListByExternalId(offset, limit int, externalId int) ([]*ThingList, error)
	// Search returns the list of existing things filtered by search params with the given offset and limit.
	Search(offset, limit int, params SearchParams) ([]*ThingList, error)
	// Get returns the thing with the specified things ID.
	Get(id uuid.UUID) (*Thing, error)
	// Exist returns true only if a things with the specified id exists in store.
	Exist(id uuid.UUID) bool
	// Count returns the total number of things.
	Count(params CountParams) (int32, error)
	// Create saves a new things in the storage.
	Create(thing Thing) (*Thing, error)
	// Update updates the things with given ID in the storage.
	Update(id uuid.UUID, thing Thing) (*Thing, error)
	// Delete removes the things with given ID from the storage.
	Delete(id uuid.UUID, userId int32) error
	// IsThingActive returns true if the thing with the specified id has the inactivated attribute set to false
	IsThingActive(id uuid.UUID) bool
	// IsUserOwner returns true only if userId is the creator of the record (owner) of this thing in store.
	IsUserOwner(id uuid.UUID, userId int32) bool
	// CreateTypeThing saves a new typeThing in the storage.
	CreateTypeThing(typeThing TypeThing) (*TypeThing, error)
	// UpdateTypeThing updates the typeThing with given ID in the storage.
	UpdateTypeThing(id int32, typeThing TypeThing) (*TypeThing, error)
	// DeleteTypeThing removes the typeThing with given ID from the storage.
	DeleteTypeThing(id int32, userId int32) error
	// ListTypeThing returns the list of active typeThings with the given offset and limit.
	ListTypeThing(offset, limit int, params TypeThingListParams) ([]*TypeThingList, error)
	// GetTypeThing returns the typeThing with the specified things ID.
	GetTypeThing(id int32) (*TypeThing, error)
	// CountTypeThing returns the number of TypeThing based on search criteria
	CountTypeThing(params TypeThingCountParams) (int32, error)
}

Storage is an interface to different implementation of persistence for Things/TypeThing

func GetStorageInstance

func GetStorageInstance(dbDriver string, db database.DB, l golog.MyLogger) (Storage, error)

func NewPgxDB

func NewPgxDB(db database.DB, log golog.MyLogger) (Storage, error)

NewPgxDB will instantiate a new storage of type postgres and ensure schema exist

type Thing

type Thing struct {
	BuildAt        *time.Time `json:"build_at,omitempty"`
	Comment        *string    `json:"comment,omitempty"`
	ContainedBy    *string    `json:"contained_by,omitempty"`
	ContainedByOld *int32     `json:"contained_by_old,omitempty"`

	// date de création de cet enregistrement dans la base
	CreatedAt *time.Time `json:"created_at,omitempty"`

	// identifiant de l'utilisateur ayant créé cet enregistrement
	CreatedBy int32 `json:"created_by"`

	// cet enregisrement a été marqué comme effacé
	Deleted bool `json:"deleted"`

	// date à laquelle cet enregisrement a été marqué comme effacé
	DeletedAt *time.Time `json:"deleted_at,omitempty"`

	// utilisateur ayant demandé de marquer cet enregisrement comme effacé
	DeletedBy   *int32  `json:"deleted_by,omitempty"`
	Description *string `json:"description,omitempty"`
	ExternalId  *int32  `json:"external_id,omitempty"`
	ExternalRef *string `json:"external_ref,omitempty"`

	// cet Universally unique identifier (UUID) sera généré automatiquement pour vous
	Id                openapi_types.UUID `json:"id"`
	Inactivated       bool               `json:"inactivated"`
	InactivatedBy     *int32             `json:"inactivated_by,omitempty"`
	InactivatedReason *string            `json:"inactivated_reason,omitempty"`
	InactivatedTime   *time.Time         `json:"inactivated_time,omitempty"`

	// date de la dernière modication de cet enregistrement
	LastModifiedAt *time.Time `json:"last_modified_at,omitempty"`

	// utilisateur ayant effectué la dernière modication de cet enregistrement
	LastModifiedBy *int32 `json:"last_modified_by,omitempty"`
	ManagedBy      *int32 `json:"managed_by,omitempty"`

	// permet de stocker des attributs complémentaires au format json
	MoreData *map[string]interface{} `json:"more_data,omitempty"`
	Name     string                  `json:"name"`
	PosX     float64                 `json:"pos_x"`
	PosY     float64                 `json:"pos_y"`
	Status   *ThingStatus            `json:"status,omitempty"`

	// FK sur la clé primaire du TypeThing de cet objet
	TypeId        int32      `json:"type_id"`
	Validated     *bool      `json:"validated,omitempty"`
	ValidatedBy   *int32     `json:"validated_by,omitempty"`
	ValidatedTime *time.Time `json:"validated_time,omitempty"`
}

Thing defines model for Thing.

type ThingList

type ThingList struct {
	CreatedAt   *time.Time         `json:"created_at,omitempty"`
	CreatedBy   int32              `json:"created_by"`
	Description *string            `json:"description,omitempty"`
	ExternalId  *int32             `json:"external_id,omitempty"`
	Id          openapi_types.UUID `json:"id"`
	Inactivated bool               `json:"inactivated"`
	Name        string             `json:"name"`
	PosX        float64            `json:"pos_x"`
	PosY        float64            `json:"pos_y"`
	Status      *ThingStatus       `json:"status,omitempty"`
	TypeId      int32              `json:"type_id"`
	Validated   *bool              `json:"validated,omitempty"`
}

ThingList defines model for ThingList.

type ThingStatus

type ThingStatus string

ThingStatus defines model for ThingStatus.

const (
	Abandonné      ThingStatus = "Abandonné"
	Démoli         ThingStatus = "Démoli"
	EnConstruction ThingStatus = "En Construction"
	Planifié       ThingStatus = "Planifié"
	Utilisé        ThingStatus = "Utilisé"
)

Defines values for ThingStatus.

type TypeThing

type TypeThing struct {
	Comment           *string                 `json:"comment,omitempty"`
	CreatedAt         *time.Time              `json:"created_at,omitempty"`
	CreatedBy         int32                   `json:"created_by"`
	Deleted           bool                    `json:"deleted"`
	DeletedAt         *time.Time              `json:"deleted_at,omitempty"`
	DeletedBy         *int32                  `json:"deleted_by,omitempty"`
	Description       *string                 `json:"description,omitempty"`
	ExternalId        *int32                  `json:"external_id,omitempty"`
	GeometryType      *string                 `json:"geometry_type,omitempty"`
	IconPath          string                  `json:"icon_path"`
	Id                int32                   `json:"id"`
	Inactivated       bool                    `json:"inactivated"`
	InactivatedBy     *int32                  `json:"inactivated_by,omitempty"`
	InactivatedReason *string                 `json:"inactivated_reason,omitempty"`
	InactivatedTime   *time.Time              `json:"inactivated_time,omitempty"`
	LastModifiedAt    *time.Time              `json:"last_modified_at,omitempty"`
	LastModifiedBy    *int32                  `json:"last_modified_by,omitempty"`
	ManagedBy         *int32                  `json:"managed_by,omitempty"`
	MoreDataSchema    *map[string]interface{} `json:"more_data_schema,omitempty"`
	Name              string                  `json:"name"`
	TableName         *string                 `json:"table_name,omitempty"`
}

TypeThing defines model for TypeThing.

type TypeThingCountParams

type TypeThingCountParams struct {
	// text keywords to filter the TypeThing count
	Keywords *string `form:"keywords,omitempty" json:"keywords,omitempty"`

	// id of the creator to filter the TypeThing count
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// inactivated flag to filter the TypeThing count to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`
}

TypeThingCountParams defines parameters for TypeThingCount.

type TypeThingCreateJSONBody

type TypeThingCreateJSONBody = TypeThing

TypeThingCreateJSONBody defines parameters for TypeThingCreate.

type TypeThingCreateJSONRequestBody

type TypeThingCreateJSONRequestBody = TypeThingCreateJSONBody

TypeThingCreateJSONRequestBody defines body for TypeThingCreate for application/json ContentType.

type TypeThingList

type TypeThingList struct {
	CreatedAt    time.Time `json:"created_at"`
	ExternalId   *int32    `json:"external_id,omitempty"`
	GeometryType *string   `json:"geometry_type,omitempty"`
	IconPath     string    `json:"icon_path"`
	Id           int32     `json:"id"`
	Inactivated  bool      `json:"inactivated"`
	Name         string    `json:"name"`
	TableName    *string   `json:"table_name,omitempty"`
}

TypeThingList defines model for TypeThingList.

type TypeThingListParams

type TypeThingListParams struct {
	// text keywords to filter the things to return
	Keywords *string `form:"keywords,omitempty" json:"keywords,omitempty"`

	// id of the creator to filter by the things to return
	CreatedBy *int32 `form:"created_by,omitempty" json:"created_by,omitempty"`

	// id of the external id to filter by the things to return
	ExternalId *int32 `form:"external_id,omitempty" json:"external_id,omitempty"`

	// inactivated flag to filter the things to return
	Inactivated *bool `form:"inactivated,omitempty" json:"inactivated,omitempty"`

	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`

	// offset rows to skip before returning rows
	Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"`
}

TypeThingListParams defines parameters for TypeThingList.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL