common

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SEP defines separator string used for displaying purpose
	SEP = "================================================================================"

	// TIMEZONE defines the timezone used for all examples
	TIMEZONE = "Asia/Ho_Chi_Minh"
)
View Source
var ColsSql = []string{"id", "val_desc", "val_bool", "val_int", "val_float", "val_string",
	"val_time", "val_timez", "val_date", "val_datez", "val_datetime", "val_datetimez", "val_timestamp", "val_timestampz",
	"val_list", "val_map"}

ColsSql holds name of database table columns.

Functions

func PrintApp

func PrintApp(app *BoApp)

PrintApp prints a BoApp's info to stdout.

Types

type BoApp

type BoApp struct {
	Id            string                 `json:"id"`
	Description   string                 `json:"val_desc"`
	ValBool       bool                   `json:"val_bool"`
	ValInt        int                    `json:"val_int"`
	ValFloat      float64                `json:"val_float"`
	ValString     string                 `json:"val_string"`
	ValTime       time.Time              `json:"val_time"`
	ValTimeZ      time.Time              `json:"val_timez"`
	ValDate       time.Time              `json:"val_date"`
	ValDateZ      time.Time              `json:"val_datez"`
	ValDatetime   time.Time              `json:"val_datetime"`
	ValDatetimeZ  time.Time              `json:"val_datetimez"`
	ValTimestamp  time.Time              `json:"val_timestamp"`
	ValTimestampZ time.Time              `json:"val_timestampz"`
	ValList       []interface{}          `json:"val_list"`
	ValMap        map[string]interface{} `json:"val_map"`
}

BoApp defines business object app

func (*BoApp) FromGenericBo

func (app *BoApp) FromGenericBo(gbo godal.IGenericBo) *BoApp

FromGenericBo imports BoApp's data from a godal.IGenericBo instance.

func (*BoApp) ToGenericBo

func (app *BoApp) ToGenericBo() godal.IGenericBo

ToGenericBo transforms BoApp to godal.IGenericBo

func (*BoApp) ToJson

func (app *BoApp) ToJson() []byte

ToJson serializes BoApp to JSON string.

type DaoAppSql

type DaoAppSql struct {
	// *sql.GenericDaoSql
	sql.IGenericDaoSql
	TableName string
}

DaoAppSql is SQL-based DAO implementation.

func (*DaoAppSql) Create

func (dao *DaoAppSql) Create(bo *BoApp) (bool, error)

Create implements IDaoApp.Create

func (*DaoAppSql) Delete

func (dao *DaoAppSql) Delete(bo *BoApp) (bool, error)

Delete implements IDaoApp.Delete

func (*DaoAppSql) EnableTxMode

func (dao *DaoAppSql) EnableTxMode(txMode bool)

EnableTxMode implements IDaoApp.EnableTxMode

func (*DaoAppSql) GdaoCreateFilter

func (dao *DaoAppSql) GdaoCreateFilter(_ string, bo godal.IGenericBo) godal.FilterOpt

GdaoCreateFilter implements godal.IGenericDao.GdaoCreateFilter.

func (*DaoAppSql) Get

func (dao *DaoAppSql) Get(id string) (*BoApp, error)

Get implements IDaoApp.Get

func (*DaoAppSql) GetAll

func (dao *DaoAppSql) GetAll() ([]*BoApp, error)

GetAll implements IDaoApp.GetAll

func (*DaoAppSql) GetN

func (dao *DaoAppSql) GetN(startOffset, numRows int) ([]*BoApp, error)

GetN implements IDaoApp.GetN

func (*DaoAppSql) Update

func (dao *DaoAppSql) Update(bo *BoApp) (bool, error)

Update implements IDaoApp.Update

func (*DaoAppSql) Upsert

func (dao *DaoAppSql) Upsert(bo *BoApp) (bool, error)

Upsert implements IDaoApp.Upsert

type IDaoApp

type IDaoApp interface {
	// EnableTxMode enables/disables transaction mode
	EnableTxMode(txMode bool)

	// Delete removes an app from database store.
	Delete(bo *BoApp) (bool, error)

	// Create persists a new app to database store. If the app already existed, this function returns (false, nil)
	Create(bo *BoApp) (bool, error)

	// Get finds an app by id & fetches it from database store.
	Get(id string) (*BoApp, error)

	// GetAll retrieves all available apps from database store and returns them as a list.
	GetAll() ([]*BoApp, error)

	// GetN retries apps from database store with paging.
	GetN(startOffset, numRows int) ([]*BoApp, error)

	// Update modifies an existing app in the database store. If the application does not exist in database, this function returns (false, nil).
	Update(bo *BoApp) (bool, error)

	// Upsert performs "update-or-create" on the specified app: the app is updated/modified if it already existed, otherwise it is created.
	Upsert(bo *BoApp) (bool, error)
}

IDaoApp defines DAO APIs for apps

Jump to

Keyboard shortcuts

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