-
Roshan Patil authored84295d4f
servicebuildermdl.go 9.69 KiB
//@author Ajit Jagtap
//@version Mon Jul 09 2018 14:00:05 GMT+0530 (IST)
// Package servicebuildermdl will help you run BL and fetch data.
package servicebuildermdl
import (
"strings"
"sync"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/validationmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"github.com/oleksandr/conditions"
"github.com/tidwall/gjson"
)
var ruleCache map[string]conditions.Expr
var mutex = &sync.Mutex{}
func init() {
ruleCache = make(map[string]conditions.Expr)
}
// LoadData is a method sign for loader methods
type LoadData = func(ab *AbstractBusinessLogicHolder) error
// FinalStepProcessOutput is a method sign for loader methods
type FinalStepProcessOutput = func(ab *AbstractBusinessLogicHolder) (*interface{}, error)
// AbstractBusinessLogicHolder use this type to inheritance
type AbstractBusinessLogicHolder struct {
localServiceData map[string]interface{}
pricipalObject Principal
}
// GetDataString will give you string
func (ab *AbstractBusinessLogicHolder) GetDataString(key string) (string, bool) {
//check in map
temp, found := ab.localServiceData[key]
if errormdl.CheckBool(!found) {
return "", false
}
// cast it
value, ok := temp.(string)
if errormdl.CheckBool1(!ok) {
return "", false
}
return value, true
}
// GetDataInt will give you int
func (ab *AbstractBusinessLogicHolder) GetDataInt(key string) (int64, bool) {
//check in map
temp, found := ab.localServiceData[key]
if errormdl.CheckBool(!found) {
return 0, false
}
// cast it
value, ok := temp.(int64)
if errormdl.CheckBool1(!ok) {
return 0, false
}
return value, true
}
// GetDataResultset will give you int