gobizap

package module
v0.0.0-...-eaebcad Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 35 Imported by: 0

README

gobizap

Documentation

Index

Constants

View Source
const (
	DEFAULT_ROLE = "guest"       // default user role if not logged
	SESS_ROLE    = "USER_ROLE"   // session variable name
	SESS_LOCALE  = "USER_LOCALE" // session variable name

	VERSION_FILE_NAME = "version.txt" // for storing varion number

	FRAME_WORK_VERSION = "1.0.0.11" // framwork version
)
View Source
const (
	ER_WRONG_TOKEN_FORMAT = "Неверный формат токена."
	ER_SESS_NOT_FOUND     = "Сессия не нейдена."

	ER_PARSE_NO_FUNC          = "Параметр 'func' не найден."
	ER_PARSE_NO_METH          = "Не найдена функция в параметре."
	ER_PARSE_NO_CONTR         = "Не найден котроллер в параметре."
	ER_PARSE_CTRL_NOT_DEFINED = "Контроллер '%s' не определен."

	ER_PARSE_NOT_VALID_EMPTY = "Поле: %s, пустое значение"

	ER_AUTH               = "Ошибка авторизации."                             //100
	ER_AUTH_EXP           = "Срок сессии истек."                              //101
	ER_AUTH_NOT_LOGGED    = "Не авторизован."                                 //102
	ER_AUTH_BANNED        = "Доступ запрещен."                                //103
	ER_SQL_SERVER_CON     = "Ошибка подключения к серверу базы данных."       //105
	ER_SQL_QUERY          = "Ошибка при выполнении запроса к базе данных."    //106
	ER_VERSION            = "Версии клиентского и серверного ПО отличается."  //107
	ER_SESSION            = "Ошибка работы с данными сессии."                 //109
	ER_COM_NO_CONTROLLER  = "Контроллер не определен."                        //10
	ER_COM_METH_PROHIB    = "Метод запрещен."                                 //11
	ER_COM_NO_VIEW        = "Вид не определен."                               //12
	ER_INTERNAL           = "Server innner error."                            //13
	ER_DELETE_CONSTR_VIOL = "Удаление невозможно, так как существуют ссылки." //500
	ER_DELETE_NOT_FOUND   = "Объект не найден."                               //510
	ER_WRITE_CONSTR_VIOL  = "Нарушение уникальности ключевых полей."          //600
	ER_PM_INTERNAL        = "Ошибка исполнения метода."                       //5

	ER_CONTOLLER_METH_NOT_DEFINED = "Метод '%s' контроллера '%s' не найден."

	ER_SQL_WHERE_FILED_CNT_MISMATCH = "Количество полей в условии не совпадает."
	ER_SQL_WHERE_UNKNOWN_COND       = "Неизветсное условие '%s'."

	ER_UPDATE_EMPTY = "Поля для обновления не установлены."

	ER_NO_KEYS  = "Ключевые поля не установлены."
	ER_NO_WHERE = "Не определено значение условия."

	ER_VERSION_FILE_EMPTY      = "Файл версии пустой."
	ER_CONFIG_FILE_NOT_DEFINED = "Файл конфигурации не определен."
)
View Source
const (
	SQL_STATEMENT_LIMIT_2      = "OFFSET %d LIMIT %d"
	SQL_STATEMENT_LIMIT_1      = "LIMIT %d"
	DEF_DOC_PER_PAGE_COUNT int = 50
	DEF_LIMIT_COUNT        int = 5000
)
View Source
const (
	SQL_STATEMENT = "ORDER BY "
	SQL_DIR_ASC   = "ASC"
	SQL_DIR_DESC  = "DESC"

	PAR_DIR_ASC  = "asc"
	PAR_DIR_DESC = "desc"
)
View Source
const (
	SGN_PAR_E       = "e"       //equal
	SGN_PAR_L       = "l"       //less
	SGN_PAR_G       = "g"       //greater
	SGN_PAR_LE      = "le"      //less and equal
	SGN_PAR_GE      = "ge"      //greater and equal
	SGN_PAR_LK      = "lk"      //like
	SGN_PAR_NE      = "ne"      //not equal
	SGN_PAR_I       = "i"       // IS
	SGN_PAR_IN      = "in"      // in
	SGN_PAR_INCL    = "incl"    //include
	SGN_PAR_ANY     = "any"     //Any
	SGN_PAR_OVERLAP = "overlap" //overlap

	JOIN_PAR_AND = "a"
	JOIN_PAR_OR  = "o"
)
View Source
const (
	KEY_FLD_PREF = "old_"

	LSN_FIELD = "lsn"

	METH_COMPLETE_DEF_COUNT = 50

	RESP_ER_DELETE_CONSTR_VIOL = 500
	RESP_ER_DELETE_NOT_FOUND   = 510
	RESP_ER_WRITE_CONSTR_VIOL  = 600
)
View Source
const DEF_APP_SHUTDOWN_TIMEOUT = 15 //30 seconds
View Source
const (
	DEF_FIELD_SEP = "@@" //default field separator used by clients
)

Variables

View Source
var DebugQueries bool // if true, all queries will be logged
View Source
var DocPerPageCount int

Default count value @ToDo: subscribe to DocPerPageCount update local event!!!

View Source
var DocPerPageCountConstantID string

Functions

func AddQueryResult

func AddQueryResult(resp *response.Response, modelMD *model.ModelMD, modelStruct interface{}, query string, queryTotal string, condValues []interface{}, conn *pgx.Conn, sysModel bool) error

func AddStructFieldsToList

func AddStructFieldsToList(v reflect.Value, fields *[]interface{}, fieldIDs *strings.Builder, fieldPrefix string) error

func ArgsFieldSep

func ArgsFieldSep(rfltArgs reflect.Value) string

Helper function. Returns field separator of a condition query

func ArgsToInsertParams

func ArgsToInsertParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection, encryptKey string) (fieldIds string, fieldArgs string, fieldValues []interface{})

Separates public method arguments into fieldIds, fieldArgs, retFieldIds, fieldValues fieldIds is a string containing all ids fieldArgs is a string with parameters ($1,$2...) to be used in query fieldValues interface values function is used for insert PublicMethod

func ArgsToUpdateParams

func ArgsToUpdateParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection) (fieldQuery string, whereQuery string, fieldValues []interface{}, keys map[string]interface{})

puts old_key to where query pg specific function

func CompleteOnArgs

func CompleteOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, scanModelMD *model.ModelMD, scanModel interface{}, presetConds sql.FilterCondCollection) error

Implements controller complete method Internally calls CompleteOnArgsWithConn

func CompleteOnArgsWithConn

func CompleteOnArgsWithConn(conn *pgx.Conn, app Applicationer, resp *response.Response, rfltArgs reflect.Value, scanModelMD *model.ModelMD, scanModel interface{}, presetConds sql.FilterCondCollection) error

Implements controller complete method args.Ic - insensetive case 1/0 args.Mid 1 - %pattern%, 0 - pattern% scanModelMD scanModel pattern - pattern to match there is also another argument with the same name as model field marked as matchField=true in tag

func DeleteOnArgKeys

func DeleteOnArgKeys(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error

Common function for deleting object from DB based on argument keys

func DeleteOnArgKeysWithConn

func DeleteOnArgKeysWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error

Implements controller delete method

func GenUniqID

func GenUniqID(maxLen int) string

Generates unique identifier

func GetDbLsn

func GetDbLsn(conn *pgx.Conn) string

func GetExcelFileOnArgs

func GetExcelFileOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, scanModelMD *model.ModelMD, scanModel interface{}, clientFilName string) error

func GetIntArgValByName

func GetIntArgValByName(args reflect.Value, fieldName string, defVal int64) int64

Helper function to get value as int64 from argument by name

func GetListOnArgs

func GetListOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, modelMD *model.ModelMD, modelStruct interface{}, presetConds sql.FilterCondCollection) error

func GetListQuery

func GetListQuery(conn *pgx.Conn, rfltArgs reflect.Value, scanModelMD *model.ModelMD, extraConds sql.FilterCondCollection, encryptKey string) (string, string, []interface{}, int, int, error)

Returns: query, total query and cond_params string - query, string - total query, []interface{} - condition params from int, count int

func GetMd5

func GetMd5(data string) string

Generates MD5 hash

func GetModelLsnValue

func GetModelLsnValue(modelStruct interface{}) string

func GetModelStructFields

func GetModelStructFields(modelStruct interface{}) (model.ModelRow, []interface{})

returns row fields of a given model structute

func GetObjectOnArgs

func GetObjectOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, modelMD *model.ModelMD, modelStruct interface{}, presetConds sql.FilterCondCollection) error

Implements controller get_object method rfltArgs holds condition fields

func GetObjectOnArgsWithConn

func GetObjectOnArgsWithConn(conn *pgx.Conn, app Applicationer, resp *response.Response, rfltArgs reflect.Value, modelMD *model.ModelMD, modelStruct interface{}, presetConds sql.FilterCondCollection) error

func GetSQLDefaultOrderBy

func GetSQLDefaultOrderBy(modelMD *model.ModelMD, encryptKey string) string

func GetSQLLimitFromArgs

func GetSQLLimitFromArgs(rfltArgs reflect.Value, scanModelMD *model.ModelMD, conn *pgx.Conn, docPerPageCount int) (string, int, int, error)

func GetSQLOrderByFromArgs

func GetSQLOrderByFromArgs(rfltArgs reflect.Value, fieldSep string) string

func GetSQLOrderByFromArgsOrDefault

func GetSQLOrderByFromArgsOrDefault(rfltArgs reflect.Value, fieldSep string, modelMD *model.ModelMD, encryptKey string) string

func GetSQLWhereFromArgs

func GetSQLWhereFromArgs(rfltArgs reflect.Value, fieldSep string, modelMD *model.ModelMD, extraConds sql.FilterCondCollection) (string, []interface{}, error)

returns:

sql_s query string
vals_s slice of validated, sanatized parameters
error

func GetTextArgValByName

func GetTextArgValByName(args reflect.Value, fieldName string, defVal string) string

Helper function to get value as sring from argument by name

func InsertOnArgs

func InsertOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, retModel interface{}, presetConds sql.FilterCondCollection) error

Implements controller insert method internally calls InsertOnArgsWithConn

func InsertOnArgsWithConn

func InsertOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, retModel interface{}, presetConds sql.FilterCondCollection) error

Implements controller insert method

func MakeStructRowFields

func MakeStructRowFields(resultStruct interface{}, fieldPrefix string) ([]interface{}, string, error)

Returns:

struct fields,
list of field IDs for select query
error if any

func PublishEventsWithKeys

func PublishEventsWithKeys(sockID string, keys map[string]interface{}, app Applicationer, pm PublicMethod, lsn string)

func QueryResultToModel

func QueryResultToModel(modelMD *model.ModelMD, modelStruct interface{}, query string, queryTotal string, condValues []interface{}, conn *pgx.Conn, sysModel bool) (model.Modeler, error)

Executes query and returns it result as model

func QueryResultToXML

func QueryResultToXML(modelID string, scanModel interface{}, query string, queryTotal string, whereParams []interface{}, conn *pgx.Conn) (string, error)

func RetrieveValue

func RetrieveValue(dStore *pgds.PgProvider, constID string, constVal interface{}) error

GetValue fetches value of constant constID from store to constVal.

func SetDocPerPageCount

func SetDocPerPageCount(conn *pgx.Conn) error

func UpdateOnArgs

func UpdateOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error

Implements controller insert method internally calls UpdateOnArgsWithConn

func UpdateOnArgsWithConn

func UpdateOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error

Implements controller insert method

Types

type AppConfiger

type AppConfiger interface {
	GetDb() config.DbStorage
	GetWSServer() string
	GetTLSWSServer() string
	GetTLSKey() string
	GetTLSCert() string
	GetAppID() string
	GetLogLevel() string
	GetSession() config.Session
	GetTemplateDir() string
	GetReportErrors() bool
	GetXSLTDir() string
	GetDefaultLocale() string
	GetTechMail() string
	GetAuthor() string
	GetDebugQueries() bool
	GetAppShutdownTimeout() int
	SetAppShutdownTimeout(int)
}

AppConfiger is an application configuration interface. Realization is held by Application object.

type Application

type Application struct {
	Config         AppConfiger      // app config
	Logger         logger.Logger    // app logger
	SessManager    *session.Manager // app sessions
	MD             *Metadata        // app description of all controllers/models
	Servers        ServerList       // list of running servers
	PermisManager  Permissioner     // handles permission rules (controllers to roles)
	OnPublishEvent OnPublishEventProto
	DataStorage    interface{}
	EncryptKey     string // application encryption key
	BaseDir        string // application directory
	ConfigFileName string //
	OnReloadConfig OnReloadConfigProto
	AppVersion     string
	EvntServer     RunnableServer
}

Application is the main object holding application parameters. It is passed to all controllers. Derived applications must include this structure to their app objects.

func (*Application) AddServer

func (a *Application) AddServer(ID string, s srv.Server)

AddServer adds a new service to the list.

func (*Application) DestroySession

func (a *Application) DestroySession(sessID string)

DestroySession deletes a session by its ID.

func (*Application) GetAppVersion

func (a *Application) GetAppVersion() string

GetAppVersion returns application version. Version is retrieved from file. It panics if version file is not found. Should be called on application startup.

func (*Application) GetBaseDir

func (a *Application) GetBaseDir() string

func (*Application) GetConfig

func (a *Application) GetConfig() AppConfiger

GetConfig returns application config.

func (*Application) GetDataStorage

func (a *Application) GetDataStorage() interface{}

GetDataStorage returns application data storage object.

func (*Application) GetEncryptKey

func (a *Application) GetEncryptKey() string

func (*Application) GetFrameworkVersion

func (a *Application) GetFrameworkVersion() string

GetFrameworkVersion returns current framwork version number.

func (*Application) GetLogger

func (a *Application) GetLogger() logger.Logger

GetConfig returns application logger.

func (*Application) GetMD

func (a *Application) GetMD() *Metadata

GetConfig returns application metadata.

func (*Application) GetOnPublishEvent

func (a *Application) GetOnPublishEvent() OnPublishEventProto

GetOnPublishEvent returns on publish event function.

func (*Application) GetPermisManager

func (a *Application) GetPermisManager() Permissioner

GetPermisManager returns application permission manager.

func (*Application) GetServer

func (a *Application) GetServer(ID string) srv.Server

GetConfig returns a running service by its name.

func (*Application) GetServers

func (a *Application) GetServers() ServerList

GetConfig returns a list of running service.

func (*Application) GetSessManager

func (a *Application) GetSessManager() *session.Manager

GetSessManager returns application session manager.

func (*Application) GetTempDir

func (a *Application) GetTempDir() string

GetTempDir returns application temp directory. TODO: more platform independant way.

func (*Application) HandleEvent

func (a *Application) HandleEvent(fn string, args []byte)

HandleEvent is an event handler. Called from event server. Event is in format "ControllerID.MethodID". No response is expected, so the function returns none. All errors are logged.

func (*Application) HandleJSONRequest

func (a *Application) HandleJSONRequest(serv srv.Server, sock socket.ClientSocketer, payload []byte, viewID string)

HandleJSONRequest handles requests in json format. Payload argument contains json data. It parses incoming arguments, then on success HandleRequestCont() is called.

func (*Application) HandlePermission

func (a *Application) HandlePermission(sock socket.ClientSocketer, controllerID string, methodID string) error

HandlePermission is called to determine permission for Controller->method. If not permitted an error is returned. TODO: it is better to return bool value instead.

func (*Application) HandleRequest

func (a *Application) HandleRequest(serv srv.Server, sock socket.ClientSocketer, controllerID string, methodID string, queryID string, argsPayload []byte, viewID string)

HandleRequest handles net request. It has controller and method as separated parameters. If error occurs when parsing command it is sent to client. Otherwise, on success handling is continued in HandleRequestCont() function

func (*Application) HandleRequestCont

func (a *Application) HandleRequestCont(serv srv.Server, sock socket.ClientSocketer, pm PublicMethod, contr Controller, argv reflect.Value, resp *response.Response, viewID string)

HandleRequestCont continues handling a client request. Checks permission for controller->method for a given role.

func (*Application) HandleServerError

func (a *Application) HandleServerError(serv srv.Server, sock socket.ClientSocketer, queryID string, viewID string)

HandleServerError is called on any server error. The error is sent to client with a specified view as an internal server error.

func (*Application) HandleSession

func (a *Application) HandleSession(sock socket.ClientSocketer) error

HandleSession is run on a new client call. It finds an appropriate session by client token or creates a new one if it is dead.

func (*Application) LoadAppVersion

func (a *Application) LoadAppVersion() error

LoadAppVersion loads application version from file defined by VERSION_FILE_NAME constant. File is searched in base directory.

func (*Application) PublishPublicMethodEvents

func (a *Application) PublishPublicMethodEvents(pm PublicMethod, params map[string]interface{})

PublishPublicMethodEvents publishes events from public method if there are any.

func (*Application) ReloadAppConfig

func (a *Application) ReloadAppConfig() error

ReloadAppConfig reloads application configuration from file. After reload OnReloadConfig() is called if it points to a function.

func (*Application) Run

func (a *Application) Run()

Run starts all registered servers and waits for an OS interrupt signal. If interrupted all servers are shutdown within the time specified by AppShutdownTimeout configuration parameter.

func (*Application) SendToClient

func (a *Application) SendToClient(serv srv.Server, sock socket.ClientSocketer, resp *response.Response, viewID string) error

SendToClient sends back to client response object rendered with a specific View. TODO: measure request time?

type Applicationer

type Applicationer interface {
	GetConfig() AppConfiger
	GetLogger() logger.Logger
	GetMD() *Metadata
	GetServer(string) srv.Server
	GetServers() ServerList
	SendToClient(srv.Server, socket.ClientSocketer, *response.Response, string) error
	HandleRequest(srv.Server, socket.ClientSocketer, string, string, string, []byte, string)
	HandleJSONRequest(srv.Server, socket.ClientSocketer, []byte, string)
	HandleSession(socket.ClientSocketer) error
	DestroySession(sessID string)
	HandlePermission(socket.ClientSocketer, string, string) error
	HandleServerError(srv.Server, socket.ClientSocketer, string, string)
	GetSessManager() *session.Manager
	//XSLTransform([]byte, string, string, string) ([]byte, error)
	//XSLToPDFTransform(string, string, []string, []byte, string, string, string) ([]byte, error)
	GetFrameworkVersion() string
	GetPermisManager() Permissioner
	GetOnPublishEvent() OnPublishEventProto
	GetDataStorage() interface{}
	PublishPublicMethodEvents(PublicMethod, map[string]interface{})
	GetEncryptKey() string
	GetBaseDir() string
	LoadAppVersion() error
	ReloadAppConfig() error
}

Applicationer interface is used in all standart controller methods as a parameter.

type ArgConditions

type ArgConditions struct {
	Fields   []string
	Signs    []sql.SQLCondition
	Values   []interface{}
	InsCases []bool
	Joins    []ConditionJoin
}

func ParseSQLWhereFromArgs

func ParseSQLWhereFromArgs(rfltArgs reflect.Value, fieldSep string, modelMetadata fields.FieldCollection) (*ArgConditions, error)

parses reflect.Value, extracts data from cond_fields, cond_sgns, cond_ic, cond_vals, cond_joins returns cond_fields - slice of string cond_sgns - slice of sql.SQLCondition cond_vals - slice of interface{} cond_ic - slice of []bool

func (*ArgConditions) FieldValue

func (a *ArgConditions) FieldValue(fieldID string, cond sql.SQLCondition) (interface{}, error)

type Base_Controller

type Base_Controller struct {
	ID            string
	PublicMethods PublicMethodCollection
}

Base_Controller is a parent structure for all controllers.

func (*Base_Controller) GetID

func (c *Base_Controller) GetID() string

func (*Base_Controller) GetPublicMethod

func (c *Base_Controller) GetPublicMethod(publicMethodID PublicMethodID) (PublicMethod, error)

type Base_PublicMethod

type Base_PublicMethod struct {
	ID        string
	Fields    fields.FieldCollection
	EventList PublicMethodEventList
}

func (*Base_PublicMethod) AddEvent

func (pm *Base_PublicMethod) AddEvent(evId string)

func (*Base_PublicMethod) GetEventList

func (pm *Base_PublicMethod) GetEventList() PublicMethodEventList

func (*Base_PublicMethod) GetFields

func (pm *Base_PublicMethod) GetFields() fields.FieldCollection

func (*Base_PublicMethod) GetID

func (pm *Base_PublicMethod) GetID() PublicMethodID

type ConditionJoin

type ConditionJoin int
const (
	CONDITION_JOIN_AND ConditionJoin = iota
	CONDITION_JOIN_OR
)

func (ConditionJoin) Sql

func (c ConditionJoin) Sql() string

type Constant

type Constant interface {
	GetAutoload() bool               // if constant is sent to client at first request.
	Sanatize(string) (string, error) // manages value validation.
}

Constant describes application constant object.

type ConstantBytea

type ConstantBytea struct {
	ID       string
	Autoload bool
	Value    fields.ValBytea
}

******************************

func (*ConstantBytea) GetAutoload

func (c *ConstantBytea) GetAutoload() bool

func (*ConstantBytea) GetValue

func (c *ConstantBytea) GetValue(app Applicationer) ([]byte, error)

func (*ConstantBytea) Sanatize

func (c *ConstantBytea) Sanatize(val string) (string, error)

type ConstantCollection

type ConstantCollection map[string]Constant

ConstantCollection is a collection of all application constants.

func (ConstantCollection) Exists

func (c ConstantCollection) Exists(ID string) bool

Exists returns true if a given constant exists.

type ConstantFloat

type ConstantFloat struct {
	ID       string
	Autoload bool
	Value    fields.ValFloat
}

******************************

func (*ConstantFloat) GetAutoload

func (c *ConstantFloat) GetAutoload() bool

func (*ConstantFloat) GetValue

func (c *ConstantFloat) GetValue(app Applicationer) (float64, error)

func (*ConstantFloat) Sanatize

func (c *ConstantFloat) Sanatize(val string) (string, error)

type ConstantInt

type ConstantInt struct {
	ID       string        // constant ID
	Autoload bool          // if autoload
	Value    fields.ValInt // constant value
}

ConstantInt is a constant of integer type.

func (*ConstantInt) GetAutoload

func (c *ConstantInt) GetAutoload() bool

func (*ConstantInt) GetValue

func (c *ConstantInt) GetValue(app Applicationer) (int64, error)

GetValue return constant value. TODO: caching. Clear value on updates through events.

func (*ConstantInt) Sanatize

func (c *ConstantInt) Sanatize(val string) (string, error)

Sanatize sanatizes value for db.

type ConstantInterval

type ConstantInterval = ConstantTime

******************************

type ConstantJSON

type ConstantJSON struct {
	ID       string
	Autoload bool
	Value    fields.ValJSON
}

******************************

func (*ConstantJSON) GetAutoload

func (c *ConstantJSON) GetAutoload() bool

func (*ConstantJSON) GetValue

func (c *ConstantJSON) GetValue(app Applicationer) ([]byte, error)

func (*ConstantJSON) Sanatize

func (c *ConstantJSON) Sanatize(val string) (string, error)

type ConstantText

type ConstantText struct {
	ID       string
	Autoload bool
	Value    fields.ValText
}

ConstantText is string value constant

func (*ConstantText) GetAutoload

func (c *ConstantText) GetAutoload() bool

func (*ConstantText) GetValue

func (c *ConstantText) GetValue(app Applicationer) (string, error)

func (*ConstantText) Sanatize

func (c *ConstantText) Sanatize(val string) (string, error)

TODO: string validating.

type ConstantTime

type ConstantTime struct {
	ID       string
	Autoload bool
	Value    fields.ValTime
}

func (*ConstantTime) GetAutoload

func (c *ConstantTime) GetAutoload() bool

func (*ConstantTime) GetValue

func (c *ConstantTime) GetValue(app Applicationer) (time.Time, error)

func (*ConstantTime) Sanatize

func (c *ConstantTime) Sanatize(val string) (string, error)

type Controller

type Controller interface {
	//InitPublicMethods()
	GetPublicMethod(PublicMethodID) (PublicMethod, error)
	GetID() string
}

Controller is an application controller interface.

type ControllerCollection

type ControllerCollection map[string]Controller

ControllerCollection is a list of application controllers.

func (*ControllerCollection) ParseCommand

func (c *ControllerCollection) ParseCommand(controllerID string, methodID string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)

ParseCommand parses command from separated controller,method IDs

func (*ControllerCollection) ParseFunctionCommand

func (c *ControllerCollection) ParseFunctionCommand(fn string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)

ParseFunctionCommand parses command from function string of type ControllerID.MethodID.

func (*ControllerCollection) ParseJSONCommand

func (c *ControllerCollection) ParseJSONCommand(payload []byte) (Controller, PublicMethod, reflect.Value, string, string, error)

ParseJSONCommand parses external command from JSON string of arguments argument "func" at least MUST exist! Returns:

public method interface,
argv - all parsed arguments not validated, returned as reflect.Value,
query id
view id
error if any

type DbConn

type DbConn interface {
	//Prepare(ctx context.Context, queryID string, query string) error
	//Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...any) DbRow
}

type DbRow

type DbRow interface {
	Scan(dest ...any) error
}

type DbRows

type DbRows interface {
	Close()
	Err() error
	Next() bool
	Scan(dest ...any) error
}

type Enum

type Enum map[string]EnumDescrCollection

func (*Enum) CheckValue

func (e *Enum) CheckValue(v string) bool

CheckValue checks if a given value is in enum value list of values.

func (*Enum) GetDescription

func (e *Enum) GetDescription(v string, localeID string) string

GetDescription retrieves enum description for a specific language.

type EnumCollection

type EnumCollection map[string]Enumer

EnumCollection is an application enum list.

type EnumDescrCollection

type EnumDescrCollection map[string]string //holds language specific description of enum values.

type Enumer

type Enumer interface {
	CheckValue(string) bool               // checks if value exists in the given Enum
	GetDescription(string, string) string // returns description for a specific localeID
}

Enumer

type ExtCommand

type ExtCommand struct {
	Func     string `json:"func"` //function Controller.method
	Query_id string `json:"query_id"`
	View_id  string `json:"view_id"`
}

ExtCommand represents external client query command.

type LocaleID

type LocaleID string
const (
	LOCALE_RU LocaleID = "ru"
	LOCALE_EN LocaleID = "en"
)

type Metadata

type Metadata struct {
	Debug       bool
	Owner       string // holds owner information
	DataSchema  string
	Version     VersionType
	Controllers ControllerCollection
	Models      ModelMDCollection
	Enums       EnumCollection
	Constants   ConstantCollection
}

Metadata is the metadata structure. Maps metadata.xml file.

func NewMetadata

func NewMetadata() *Metadata

NewMetadata creates new Metadata object

type ModelMDCollection

type ModelMDCollection map[string]*model.ModelMD

ModelMDCollection

type OnPublishEventProto

type OnPublishEventProto = func(string, string)

type OnReloadConfigProto

type OnReloadConfigProto = func()

type Permissioner

type Permissioner interface {
	Reload() error
	IsAllowed(role, controller, method string) bool
}

type PublicMethod

type PublicMethod interface {
	GetID() PublicMethodID
	GetFields() fields.FieldCollection
	Unmarshal(payload []byte) (reflect.Value, error)
	Run(Applicationer, srv.Server, socket.ClientSocketer, *response.Response, reflect.Value) error
	GetEventList() PublicMethodEventList
}

type PublicMethodCollection

type PublicMethodCollection map[PublicMethodID]PublicMethod

type PublicMethodError

type PublicMethodError struct {
	Code int
	Err  error
}

func NewPublicMethodError

func NewPublicMethodError(code int, err string) *PublicMethodError

func (PublicMethodError) Error

func (e PublicMethodError) Error() string

type PublicMethodEventList

type PublicMethodEventList []string

type PublicMethodID

type PublicMethodID string

public method

type PublicMethodWithEvent

type PublicMethodWithEvent interface {
	GetEventList() PublicMethodEventList
	AddEvent(string)
}

type RunnableServer

type RunnableServer interface {
	Run()
	Shutdown(context.Context) error
}

type SQLDirectType

type SQLDirectType byte
const (
	DIRECT_ASC  SQLDirectType = iota
	DIRECT_DESC SQLDirectType = iota
)

type SQLOrder

type SQLOrder struct {
	Expr   string
	Direct SQLDirectType
}

type SQLOrders

type SQLOrders []SQLOrder

func NewSQLOrderByFromArgs

func NewSQLOrderByFromArgs(rfltArgs reflect.Value, fieldSep string) *SQLOrders

type ServerList

type ServerList map[string]srv.Server

ServerList is a list of running servers. Defined on application startup.

type VersionType

type VersionType struct {
	DateOpen  time.Time // open for modification timestamp
	DateClose time.Time // close version timestamp
	Value     string    // version value
}

VersionType structures holds metadata version information.

type XMLer

type XMLer interface {
	Value() (driver.Value, error)
	GetIsNull() bool
}

Directories

Path Synopsis
About package holds About application information.
About package holds About application information.
config module
Constants package manages application constants.
Constants package manages application constants.
md module
pg
repo
srv
tcpSrv/cl command
pdf
xml

Jump to

Keyboard shortcuts

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