entity

package
v0.0.0-...-9ea3a31 Latest Latest
Warning

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

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

Documentation

Overview

Package entity provides entities for business logic.

Index

Constants

View Source
const (
	CommandStart      = "/start"
	CommandGetFromURL = "/url"
	CommandHelp       = "/help"
)
View Source
const (
	ExifGPSTag = "gps"
)

Variables

View Source
var (
	// ErrUserNotExists error user not exists
	ErrUserNotExists = errors.New("user not exists")
	// ErrUnknownBotCommand error user not exists
	ErrUnknownBotCommand = errors.New("unknown bot command")
	// ErrNotCommand error not a command
	ErrNotCommand = errors.New("not a command")
	// ErrWrongNumberOfArguments error wrong number of arguments
	ErrWrongNumberOfArguments = errors.New("wrong number of arguments")
	// ErrWrongURL error wrong URL
	ErrWrongURL = errors.New("wrong URL")
	// ErrLoadURL failed to load URL
	ErrLoadURL = errors.New("failed to load URL")
	// ErrInternal internal error
	ErrInternal = errors.New("internal error")
	// ErrNoExif no EXIF data found
	ErrNoExif = errors.New("no EXIF data found")
)
View Source
var ExifTags = []ExifTag{
	{
		Name:    "DateTimeOriginal",
		LabelID: locales.LIdExifTagDateTimeOriginal,
		Handler: nil,
	},
	{
		Name:    "ExposureTime",
		LabelID: locales.LIdExifTagExposureTime,
		Handler: nil,
	},
	{
		Name:    "ExposureBiasValue",
		LabelID: locales.LIdExifTagExposureBiasValue,
		Handler: prepareExposureBiasValue,
	},
	{
		Name:    "ExposureMode",
		LabelID: locales.LIdExifTagExposureMode,
		Handler: prepareExposureMode,
	},
	{
		Name:    "ApertureValue",
		LabelID: locales.LIdExifTagApertureValue,
		Handler: prepareAperture,
	},
	{
		Name:    "ExposureProgram",
		LabelID: locales.LIdExifTagExposureProgram,
		Handler: prepareExposureProgram,
	},
	{
		Name:    "ISOSpeedRatings",
		LabelID: locales.LIdExifTagISOSpeedRatings,
		Handler: nil,
	},
	{
		Name:    "Flash",
		LabelID: locales.LIdExifTagFlash,
		Handler: prepareFlash,
	},
	{
		Name:    "FocalLength",
		LabelID: locales.LIdExifTagFocalLength,
		Handler: prepareFocalLength,
	},
	{
		Name:    "DigitalZoomRatio",
		LabelID: locales.LIdExifTagDigitalZoomRatio,
		Handler: prepareDigitalZoomRatio,
	},
	{
		Name:    "Make",
		LabelID: locales.LIdExifTagMake,
		Handler: prepareMake,
	},
	{
		Name:    "Model",
		LabelID: locales.LIdExifTagModel,
	},
	{
		Name:    "LensModel",
		LabelID: locales.LIdExifTagLensModel,
	},
	{
		Name:    "BodySerialNumber",
		LabelID: locales.LIdExifTagBodySerialNumber,
	},
	{
		Name:    "LensSerialNumber",
		LabelID: locales.LIdExifTagLensSerialNumber,
	},
	{
		Name:    "MeteringMode",
		LabelID: locales.LIdExifTagMeteringMode,
		Handler: prepareMeteringMode,
	},
	{
		Name:    "WhiteBalance",
		LabelID: locales.LIdExifTagWhiteBalance,
		Handler: prepareWhiteBalance,
	},
	{
		Name:    "Software",
		LabelID: locales.LIdExifTagSoftware,
	},
	{
		Name:    "ColorSpace",
		LabelID: locales.LIdExifTagColorSpace,
		Handler: prepareColorSpace,
	},
	{
		Name:    "Artist",
		LabelID: locales.LIdExifTagArtist,
	},
	{
		Name:    "Copyright",
		LabelID: locales.LIdExifTagCopyright,
	},
}

Functions

func GetErrorMessageID

func GetErrorMessageID(err error) string

func ValidateURL

func ValidateURL(url string) error

Types

type BotConfig

type BotConfig struct {
	Token                  string `json:"token"`
	UpdateTimeout          int    `json:"update_timeout" default:"60"`
	CommandWorkersPoolSize int    `json:"command_workers_pool_size" default:"5"`
	SenderWorkersPoolSize  int    `json:"sender_workers_pool_size" default:"20"`
	Debug                  bool   `json:"debug" default:"false"`
}

BotConfig telegram settings

func (BotConfig) Validate

func (c BotConfig) Validate() error

Validate validation BotConfig

type Config

type Config struct {
	Database *DatabaseConfig `json:"database"`
	Logger   *LoggerConfig   `json:"logger"`
	Runtime  *RuntimeConfig  `json:"runtime"`
	Bot      *BotConfig      `json:"bot"`
	Parser   *ParserConfig   `json:"parser"`
}

Config application configuration

type DatabaseConfig

type DatabaseConfig struct {
	Driver   string `json:"driver" default:"postgres"`
	Host     string `json:"host" default:"127.0.0.1"`
	Port     int    `json:"port" default:"5432"`
	Username string `json:"username"`
	Password string `json:"password"`
	Database string `json:"database"`
	SSLMode  string `json:"sslmode" default:"disable"`
}

DatabaseConfig database settings

type ExifResultItem

type ExifResultItem struct {
	ValueID  string
	SuffixID string
	Value    string
}

func (*ExifResultItem) IsEmpty

func (r *ExifResultItem) IsEmpty() bool

type ExifTag

type ExifTag struct {
	Name    string
	LabelID string
	Handler func(v exif.ExifTag) *ExifResultItem
}

type LoggerConfig

type LoggerConfig struct {
	Level             string `json:"level" default:"debug"`
	TimeFieldFormat   string `json:"time_field_format" default:"2006-01-02T15:04:05Z07:00"`
	PrettyPrint       bool   `json:"pretty_print" default:"true"`
	DisableSampling   bool   `json:"disable_sampling" default:"false"`
	RedirectStdLogger bool   `json:"redirect_std_logger" default:"false"`
	ErrorStack        bool   `json:"error_stack" default:"false"`
	ShowCaller        bool   `json:"show_caller" default:"false"`
}

LoggerConfig logger settings

type ParserConfig

type ParserConfig struct {
	WorkersPoolSize int `json:"workers_pool_size" default:"5"`
}

ParserConfig EXIF parser settings

func (ParserConfig) Validate

func (c ParserConfig) Validate() error

Validate validation ParserConfig

type ParserJob

type ParserJob struct {
	URL          string
	CallbackData interface{}
	CallbackChan chan *ParserJobResult
}

type ParserJobResult

type ParserJobResult struct {
	URL          string
	Exif         map[string]*ExifResultItem
	Err          error
	CallbackData interface{}
}

type RuntimeConfig

type RuntimeConfig struct {
	GoMaxProcs int `json:"go_max_procs" default:"0"`
}

RuntimeConfig runtime settings

type User

type User struct {
	ID        int64
	FirstName string
	LastName  string
	UserName  string
	Language  string
	CreatedAt time.Time
	UpdatedAt *time.Time
}

User is a bot user

type UsersFilter

type UsersFilter struct {
	ID []int64
}

UsersFilter is filter for getting users

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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