models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionActivitiesSQL = `
SELECT activity_id
FROM users.permission_activity
WHERE permission_id = $1`

	PermissionSQL = `
SELECT name
FROM users.permissions
WHERE id = $1`

	ActivitySQL = `
SELECT name, method, destination_url
FROM users.activity
WHERE id = $1`

	AllActivitiesSQL = `
SELECT id, name, method, destination_url FROM users.activity`
)
View Source
const (
	// TimeFormat is the default format
	TimeFormat = time.RFC3339
	// TimeFormatMicro includes micro seconds
	TimeFormatMicro = "2006-01-02T15:04:05.999Z07:00"
	// TimeFormatMicroLocal is in local time
	TimeFormatMicroLocal = "2006-01-02T15:04:05.000"
	// DateFormat is for dates without time.
	DateFormat = "2006-01-02"
)

Variables

ParseTime parses the time formats.

Functions

func AddAlarmToUser

func AddAlarmToUser(ctx context.Context, conn *sql.Conn, userID int64, alarm Alarm) (alarmID int64, err error)

AddAlarmToUser connects an existing alarm to the specified user.

func AddAreaToUnit

func AddAreaToUnit(ctx context.Context, conn *sql.Conn, unitID int64, area AlarmArea) error

AddAreaToUnit associates an existing area with an alarm_area_unit.

func AlarmHasArea

func AlarmHasArea(ctx context.Context, conn *sql.Conn, unitID, areaID int64) bool

func CreateAlarm

func CreateAlarm(ctx context.Context, conn *sql.Conn, alarm Alarm) (alarmID int64, err error)

CreateAlarm persists the given alarm and connects it to the user.

func CreateAlarmArea

func CreateAlarmArea(ctx context.Context, conn *sql.Conn, unitID int64, area AlarmArea) (areaID int64, err error)

CreateAlarmArea persists a new alarm area for an existing alarm_area_unit.

func CreateAlarmSettings

func CreateAlarmSettings(ctx context.Context, conn *sql.Conn, userID int64) (int64, error)

CreateAlarmSettings persists new and empty alarm settings for a user.

func CreateAppSettings

func CreateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)

CreateAppSettings persists new app settings for the specified group.

func CreateGroup

func CreateGroup(ctx context.Context, conn *sql.Conn, group *Group) (int64, error)

CreateGroup persists a new group in the database and creates empty app settings.

func CreateGroupMapLayer

func CreateGroupMapLayer(ctx context.Context, conn *sql.Conn, groupID int64, layer *LayerForGroup) (layerID int64, err error)

CreateGroupMapLayer persists the given layer.

func CreateMapLayer

func CreateMapLayer(ctx context.Context, conn *sql.Conn, layer *Layer) (layerID int64, err error)

CreateMapLayer persists the given layer.

func CreateProfile

func CreateProfile(ctx context.Context, conn *sql.Conn, userID int64) (int64, error)

CreateProfile persists a new empty profile for a user.

func CreateRole

func CreateRole(ctx context.Context, conn *sql.Conn, role *Role) (int64, error)

CreateRole writes a new role to db.

func CreateRolePermission

func CreateRolePermission(ctx context.Context, conn *sql.Conn, roleID, permissionID int64) error

CreateRolePermission associates a permission with a role.

func CreateStrokeArea

func CreateStrokeArea(ctx context.Context, conn *sql.Conn, area *StrokeArea) (int64, error)

CreateStrokeArea persists a new stroke area.

func CreateUser

func CreateUser(ctx context.Context, conn *sql.Conn, user *User) (id int64, err error)

CreateUser writes a new user to db.

func CreateUserLog

func CreateUserLog(log Logging, userID int64) (logID int64, err error)

CreateUserLog persists the given alarm and connects it to the user.

func DeleteAlarm

func DeleteAlarm(ctx context.Context, conn *sql.Conn, alarmID, userID int64) error

DeleteAlarm removes the association between the user and the alarm. Does not remove the alarm itself.

func DeleteAlarmByGroupID

func DeleteAlarmByGroupID(ctx context.Context, conn *sql.Conn, alarmID, groupID int64) error

DeleteAlarmByGroupID removes an alarm from the database.

func DeleteGroup

func DeleteGroup(ctx context.Context, conn *sql.Conn, groupID int64) error

DeleteGroup removes an empty group from the database.

func DeleteGroupMapLayer

func DeleteGroupMapLayer(ctx context.Context, conn *sql.Conn, groupID, layerID int64) error

DeleteGroupMapLayer removes the the maplayer freom db.

func DeleteMapLayer

func DeleteMapLayer(ctx context.Context, conn *sql.Conn, layerID int64) error

DeleteMapLayer removes the the maplayer freom db.

func DeleteRole

func DeleteRole(ctx context.Context, conn *sql.Conn, roleID int64) error

DeleteRole removes a role from db.

func DeleteRolePermission

func DeleteRolePermission(ctx context.Context, conn *sql.Conn, roleID, permissionID int64) error

DeleteRolePermission removes the association between a role and a permission.

func DeleteUser

func DeleteUser(ctx context.Context, conn *sql.Conn, userID int64) error

DeleteUser removes a user from db.

func GeomContainsPoint

func GeomContainsPoint(g wkt.Geom, point *wkt.Point) bool

GeomContainsPoint checks if a point is inside a given geometry.

func HasAlarm

func HasAlarm(ctx context.Context, conn *sql.Conn, userID, alarmID int64) bool

HasAlarm checks if the alarm identified by alarm is associated to a user identified by userID

func HasAlarmByGroup

func HasAlarmByGroup(ctx context.Context, conn *sql.Conn, groupID, alarmID int64) bool

HasAlarmByGroup checks if the group has the alarm.

func LoadActivities

func LoadActivities(
	ctx context.Context,
	conn *sql.Conn,
	permissionActivities []PermissionActivity,
) (map[int64]*Activity, error)

func LoadPermissions

func LoadPermissions(
	ctx context.Context,
	conn *sql.Conn,
	rolePermissions []RolePermission,
	permissions map[int64]*Permission,
) error

func LoadRoles

func LoadRoles(
	ctx context.Context,
	conn *sql.Conn,
	userRoles []UserRole,
) (map[int64]*Role, error)

func LoadRolesForUser

func LoadRolesForUser(ctx context.Context, conn *sql.Conn, userID int64) (*[]Role, error)

LoadRolesForUser fetches roles for a user from db using the userID parameter

func LoadStrokeAreaAsWKT

func LoadStrokeAreaAsWKT(ctx context.Context, conn *sql.Conn, userID int64) (wkt.Geom, error)

LoadStrokeAreaAsWKT returns the geometry of a given userID.

func MultiPolygonContainsPoint

func MultiPolygonContainsPoint(poly *wkt.MultiPolygon, point *wkt.Point) bool

MultiPolygonContainsPoint checks if a multi-polygon contains a given point.

func PolygonContainsPoint

func PolygonContainsPoint(poly *wkt.Polygon, point *wkt.Point) bool

PolygonContainsPoint checks if a polygon contains a given point.

func RemoveAreaFromUnit

func RemoveAreaFromUnit(ctx context.Context, conn *sql.Conn, unitID, areaID int64) error

RemoveAreaFromUnit deletes the connection between an alarm area and the unit.

func UpdateAlarm

func UpdateAlarm(ctx context.Context, conn *sql.Conn, alarm Alarm) (alarmID int64, err error)

UpdateAlarm persists new attributes in an existing alarm.

func UpdateAlarmArea

func UpdateAlarmArea(ctx context.Context, conn *sql.Conn, area *AlarmArea) (int64, error)

UpdateAlarmArea persists changed attributes of a stroke area.

func UpdateAlarmSettings

func UpdateAlarmSettings(ctx context.Context, conn *sql.Conn, settings AlarmSettings) (int64, error)

UpdateAlarmSettings persists changes in alarmsettings.

func UpdateAppSettings

func UpdateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)

UpdateAppSettings persists changes in app settings.

func UpdateGroup

func UpdateGroup(ctx context.Context, conn *sql.Conn, group *Group) (int64, error)

UpdateGroup persists changes for a group.

func UpdateGroupMapLayer

func UpdateGroupMapLayer(ctx context.Context, conn *sql.Conn, layer *LayerForGroup) (layerID int64, err error)

UpdateGroupMapLayer persists new attributes in an existing layer.

func UpdateMapLayer

func UpdateMapLayer(ctx context.Context, conn *sql.Conn, layer *Layer) (layerID int64, err error)

UpdateMapLayer persists new attributes in an existing layer.

func UpdateProfile

func UpdateProfile(ctx context.Context, conn *sql.Conn, userID int64, profile *interface{}) error

UpdateProfile sets the new profile data for a user.

func UpdateRole

func UpdateRole(ctx context.Context, conn *sql.Conn, role *Role) (int64, error)

UpdateRole persists changes in role attributes.

func UpdateStrokeArea

func UpdateStrokeArea(ctx context.Context, conn *sql.Conn, area *StrokeArea) (int64, error)

UpdateStrokeArea persists changed attributes of a stroke area.

func UpdateUser

func UpdateUser(ctx context.Context, conn *sql.Conn, user *User) (int64, error)

UpdateUser persists changes in users attributes.

Types

type Activity

type Activity struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Method string `json:"method"`
	URL    string `json:"url"`
}

func LoadAllActivities

func LoadAllActivities(ctx context.Context, conn *sql.Conn) ([]*Activity, error)

type Alarm

type Alarm struct {
	ID             int64               `json:"id"`
	Name           string              `json:"name"`
	GroupID        int64               `json:"groupId"`
	Alarm          bool                `json:"alarm"`
	AlarmTimestamp *pgtype.Timestamptz `json:"alarmTimestamp"`
	IsExtended     bool                `json:"isExtended"`
	IsNotified     bool                `json:"isNotified"`
}

Alarm represents the datastructure for alarm_area_units in the db.

func LoadAlarm

func LoadAlarm(ctx context.Context, conn *sql.Conn, unitID int64) (*Alarm, error)

LoadAlarm fetches n alarm identified by its id from the database.

func LoadAlarmByGroup

func LoadAlarmByGroup(ctx context.Context, conn *sql.Conn, groupID int64) ([]Alarm, error)

LoadAlarmByGroup fetches alarms associated to a group from db using the groupID parameter

func LoadAlarmByGroupByID

func LoadAlarmByGroupByID(ctx context.Context, conn *sql.Conn, groupID, alarmID int64) ([]Alarm, error)

LoadAlarmByGroupByID fetches a single alram identified by its id for a group from db.

func LoadAlarms

func LoadAlarms(ctx context.Context, conn *sql.Conn, userID int64) ([]Alarm, error)

LoadAlarms fetches the alarms associated to a user from db using the userID parameter

type AlarmArea

type AlarmArea struct {
	ID              int64               `json:"id"`
	Geom            interface{}         `json:"geom"`
	AlarmDuration   *int64              `json:"alarmDuration"`
	Radius          *float64            `json:"radius"`
	Center          *interface{}        `json:"center"`
	Icon            *string             `json:"icon"`
	Area            *float64            `json:"area"`
	InnerRadius     *float64            `json:"innerRadius"`
	StrokeThreshold *int64              `json:"strokeThreshold"`
	StrokeCounter   *int64              `json:"strokeCounter"`
	LastStroke      *pgtype.Timestamptz `json:"lastStroke"`
}

AlarmArea represents the persistence layer

func LoadAlarmAreaByID

func LoadAlarmAreaByID(ctx context.Context, conn *sql.Conn, areaID int64) (*AlarmArea, error)

LoadAlarmAreaByID fetches a single alarm area specified by id.

func LoadAlarmAreas

func LoadAlarmAreas(ctx context.Context, conn *sql.Conn, alarmID int64) ([]AlarmArea, error)

LoadAlarmAreas fetches areas for a specified alarm.

type AlarmSettings

type AlarmSettings struct {
	ID                  *int64              `json:"id"`
	AlarmTemplateMailID *int64              `json:"alarmTemplateMailId"`
	AlarmTemplateSmsID  *int64              `json:"alarmTemplateSmsId"`
	AlarmTemplateMqttID *int64              `json:"alarmTemplateMqttId"`
	AlarmTemplateFaxID  *int64              `json:"alarmTemplateFaxId"`
	Sms                 *string             `json:"sms"`
	Email               *string             `json:"email"`
	Phone               *string             `json:"phone"`
	Fax                 *string             `json:"fax"`
	StartDate           *pgtype.Timestamptz `json:"startDate"`
	StopDate            *pgtype.Timestamptz `json:"stopDate"`
	StartTime           *time.Time          `json:"startTime"`
	StopTime            *time.Time          `json:"stopTime"`
	Monday              *bool               `json:"monday"`
	Tuesday             *bool               `json:"tuesday"`
	Wednesday           *bool               `json:"wednesday"`
	Thursday            *bool               `json:"thursday"`
	Friday              *bool               `json:"friday"`
	Saturday            *bool               `json:"saturday"`
	Sunday              *bool               `json:"sunday"`
	OnlyLog             bool                `json:"onlyLog"`
	StrokeProtocol      bool                `json:"strokeProtocol"`
	StrokeAsCSV         bool                `json:"strokeAsCSV"`
}

AlarmSettings represents the persistence layer

func LoadAlarmSettings

func LoadAlarmSettings(ctx context.Context, conn *sql.Conn, userID int64) (*AlarmSettings, error)

LoadAlarmSettings fetches alarm settings for a user from db using the userID parameter

type AppSettings

type AppSettings struct {
	ID                *int64             `json:"id"`
	GroupID           int64              `json:"groupId"`
	MaxDisplayTime    *int64             `json:"maxDisplayTime"`
	ArchiveDays       int64              `json:"archiveDays"`
	ArchiveSince      pgtype.Timestamptz `json:"archiveSince"`
	MaxZoom           int64              `json:"maxZoom"`
	MinZoom           int64              `json:"minZoom"`
	LiveBlids         bool               `json:"liveBlids"`
	Animation         bool               `json:"animation"`
	Sound             bool               `json:"sound"`
	Path              string             `json:"path"`
	MaxAlarms         int64              `json:"maxAlarms"`
	MaxAlarmAreas     int64              `json:"maxAlarmAreas"`
	MaxAlarmUser      int64              `json:"maxAlarmUser"`
	StatisticWindowed bool               `json:"statisticWindowed"`
}

AppSettings represents the persistence layer

func LoadAppSettings

func LoadAppSettings(ctx context.Context, conn *sql.Conn, groupID int64) (*AppSettings, error)

LoadAppSettings fetches settings for a group from db using the groupID parameter

type BBox

type BBox struct {
	MinX float64
	MinY float64
	MaxX float64
	MaxY float64
}

BBox is a bounding box of an area.

func CalculateBBox

func CalculateBBox(g wkt.Geom) *BBox

CalculateBBox return the bounding box of given geometry.

func (*BBox) Contains

func (bb *BBox) Contains(p *wkt.Point) bool

Contains checks if a given point is inside these bounding box.

type Date

type Date struct{ time.Time }

Date is a wrapper for time.Time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Date

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON encoded Date.

type Group

type Group struct {
	ID                *int64  `json:"id"`
	Name              *string `json:"name"`
	Parent            *int64  `json:"parent"`
	RoleID            *int64  `json:"roleId"`
	ThemeID           *int64  `json:"themeId"`
	MaxAlarmArea      *int64  `json:"maxAlarmArea"`
	DataAreaID        *int64  `json:"dataAreaId"`
	AlarmConfigID     *int64  `json:"alarmConfigId"`
	ChangeAlarmConfig bool    `json:"changeAlarmConfig"`
}

Group represents the persistence layer

func LoadGroupByID

func LoadGroupByID(ctx context.Context, conn *sql.Conn, groupID int64) (*Group, error)

LoadGroupByID fetches the group with the given groupID from the database.

func LoadGroupChildren

func LoadGroupChildren(ctx context.Context, conn *sql.Conn, groupID int64) ([]*Group, error)

LoadGroupChildren fetches all group childs of the group identified by groupID parameter.

type HostTheme

type HostTheme struct {
	ID   *int64       `json:"id"`
	Host *string      `json:"host"`
	Data *pgtype.JSON `json:"data"`
}

func LoadHostTheme

func LoadHostTheme(ctx context.Context, conn *sql.Conn, host string) (*HostTheme, error)

LoadHostTheme fetches a host theme from db.

type Layer

type Layer struct {
	ID                int64           `json:"id"`
	GeoserverName     *string         `json:"geoserverName"`
	Name              *string         `json:"name"`
	Reload            bool            `json:"reload"`
	BaseLayer         bool            `json:"baseLayer"`
	TimeLayer         bool            `json:"timeLayer"`
	TickWidth         *int64          `json:"tickWidth"`
	LayerType         string          `json:"layerType"`
	SingleTile        bool            `json:"singleTile"`
	DefaultName       *string         `json:"defaultName"`
	ExternalServer    *string         `json:"externalServer"`
	ExternalParameter json.RawMessage `json:"externalParameter"`
}

Layer represents the datastructure for map_layers in the db.

func LoadMapLayerByID

func LoadMapLayerByID(ctx context.Context, conn *sql.Conn, layerID int64) (*Layer, error)

LoadMapLayerByID fetches a layer identified by its id from the database.

func LoadMapLayers

func LoadMapLayers(ctx context.Context, conn *sql.Conn) ([]Layer, error)

LoadMapLayers fetches the map layers from db

type LayerForGroup

type LayerForGroup struct {
	ID            int64           `json:"id"`
	GroupID       int64           `json:"groupId"`
	LayerID       int64           `json:"layerID"`
	ReloadTime    int64           `json:"reloadTime"`
	DisplayName   *string         `json:"displayName"`
	FeatureInfo   bool            `json:"featureInfo"`
	CheckOnLogin  bool            `json:"checkedOnLogin"`
	Permanent     bool            `json:"permanent"`
	CQLFilter     json.RawMessage `json:"cqlFilter"`
	PopupTemplate *string         `json:"popupTemplate"`
	ZIndex        *int64          `json:"zIndex"`
}

LayerForGroup represents the datastructure for group_map_layers in the db.

func LoadGroupMapLayerByID

func LoadGroupMapLayerByID(ctx context.Context, conn *sql.Conn, groupID, layerID int64) (*LayerForGroup, error)

LoadGroupMapLayerByID fetches a group layer identified by its id from the database.

func LoadGroupMapLayers

func LoadGroupMapLayers(ctx context.Context, conn *sql.Conn, groupID int64) ([]LayerForGroup, error)

LoadGroupMapLayers fetches the map layers from db

func LoadMapLayersUser

func LoadMapLayersUser(ctx context.Context, conn *sql.Conn, userID int64) ([]LayerForGroup, error)

LoadMapLayersUser fetches the map layers from db

type Logging

type Logging struct {
	ID        int64               `json:"id"`
	User      string              `json:"user"`
	Text      string              `json:"text"`
	Timestamp *pgtype.Timestamptz `json:"timestamp"`
	IP        string              `json:"ip"`
}

Logging represents the datastructure in the db.

func LoadUserLogs

func LoadUserLogs(ctx context.Context, conn *sql.Conn, userID int64) ([]Logging, error)

LoadUserLogs fetches the logs associated to a users group from db using the userID parameter

type PWResetUser

type PWResetUser struct {
	User string `json:"user"`
}

PWResetUser is send to request a password reset for a user.

type Permission

type Permission struct {
	ID          int64   `json:"id"`
	Name        string  `json:"name"`
	ActivityIDs []int64 `json:"activities,omitempty"`
}

Permission represents the persistence layer.

func LoadPermissionByID

func LoadPermissionByID(ctx context.Context, conn *sql.Conn, permissionID int64) (*Permission, error)

LoadPermissionByID fetches a single permission.

func LoadPermissionsByRole

func LoadPermissionsByRole(ctx context.Context, conn *sql.Conn, roleID int64) ([]*Permission, error)

LoadPermissionsByRole fetches the permissions for a specified user.

func LoadUserPermissions

func LoadUserPermissions(ctx context.Context, conn *sql.Conn, userID int64) ([]*Permission, error)

LoadUserPermissions fetches the permissions for a specified user.

type PermissionActivity

type PermissionActivity struct {
	PermissionID int64 `json:"permission_id"`
	ActivityID   int64 `json:"activity_id"`
}

func LoadPermissionActivities

func LoadPermissionActivities(
	ctx context.Context,
	conn *sql.Conn,
	rolePermissions []RolePermission,
) ([]PermissionActivity, error)

type Profile

type Profile struct {
	ID   *int64       `json:"id"`
	Data *pgtype.JSON `json:"data"`
}

Profile represents the persitence layer of a user

func LoadProfileForUser

func LoadProfileForUser(ctx context.Context, conn *sql.Conn, userID int64) (*Profile, error)

LoadProfileForUser fetches a profile for a user from db using the userID parameter

type Role

type Role struct {
	ID            int64   `json:"id"`
	Parent        *int64  `json:"parent"`
	Name          *string `json:"name"`
	PermissionIDs []int64 `json:"permissions,omitempty"`
}

Role represents the persitence layer of a role

func LoadRoleByID

func LoadRoleByID(ctx context.Context, conn *sql.Conn, roleID int64) (*Role, error)

LoadRoleByID retches a role from db specified by roleID.

type RolePermission

type RolePermission struct {
	RoleID       int64 `json:"role_id"`
	PermissionID int64 `json:"permission_id"`
}

func LoadRolePermissions

func LoadRolePermissions(
	ctx context.Context,
	conn *sql.Conn,
	roles map[int64]*Role,
) ([]RolePermission, error)

type Statistic

type Statistic struct {
	PEarth      []StatisticItem `json:"pEarth"`
	NEarth      []StatisticItem `json:"nEarth"`
	Cloud       []StatisticItem `json:"cloud"`
	CountTotal  int64           `json:"countTotal"`
	CountPEarth int64           `json:"countPEarth"`
	CountNEarth int64           `json:"countNEarth"`
	CountCloud  int64           `json:"countCloud"`
}

Statistic represents the summary over stroke statistics in a specific time range and in a specific bbox.

func LoadStatistics

func LoadStatistics(
	ctx context.Context,
	conn *sql.Conn,
	start, stop int64,
	left, right, top, bottom float64,
) (*Statistic, error)

LoadStatistics fetches stroke statististics from the database.

type StatisticItem

type StatisticItem struct {
	Timestamp time.Time `json:"timestamp"`
	Count     float64   `json:"count"`
}

StatisticItem represents a single entry in statistics.

type StrokeArea

type StrokeArea struct {
	ID      *int64      `json:"id"`
	GroupID int64       `json:"groupId"`
	Geom    interface{} `json:"geom"`
}

StrokeArea represents the persistence layer

func LoadStrokeArea

func LoadStrokeArea(ctx context.Context, conn *sql.Conn, userID int64) (*StrokeArea, error)

LoadStrokeArea fetches a stroke area for a user from db using the userID parameter

func LoadStrokeAreaByGroup

func LoadStrokeAreaByGroup(ctx context.Context, conn *sql.Conn, groupID int64) (*StrokeArea, error)

LoadStrokeAreaByGroup fetches a single stroke area for a group.

type Template

type Template struct {
	ID              int64   `json:"id"`
	AlarmSubject    *string `json:"alarmSubject"`
	AllClearSubject *string `json:"allClearSubject"`
	AlarmText       *string `json:"alarmText"`
	AllClearText    *string `json:"allClearText"`
}

Template represents the persitence layer of all types of templates

func LoadTemplateFax

func LoadTemplateFax(ctx context.Context, conn *sql.Conn) ([]Template, error)

LoadTemplateFax fetches all templates of type fax.

func LoadTemplateMQTT

func LoadTemplateMQTT(ctx context.Context, conn *sql.Conn) ([]Template, error)

LoadTemplateMQTT fetches all templates of type mqtt.

func LoadTemplateMail

func LoadTemplateMail(ctx context.Context, conn *sql.Conn) ([]Template, error)

LoadTemplateMail fetches all templates of type mail.

func LoadTemplatePhone

func LoadTemplatePhone(ctx context.Context, conn *sql.Conn) ([]Template, error)

LoadTemplatePhone fetches all templates of type phone.

func LoadTemplateSMS

func LoadTemplateSMS(ctx context.Context, conn *sql.Conn) ([]Template, error)

LoadTemplateSMS fetches all templates of type sms.

type Theme

type Theme struct {
	ID   *int64       `json:"id"`
	Name *string      `json:"name"`
	Data *pgtype.JSON `json:"data"`
}

Theme represents the persitence layer of a user

func LoadThemeForUser

func LoadThemeForUser(ctx context.Context, conn *sql.Conn, userID int64) (*Theme, error)

LoadThemeForUser fetches a theme for a user from db using the userID parameter

func LoadThemes

func LoadThemes(ctx context.Context, conn *sql.Conn) ([]Theme, error)

LoadThemes fetches all themes from db

type Time

type Time struct{ time.Time }

Time is a wrapper for time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON pases the JSON encodes Time

type TimeParser

type TimeParser []string

TimeParser is a list of time formats.

func (TimeParser) Parse

func (tg TimeParser) Parse(s string) (time.Time, error)

Parse tries to parse a given string by the entries of the layout list one after another. The first matching time is returned. If no layout matches the last error is returned or time zero if the layout list is empty.

type User

type User struct {
	ID           *int64        `json:"id"`
	Name         *string       `json:"name"`
	Password     *string       `json:"password"`
	GroupID      *int64        `json:"groupId"`
	StartDate    *sql.NullTime `json:"startDate"`
	StopDate     *sql.NullTime `json:"stopDate"`
	FirstName    *string       `json:"firstName"`
	LastName     *string       `json:"lastName"`
	Company      *string       `json:"company"`
	Division     *string       `json:"division"`
	Street       *string       `json:"street"`
	ZIP          *string       `json:"zip"`
	City         *string       `json:"city"`
	PhoneNumber  *string       `json:"phonenumber"`
	Annotation   *string       `json:"annotation"`
	MobileNumber *string       `json:"mobilenumber"`
	EMail        *string       `json:"email"`
}

User represents the persitence layer of a user

func LoadUser

func LoadUser(ctx context.Context, conn *sql.Conn, userID int64) (*User, error)

LoadUser fetches a single user from db using the userID parameter

func LoadUsersByGroup

func LoadUsersByGroup(ctx context.Context, conn *sql.Conn, groupID int64) ([]*User, error)

LoadUsersByGroup fetches all users of a specified group.

type UserActivities

type UserActivities struct {
	Roles       map[int64]*Role       `json:"roles"`
	Permissions map[int64]*Permission `json:"permissions"`
	Activities  map[int64]*Activity   `json:"activities"`
}

func LoadActivitiesForUser

func LoadActivitiesForUser(
	ctx context.Context,
	conn *sql.Conn,
	userID int64,
) (*UserActivities, error)

type UserRole

type UserRole struct {
	RoleID int64 `json:"role_id"`
	UserID int64 `json:"user_id"`
}

func LoadUserRoles

func LoadUserRoles(
	ctx context.Context,
	conn *sql.Conn,
	userID int64,
) ([]UserRole, error)

Jump to

Keyboard shortcuts

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