Documentation ¶
Index ¶
- Variables
- func Close() error
- func Cols(query string, args ...interface{}) ([]string, error)
- func CommandExists(commands []TypeCommand, commandName string) bool
- func Del(ownerId int64, moduleId, ejaId int64) error
- func FieldAdd(tableName string, fieldName string, fieldType string) error
- func FieldExists(tableName string, fieldName string) (bool, error)
- func FieldNameIsValid(name string) error
- func FieldNameList(moduleId int64, actionType string) (fields []string)
- func FieldType(name string) string
- func FieldTypeGet(moduleId int64, fieldName string) string
- func Float(nameValue interface{}) float64
- func IncludeList(query string, args ...interface{}) ([]int64, error)
- func LinkAdd(ownerId int64, moduleId int64, fieldId int64, linkModuleId int64, ...) error
- func LinkDel(ownerId int64, moduleId int64, fieldId int64, linkModuleId int64, ...) error
- func ModuleGetIdByName(name string) int64
- func ModuleGetNameById(id int64) string
- func ModuleImport(module TypeModule, moduleName string) error
- func New(ownerId int64, moduleId int64) (int64, error)
- func Now() string
- func Number(nameValue interface{}) int64
- func NumbersToCsv(slice []int64) string
- func Open(engine string, database string, username string, password string, host string, ...) error
- func Owners(ownerId int64, moduleId int64) (result []int64)
- func OwnersCsv(ownerId int64, moduleId int64) string
- func Password(value string) string
- func PermissionAdd(userId int64, moduleId int64, commandName string) int64
- func PermissionAddDefault(userId int64, moduleId int64) int64
- func PermissionCount(moduleId int64) int64
- func Put(ownerId int64, moduleId int64, ejaId int64, fieldName string, ...) error
- func SearchCount(query string, args []interface{}) int64
- func SearchLinks(ownerId int64, srcModuleId int64, srcFieldId int64, dstModuleId int64) []string
- func SearchQuery(ownerId int64, tableName string, values map[string]string) (string, []interface{}, error)
- func SearchQueryLinks(ownerId, srcModuleId, srcFieldId, dstModuleId int64) string
- func SearchQueryOrderAndLimit(order string, limit int64, offset int64) string
- func SessionCleanLink(userId int64) error
- func SessionCleanSearch(userId int64) error
- func SessionInit(userId int64) string
- func SessionPut(userId int64, name string, value string, subName ...string) (err error)
- func SessionReset(userId int64) error
- func Setup(setupPath string) error
- func SetupAdmin(setupUser string, setupPass string) error
- func Sha256(value string) string
- func String(nameValue interface{}) string
- func TableAdd(name string, tmp ...bool) error
- func TableDel(name string) error
- func TableExists(name string) (bool, error)
- func TableNameIsValid(name string) error
- func Translate(value string, user ...int64) string
- func UserGroupCsv(userId int64) string
- func UserGroupList(userId int64) []int64
- func UserPermissionCopy(userId int64, moduleId int64)
- func Value(query string, args ...interface{}) (result string, err error)
- type TypeCommand
- type TypeField
- type TypeLink
- type TypeModule
- type TypeModuleField
- type TypeModuleModule
- type TypeModulePath
- type TypeModuleTranslation
- type TypeModuleTree
- type TypeRow
- func Get(ownerId int64, moduleId int64, ejaId int64) (TypeRow, error)
- func Row(query string, args ...interface{}) (result TypeRow, err error)
- func TableGetAllById(tableName string, ejaId int64) TypeRow
- func UserGetAllById(userId int64) TypeRow
- func UserGetAllBySession(session string) TypeRow
- func UserGetAllByUserAndPass(username string, password string) TypeRow
- type TypeRows
- func Rows(query string, args ...interface{}) (result TypeRows, err error)
- func SearchMatrix(ownerId int64, moduleId int64, query string, queryArgs []interface{}) (resultRows TypeRows, resultCols []string, resultLabels map[string]string, ...)
- func SessionLoad(userId int64, moduleId int64) (TypeRows, error)
- type TypeRun
- type TypeSearchColumn
- type TypeSelect
Constants ¶
This section is empty.
Variables ¶
var Assets embed.FS
var DbConnectionId int64
DbConnectionId holds the current database connection
var DbEngine string
DbEngine holds the current database engine in use (e.g., "sqlite", "mysql").
var DbHandler *sql.DB
DbHandler is the database handler representing the open database connection.
Functions ¶
func Cols ¶
Cols executes a query with optional parameters and returns the column names of the result set.
func CommandExists ¶
func CommandExists(commands []TypeCommand, commandName string) bool
CommandExists checks if a given command exists in the provided list of commands.
func FieldExists ¶
FieldExists checks whether a field with the given name already exists in the specified table.
func FieldNameIsValid ¶
FieldNameIsValid checks the validity of a field name based on the current database engine.
func FieldNameList ¶
FieldNameList retrieves a list of field names based on the provided module ID and action type.
func FieldTypeGet ¶
FieldTypeGet retrieves the field type for a specific field in a module based on module ID and field name.
func Float ¶
func Float(nameValue interface{}) float64
Float converts a value to a float64. It handles various numeric types and attempts to parse a string as a float64. If parsing fails, it returns 0.0.
func IncludeList ¶
IncludeList executes a query and returns a slice of int64 values from the first column of the result.
func LinkAdd ¶
func LinkAdd(ownerId int64, moduleId int64, fieldId int64, linkModuleId int64, linkFieldId int64) error
LinkAdd adds a new link between modules and fields.
func LinkDel ¶
func LinkDel(ownerId int64, moduleId int64, fieldId int64, linkModuleId int64, linkFieldId int64) error
LinkDel deletes a link between modules and fields.
func ModuleGetIdByName ¶
ModuleGetIdByName retrieves the module ID based on the given module name. If an error occurs during the database operation or table name is not valid, it returns 0.
func ModuleGetNameById ¶
ModuleGetNameById retrieves the module name based on the given module ID. If an error occurs during the database operation or table name is not valid, it returns an empty string.
func ModuleImport ¶
func ModuleImport(module TypeModule, moduleName string) error
ModuleImport imports a module into the database based on the provided TypeModule and module name.
func New ¶
New creates a new entry in the specified module table with the given ownerId and moduleId.
func Number ¶
func Number(nameValue interface{}) int64
Number converts a value to an int64. It handles various numeric types and attempts to parse a string as an int64. If parsing fails, it returns 0.
func NumbersToCsv ¶
NumbersToCsv converts a slice of int64 numbers into a comma-separated string.
func Open ¶
func Open(engine string, database string, username string, password string, host string, port int) error
Open initializes a connection to the specified database using the provided parameters.
func Owners ¶
Owners retrieves a list of user IDs who are owners of the specified module ID and have certain group associations. The function recursively checks group memberships up to a certain depth.
func OwnersCsv ¶
OwnersCsv retrieves a comma-separated string of user IDs who are owners of the specified module ID and have certain group associations.
func PermissionAdd ¶
PermissionAdd adds a permission for the specified user, module, and command.
func PermissionAddDefault ¶
PermissionAddDefault adds default permissions for the specified user and module.
func PermissionCount ¶
PermissionCount returns the count of permissions associated with the specified module.
func Put ¶
Put updates a specific field in a row of the specified module table based on ownerId, moduleId, ejaId, fieldName, and fieldValue.
func SearchCount ¶
SearchCount calculates the number of records for a given search query and arguments.
func SearchLinks ¶
SearchLinks searches for links associated with a specified module, field, and owner ID.
func SearchQuery ¶
func SearchQuery(ownerId int64, tableName string, values map[string]string) (string, []interface{}, error)
SearchQuery generates a SQL query for searching records in a specified table based on provided criteria.
func SearchQueryLinks ¶
SearchQueryLinks generates a condition for searching based on related links.
func SearchQueryOrderAndLimit ¶
SearchQueryOrderAndLimit generates an ORDER BY, LIMIT, and OFFSET clause for search queries.
func SessionCleanLink ¶
SessionCleanLink removes specific session variables related to links for a specified user.
func SessionCleanSearch ¶
SessionCleanSearch removes specific session variables related to searches for a specified user.
func SessionInit ¶
SessionInit generates a new session for the specified user and updates the database.
func SessionPut ¶
SessionPut stores a session variable for a specified user in the database.
func SessionReset ¶
SessionReset removes all session variables for a specified user from the database.
func Setup ¶
Setup initializes the database with modules, fields, and commands. It reads JSON files from the specified setupPath or embeded assets, and populates the database accordingly. The admin user credentials are used for setup.
func SetupAdmin ¶
func String ¶
func String(nameValue interface{}) string
String converts a value to a string. It handles various types, including string, int, int64, float32, float64, and []uint8.
func TableAdd ¶
TableAdd creates a new table with the specified name in the database. If the table already exists, it does nothing. The optional 'tmp' parameter specifies whether the table is temporary.
func TableDel ¶
TableDel deletes the table with the specified name from the database. If the table does not exist, it returns an error.
func TableExists ¶
TableExists checks if a table with the specified name exists in the database.
func TableNameIsValid ¶
TableNameIsValid checks if a table name is valid according to the current database engine's conventions.
func Translate ¶
Translate retrieves the translation for the specified word based on the current session's language and module context. If a translation is not found, it returns a placeholder string indicating that the translation is missing.
func UserGroupCsv ¶
UserGroupCsv returns a comma-separated string of group IDs associated with a user.
func UserGroupList ¶
UserGroupList retrieves the list of group IDs associated with a user.
func UserPermissionCopy ¶
UserPermissionCopy copies user permissions from one module to another.
Types ¶
type TypeCommand ¶
TypeCommand represents a command with its properties.
type TypeField ¶
type TypeField struct { Type string Name string Label string Value string Options []TypeSelect }
TypeField represents a field in a database with metadata.
type TypeLink ¶
type TypeLink struct { Label string `json:"Label,omitempty"` ModuleId int64 `json:"ModuleId,omitempty"` ModuleLabel string `json:"ModuleLabel,omitempty"` FieldId int64 `json:"FieldId,omitempty"` }
TypeLink represents a link between modules and fields.
func ModuleLinks ¶
ModuleLinks retrieves a list of links associated with a specified module.
type TypeModule ¶
type TypeModule struct { Module TypeModuleModule `json:"module"` Command []string `json:"command"` Field []TypeModuleField `json:"field"` Translation []TypeModuleTranslation `json:"translation"` Name string `json:"name"` Data []map[string]interface{} `json:"data"` }
TypeModule represents a modular structure containing information about modules, fields, translations, and data.
func ModuleExport ¶
func ModuleExport(moduleId int64, data bool) (module TypeModule, err error)
ModuleExport exports a module.
type TypeModuleField ¶
type TypeModuleField struct { Value string `json:"value"` PowerEdit int64 `json:"powerEdit"` PowerList int64 `json:"powerList"` Type string `json:"type"` Translate int64 `json:"translate"` PowerSearch int64 `json:"powerSearch"` Name string `json:"name"` }
TypeModuleField represents metadata about a field within a TypeModule.
type TypeModuleModule ¶
type TypeModuleModule struct { ParentName string `json:"parentName,omitempty"` Power int64 `json:"power"` SearchLimit int64 `json:"searchLimit"` SqlCreated int64 `json:"sqlCreated"` SortList string `json:"sortList,omitempty"` }
TypeModuleModule represents metadata about a module within a TypeModule.
type TypeModulePath ¶
TypeModulePath represents a node in the module hierarchy with its ID, name, and translated label.
func ModulePath ¶
func ModulePath(ownerId int64, moduleId int64) (result []TypeModulePath)
ModulePath retrieves the path of module hierarchy from the specified module to its root for a given user.
type TypeModuleTranslation ¶
type TypeModuleTranslation struct { EjaLanguage string `json:"ejaLanguage"` EjaModuleName string `json:"ejaModuleName,omitempty"` Word string `json:"word"` Translation string `json:"translation"` }
TypeModuleTranslation represents translation information within a TypeModule.
type TypeModuleTree ¶
TypeModuleTree represents a node in the module tree.
func ModuleTree ¶
func ModuleTree(ownerId int64, moduleId int64, modulePath []TypeModulePath) (result []TypeModuleTree)
ModuleTree generates a tree structure of modules accessible to a user based on permissions and ownership.
type TypeRow ¶
TypeRow is a map representing a single row of data in the database.
func Get ¶
Get retrieves a row from the specified module table based on ownerId, moduleId, and ejaId.
func Row ¶
Row executes a query with optional parameters and returns a single row of results as a TypeRow.
func TableGetAllById ¶
TableGetAllById retrieves a row from the specified table based on the ejaId field.
func UserGetAllById ¶
UserGetAllById retrieves all user information based on the provided user ID.
func UserGetAllBySession ¶
UserGetAllBySession retrieves user information based on the provided session.
func UserGetAllByUserAndPass ¶
UserGetAllByUserAndPass retrieves user information based on the provided username and hashed password.
type TypeRows ¶
TypeRows is a slice of maps representing multiple rows of data in the database.
func Rows ¶
Rows executes a query with optional parameters and returns multiple rows of results as a TypeRows.
type TypeRun ¶
TypeRun represents the result of a database operation, including the number of changes and the last inserted ID.
type TypeSearchColumn ¶
TypeSearchColumn represents a mapping of column names to their properties and values.
type TypeSelect ¶
TypeSelect represents a key-value pair used for dropdowns or selection lists.
func SelectSqlToRows ¶
func SelectSqlToRows(query string) []TypeSelect
SelectSqlToRows executes a SQL query and converts the result into a slice of TypeSelect structures.
func SelectToRows ¶
func SelectToRows(value string) []TypeSelect
SelectToRows converts a pipe-separated or newline-separated string into a slice of TypeSelect structures.