libQuery

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PREPARE_ERROR = -1
	QUERY_ERROR   = -2
	PARSE_ERROR   = -3
	SCAN_ERROR    = -4
)
View Source
const (
	NO_DATA_FOUND       = "NO_DATA_FOUND"
	DB_READ_ERROR       = "DB_READ_ERROR"
	PARSE_DB_RESP_ERROR = "PARSE_DB_RESP_ERROR"
)

Variables

This section is empty.

Functions

func CallSql

func CallSql[R any](query string,
	core QueryRunnerInterface,
	args ...any) (int, string, string, []R, error)

func ConvertJsonToStruct

func ConvertJsonToStruct[Q any](row string) (Q, error)

func Fill

func Fill[Data any](
	query string,
	core QueryRunnerInterface,
	args ...any,
) ([]Data, string, string, error)

func Filler

func Filler[Data any](
	query string,
	core QueryRunnerInterface,
	args ...any,
) (Data, string, string, error)

func GetQueryResp

func GetQueryResp[R any](query string, core QueryRunnerInterface, args ...any) (int, string, string, bool, any, error)

func HandleCheckDuplicate

func HandleCheckDuplicate(code int, desc, dupDesc string, record []QueryData, err error) (int, string, error)

func HandleCheckExistence added in v0.3.6

func HandleCheckExistence(code int, desc, notExistDesc string, record []QueryData, err error) (int, string, error)

func ParseCommand

func ParseCommand(command, user, app, action, title string, value map[string]string, parser FieldParser) string

func ParseQueryResult

func ParseQueryResult(result map[string]any, t reflect.Type, v reflect.Value)

Types

type DmlResult

type DmlResult struct {
	Rows         map[string]string `json:"rows" form:"rows"`
	LastInsertId int64             `json:"lastId" form:"lastId"`
	RowsAffected int64             `json:"rowsAffected" form:"rowsAffected"`
}

func (*DmlResult) LoadFromMap

func (c *DmlResult) LoadFromMap(m any) error

type FieldParser

type FieldParser interface {
	Parse(string) string
}

type Insertable

type Insertable interface {
	GetUniqueId() string
	GetCountCommand() string
	GetInsertCommand() (string, []any)
}

type QueryData

type QueryData struct {
	DataRaw    string   `json:"result,omitempty" db:"result"`
	Key        string   `json:"key,omitempty" db:"key"`
	Value      string   `json:"value,omitempty" db:"value"`
	ValueArray []string `json:"valueArray,omitempty" db:"values"`
	MapList    string   `json:"mapList,omitempty" db:"map_list"`
}

type QueryRunnerInterface

type QueryRunnerInterface interface {
	QueryRunner(querySql string, args ...any) (int, []any, error)
	QueryToStruct(querySql string, target any, args ...any) (int, any, error)
	CallDbFunction(callString string, args ...any) (int, string, error)
	GetModule() (string, string)
	InsertRow(insert string, args ...any) (sql.Result, error)
}

type QueryRunnerModel

type QueryRunnerModel struct {
	DB          *sql.DB
	ProgramName string
	ModuleName  string
}

func (QueryRunnerModel) CallDbFunction

func (m QueryRunnerModel) CallDbFunction(callString string, args ...any) (int, string, error)

func (QueryRunnerModel) GetModule

func (m QueryRunnerModel) GetModule() (string, string)

func (QueryRunnerModel) InsertRow

func (m QueryRunnerModel) InsertRow(insert string, args ...any) (sql.Result, error)

func (QueryRunnerModel) QueryRunner

func (m QueryRunnerModel) QueryRunner(querySql string, args ...any) (int, []any, error)

func (QueryRunnerModel) QueryToStruct

func (m QueryRunnerModel) QueryToStruct(querySql string, target any, args ...any) (int, any, error)

type QueryWithDeps

type QueryWithDeps interface {
	GetFillable(core QueryRunnerInterface) (map[string]any, error)
}

type RecordData

type RecordData interface {
	GetId() string
	GetControlId(string) string
	GetIdList() []any
	SetId(string)
	SetValue(string)
	GetSubCategory() string
	GetValue() any
	GetValueMap() map[string]string
}

type RecordDataDml

type RecordDataDml interface {
	SetId(string)
	CheckDuplicate(core QueryRunnerInterface) (int, string, error)
	Filler(headers map[string][]string, core QueryRunnerInterface, args ...any) (string, error)
	Post(core QueryRunnerInterface, args map[string]string) (DmlResult, int, string, error)
	CheckExistence(core QueryRunnerInterface) (int, string, error)
	PreControl(core QueryRunnerInterface) (int, string, error)
	Put(core QueryRunnerInterface, args map[string]string) (DmlResult, int, string, error)
}

type RecordDataGet

type RecordDataGet interface {
	GetId() string
	GetControlId(string) string
	GetIdList() []any
	GetSubCategory() string
	GetValue() any
}

type Updatable

type Updatable interface {
	SetParams(args map[string]string) any
	GetUniqueId() []any
	GetCountCommand() string
	GetUpdateCommand() (string, []any)
	Finalize(QueryRunnerInterface) (string, error)
}

Jump to

Keyboard shortcuts

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