basedto

package
v1.0.1-rel-02 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: AFL-3.0 Imports: 24 Imported by: 0

README

BaseEntity

所有类基类、多实例

BaseEntitySingke

所有类基类、单例

BaseProxy通用代码类

结合BaseEntit使用

IchubResult通用结果类

Documentation

Overview

Package gmeta provides embedded gometa data feature for struct.

Index

Constants

View Source
const CODE_FAIL = CODE_SERVER_ERR
View Source
const CODE_NOFOUND_RECORD = 510
View Source
const CODE_REQUEST_BAD = 400
View Source
const CODE_SERVER_ERR = 500
View Source
const CODE_SUCCESS = 200

Variables

This section is empty.

Functions

func Data

func Data(object interface{}) map[string]string

Data retrieves and returns all metadata from `object`.

func Get

func Get(object interface{}, key string) *gvar.Var

Get retrieves and returns specified metadata by `key` from `object`.

func LoadBeanProxy

func LoadBeanProxy[T baseiface.IbaseProxy]() T

func ParseMaps2Models

func ParseMaps2Models[T any](str string, models *[]T)

Types

type BaseEntity

type BaseEntity struct {
	Proxy    func() *BaseProxy             `json:"-" gorm:"-"`
	Bindings map[string]baseiface.LoadBean `json:"-" gorm:"-"`

	RootDir string `json:"-" gorm:"-"`
	Ver     string `json:"-"  gorm:"-"`
}

func NewBaseEntity

func NewBaseEntity() *BaseEntity

func (*BaseEntity) Autowire

func (self *BaseEntity) Autowire()

func (*BaseEntity) Bind

func (self *BaseEntity) Bind()

func (*BaseEntity) BindUp

func (self *BaseEntity) BindUp(key string, load baseiface.LoadBean)

func (*BaseEntity) Check

func (self *BaseEntity) Check() error

func (*BaseEntity) Clone

func (self *BaseEntity) Clone() any

func (*BaseEntity) ContainsStru

func (self *BaseEntity) ContainsStru(v any) bool

func (*BaseEntity) CopyWithOption

func (self *BaseEntity) CopyWithOption(from interface{})

func (*BaseEntity) FindBinding

func (self *BaseEntity) FindBinding(key string) baseiface.LoadBean

func (*BaseEntity) FindNameOfIface

func (self *BaseEntity) FindNameOfIface() string

func (*BaseEntity) FromJson

func (self *BaseEntity) FromJson(body []byte) any

func (*BaseEntity) HandleCheck

func (self *BaseEntity) HandleCheck() error

func (*BaseEntity) Id2Str

func (self *BaseEntity) Id2Str(id int64) string

func (*BaseEntity) IfAutowire

func (self *BaseEntity) IfAutowire() bool

func (*BaseEntity) Init

func (self *BaseEntity) Init()

func (*BaseEntity) InitChildNilPtr

func (self *BaseEntity) InitChildNilPtr()

func (*BaseEntity) InitProxy

func (self *BaseEntity) InitProxy(some any)

func (*BaseEntity) JsonFromStr

func (self *BaseEntity) JsonFromStr(v string) string

func (*BaseEntity) Log

func (self *BaseEntity) Log()

func (*BaseEntity) Parse2Map

func (self *BaseEntity) Parse2Map() (map[string]any, error)

func (*BaseEntity) ParseTags

func (self *BaseEntity) ParseTags(tagkey string) map[string]string

func (*BaseEntity) Shutdown

func (self *BaseEntity) Shutdown()

func (*BaseEntity) Single

func (self *BaseEntity) Single() bool

func (*BaseEntity) Str2Int

func (self *BaseEntity) Str2Int(from string) int

func (*BaseEntity) String

func (self *BaseEntity) String() string

func (*BaseEntity) ToJson

func (self *BaseEntity) ToJson() string

func (*BaseEntity) ToJsonBytes

func (self *BaseEntity) ToJsonBytes() []byte

func (*BaseEntity) ToJsonStr

func (self *BaseEntity) ToJsonStr() string

func (*BaseEntity) ToPrettyString

func (self *BaseEntity) ToPrettyString() string

func (*BaseEntity) ToString

func (self *BaseEntity) ToString() string

func (*BaseEntity) ToStru

func (entity *BaseEntity) ToStru(out any)

func (*BaseEntity) ValueFrom

func (self *BaseEntity) ValueFrom(value any)

func (*BaseEntity) ValueOf

func (self *BaseEntity) ValueOf(that interface{})

type BaseEntityIndex

type BaseEntityIndex struct {
	BaseEntity
}

func (BaseEntityIndex) GetMapping

func (b BaseEntityIndex) GetMapping() string

func (BaseEntityIndex) PkeyName

func (b BaseEntityIndex) PkeyName() string

func (BaseEntityIndex) PkeyValue

func (b BaseEntityIndex) PkeyValue() any

func (BaseEntityIndex) TableName

func (b BaseEntityIndex) TableName() string

type BaseEntitySingle

type BaseEntitySingle struct {
	BaseEntity
}

func (*BaseEntitySingle) Autowire

func (self *BaseEntitySingle) Autowire()

func (*BaseEntitySingle) ContainsStru

func (self *BaseEntitySingle) ContainsStru(v any) bool

func (*BaseEntitySingle) IfAutowire

func (self *BaseEntitySingle) IfAutowire() bool

func (*BaseEntitySingle) InitProxy

func (bes *BaseEntitySingle) InitProxy(some any)

func (*BaseEntitySingle) ParseTags

func (self *BaseEntitySingle) ParseTags(tagkey string) map[string]string

func (*BaseEntitySingle) Single

func (bes *BaseEntitySingle) Single() bool

type BaseEntityTable

type BaseEntityTable struct {
	BaseEntity
}

func (BaseEntityTable) AutoMigrate

func (b BaseEntityTable) AutoMigrate() string

func (BaseEntityTable) PkeyName

func (b BaseEntityTable) PkeyName() string

func (BaseEntityTable) PkeyValue

func (b BaseEntityTable) PkeyValue() any

func (BaseEntityTable) TableName

func (b BaseEntityTable) TableName() string

type BaseProxy

type BaseProxy struct {
	Some any
}

func NewBaseProxy

func NewBaseProxy(some any) *BaseProxy

func (*BaseProxy) Autowire

func (self *BaseProxy) Autowire()

func (*BaseProxy) Clone

func (this *BaseProxy) Clone() any

func (*BaseProxy) ContainsStru

func (self *BaseProxy) ContainsStru(childStru any) bool

func (*BaseProxy) CopyWithOption

func (this *BaseProxy) CopyWithOption(from interface{})

func (*BaseProxy) FindNameOfIface

func (this *BaseProxy) FindNameOfIface() string

func (*BaseProxy) FromJson

func (this *BaseProxy) FromJson(body []byte) interface{}

func (*BaseProxy) FromJsonOut

func (this *BaseProxy) FromJsonOut(body []byte, out interface{})

func (*BaseProxy) HandleCheck

func (this *BaseProxy) HandleCheck() error

func (*BaseProxy) IfAutowire

func (self *BaseProxy) IfAutowire() bool

func (*BaseProxy) Init

func (this *BaseProxy) Init()

func (*BaseProxy) InitChildNilPtr

func (self *BaseProxy) InitChildNilPtr()
func (self *BaseEntity) ParseTags1(tagkey string) map[string]string {
	if self.Proxy != nil {
		return self.Proxy().ParseTags(tagkey)
	}
	return nil
}

func (*BaseProxy) JsonFromStr

func (this *BaseProxy) JsonFromStr(v string) string

func (*BaseProxy) Log

func (this *BaseProxy) Log()

func (*BaseProxy) Parse2Map

func (self *BaseProxy) Parse2Map() (map[string]any, error)

func (*BaseProxy) ParseTags

func (self *BaseProxy) ParseTags(tagkey string) map[string]string

func (*BaseProxy) Shutdown

func (this *BaseProxy) Shutdown()

func (*BaseProxy) String

func (this *BaseProxy) String() string

func (*BaseProxy) ToJson

func (this *BaseProxy) ToJson() string

func (*BaseProxy) ToJsonBytes

func (this *BaseProxy) ToJsonBytes() []byte

func (*BaseProxy) ToJsonStr

func (this *BaseProxy) ToJsonStr() string

func (*BaseProxy) ToPrettyString

func (this *BaseProxy) ToPrettyString() string

func (*BaseProxy) ToString

func (this *BaseProxy) ToString() string

func (*BaseProxy) ToStru

func (self *BaseProxy) ToStru(out any)

func (*BaseProxy) ValueFrom

func (this *BaseProxy) ValueFrom(from interface{})

func (*BaseProxy) ValueOf

func (this *BaseProxy) ValueOf(another interface{})

type Gometa

type Gometa struct {
	BaseEntity
	// contains filtered or unexported fields
}

Gometa is used as an embedded attribute for struct to enabled metadata feature.

func NewGometa

func NewGometa() *Gometa

func (*Gometa) Autowired

func (g *Gometa) Autowired() bool

func (*Gometa) SetAutowired

func (g *Gometa) SetAutowired(autowired bool)

type IchubError

type IchubError struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func NewIchubError

func NewIchubError(code int, msg string) *IchubError

func NewIchubErrorServer

func NewIchubErrorServer() *IchubError

func (*IchubError) Error

func (this *IchubError) Error() string

type IchubResult

type IchubResult struct {
	BaseEntity `json:"baseEntity"`

	//返回码
	Code int `json:"code" json:"code,omitempty"`
	//信息
	Msg string `json:"msg" json:"msg,omitempty"`
	//数据
	Data interface{} `json:"data" json:"data,omitempty"`
	//请求id
	RequestId string `json:"request_id,omitempty" json:"requestId,omitempty"`
	//请求地址
	Hosturl     string `json:"hosturl,omitempty" json:"hosturl,omitempty"`
	CmdTypeName string `json:"cmd_type_name,omitempty"`
}

func FailResult

func FailResult(msg string) *IchubResult

func NewIchubResult

func NewIchubResult() *IchubResult

func ParseIchubResult

func ParseIchubResult(body []byte) *IchubResult

func ResultCodeMsg

func ResultCodeMsg(code int, msg string) *IchubResult

func ResultError

func ResultError(err error) *IchubResult

func ResultFailErr

func ResultFailErr(err error) *IchubResult

func ResultFailMsg

func ResultFailMsg(msg string) *IchubResult

func ResultSuccessData

func ResultSuccessData(data interface{}) *IchubResult

func ValueOf

func ValueOf(resp *resty.Response) *IchubResult

func (*IchubResult) As

func (self *IchubResult) As(out interface{}) *IchubResult

func (*IchubResult) Check

func (self *IchubResult) Check() error

func (*IchubResult) CheckCode

func (self *IchubResult) CheckCode(suite suite.Suite, code int)

func (*IchubResult) CheckExp

func (self *IchubResult) CheckExp(suite suite.Suite, keyVal string)

func (*IchubResult) CheckValueByKey

func (self *IchubResult) CheckValueByKey(key string, expect interface{}) bool

func (*IchubResult) Checks

func (self *IchubResult) Checks(suite *suite.Suite, keyVals string)

keyVal : "Pay=12|l=2"

func (*IchubResult) CodeMsg

func (self *IchubResult) CodeMsg(code int, msg string) *IchubResult

func (*IchubResult) DataIfMap

func (self *IchubResult) DataIfMap() map[string]interface{}

func (*IchubResult) DataIfResultParams

func (self *IchubResult) DataIfResultParams() *IchubResultParams

func (*IchubResult) Fail

func (self *IchubResult) Fail() *IchubResult

func (*IchubResult) FailMsg

func (self *IchubResult) FailMsg(msg string) *IchubResult

func (*IchubResult) From

func (self *IchubResult) From(body []byte) (*IchubResult, error)

func (*IchubResult) GetData

func (self *IchubResult) GetData() any

func (*IchubResult) GetDbResult

func (self *IchubResult) GetDbResult() map[string]any

func (*IchubResult) GetEsResult

func (self *IchubResult) GetEsResult() map[string]any

func (*IchubResult) Init

func (self *IchubResult) Init()

func (*IchubResult) IsFailed

func (self *IchubResult) IsFailed() bool

func (*IchubResult) IsSuccess

func (self *IchubResult) IsSuccess() bool

func (*IchubResult) ParseData

func (self *IchubResult) ParseData(model interface{}) *IchubResult

func (*IchubResult) ParseDataBytes

func (self *IchubResult) ParseDataBytes(model interface{}) *IchubResult

func (*IchubResult) ParseList2Stru

func (self *IchubResult) ParseList2Stru(model any) *IchubResult

func (*IchubResult) ParseRemote

func (self *IchubResult) ParseRemote(model interface{}) *IchubResult

func (*IchubResult) ParseResult

func (self *IchubResult) ParseResult() *IchubResult

func (*IchubResult) Result2Error

func (self *IchubResult) Result2Error() error

func (*IchubResult) ResultJson

func (self *IchubResult) ResultJson(c *gin.Context)

func (*IchubResult) ResultOk

func (self *IchubResult) ResultOk(c *gin.Context)

func (*IchubResult) SetData

func (self *IchubResult) SetData(s interface{})

func (*IchubResult) Shutdown

func (self *IchubResult) Shutdown()

func (*IchubResult) Success

func (self *IchubResult) Success() *IchubResult

func (*IchubResult) SuccessData

func (self *IchubResult) SuccessData(data interface{}) *IchubResult

func (*IchubResult) SuccessMessage

func (self *IchubResult) SuccessMessage(msg string, data interface{}) *IchubResult

func (*IchubResult) To

func (self *IchubResult) To(out interface{})

func (*IchubResult) ValueByKey

func (self *IchubResult) ValueByKey(key string) any

func (*IchubResult) ValueOfMap

func (self *IchubResult) ValueOfMap(key string) *gvar.Var

type IchubResultParam

type IchubResultParam struct {
	BaseEntity
	// contains filtered or unexported fields
}

@Title 文件名称: ichub_param.go @Description 描述: 有芯规则引擎执行的参数值对象

应该进行值类型转换,转成string,再转成各类型

@Author 作者: leijianming@163.com 时间(2024-02-18 22:38:21) @Update 作者: leijianming@163.com 时间(2024-02-18 22:38:21)

规则体支持的基础数据类型 string bool int, int8, int16, int32, int64 uint uint8, uint16,uint32, uint64 float32 float64

func NewIchubResultParam

func NewIchubResultParam(value interface{}) *IchubResultParam

func (*IchubResultParam) CheckType

func (p *IchubResultParam) CheckType(i interface{}) string

func (*IchubResultParam) CheckTypeParam

func (p *IchubResultParam) CheckTypeParam() string

func (*IchubResultParam) From

func (p *IchubResultParam) From(value interface{}) *IchubResultParam

func (*IchubResultParam) FromJsonOut

func (this *IchubResultParam) FromJsonOut(out interface{})

func (*IchubResultParam) IfBool

func (p *IchubResultParam) IfBool() bool

func (*IchubResultParam) IfByte

func (p *IchubResultParam) IfByte() bool

func (*IchubResultParam) IfFloat32

func (p *IchubResultParam) IfFloat32() bool

func (*IchubResultParam) IfFloat64

func (p *IchubResultParam) IfFloat64() bool

func (*IchubResultParam) IfInt

func (p *IchubResultParam) IfInt() bool

func (*IchubResultParam) IfInt16

func (p *IchubResultParam) IfInt16() bool

func (*IchubResultParam) IfInt32

func (p *IchubResultParam) IfInt32() bool

func (*IchubResultParam) IfInt64

func (p *IchubResultParam) IfInt64() bool

func (*IchubResultParam) IfInt8

func (p *IchubResultParam) IfInt8() bool

func (*IchubResultParam) IfStr

func (p *IchubResultParam) IfStr() bool

func (*IchubResultParam) IfString

func (p *IchubResultParam) IfString() bool

func (*IchubResultParam) IfUInt16

func (p *IchubResultParam) IfUInt16() bool

func (*IchubResultParam) IfUInt32

func (p *IchubResultParam) IfUInt32() bool

func (*IchubResultParam) IfUInt64

func (p *IchubResultParam) IfUInt64() bool

func (*IchubResultParam) IfUInt8

func (p *IchubResultParam) IfUInt8() bool

func (*IchubResultParam) SetValue

func (p *IchubResultParam) SetValue(value interface{})

func (*IchubResultParam) String

func (p *IchubResultParam) String() string

func (*IchubResultParam) ToBool

func (p *IchubResultParam) ToBool() (ivalue bool)

func (*IchubResultParam) ToByte

func (p *IchubResultParam) ToByte() byte

func (*IchubResultParam) ToBytes

func (p *IchubResultParam) ToBytes() []byte

func (*IchubResultParam) ToFloat32

func (p *IchubResultParam) ToFloat32() (ivalue float32)

func (*IchubResultParam) ToFloat64

func (p *IchubResultParam) ToFloat64() (ivalue float64)

func (*IchubResultParam) ToInt

func (p *IchubResultParam) ToInt() int

func (*IchubResultParam) ToInt16

func (p *IchubResultParam) ToInt16() (ivalue int16)

func (*IchubResultParam) ToInt32

func (p *IchubResultParam) ToInt32() (ivalue int32)

func (*IchubResultParam) ToInt64

func (p *IchubResultParam) ToInt64() (ivalue int64)

func (*IchubResultParam) ToInt8

func (p *IchubResultParam) ToInt8() (ivalue int8)

func (*IchubResultParam) ToString

func (p *IchubResultParam) ToString() string

func (*IchubResultParam) ToUIn8

func (p *IchubResultParam) ToUIn8() uint8

func (*IchubResultParam) ToUInt

func (p *IchubResultParam) ToUInt() uint

func (*IchubResultParam) ToUInt16

func (p *IchubResultParam) ToUInt16() (ivalue uint16)

func (*IchubResultParam) ToUInt32

func (p *IchubResultParam) ToUInt32() (ivalue uint32)

func (*IchubResultParam) ToUInt64

func (p *IchubResultParam) ToUInt64() uint64

非int64也支持强制转换

func (*IchubResultParam) Value

func (p *IchubResultParam) Value() any

type IchubResultParams

type IchubResultParams struct {
	Params map[string]any `json:"params"`
	BaseEntity
}

func NewIchubResultParams

func NewIchubResultParams() *IchubResultParams

func (*IchubResultParams) GetMap

func (p *IchubResultParams) GetMap(key string) map[string]any

func (*IchubResultParams) GetParam

func (p *IchubResultParams) GetParam(key string) *IchubResultParam

func (*IchubResultParams) GetParams

func (p *IchubResultParams) GetParams(key string) *IchubResultParams

func (*IchubResultParams) SetParam

func (p *IchubResultParams) SetParam(key string, value interface{})

func (*IchubResultParams) ValueOf

func (this *IchubResultParams) ValueOf(m map[string]interface{}) *IchubResultParams

type IchubResults

type IchubResults struct {
	BaseEntity
	// 返回码
	Code int `json:"code"`
	// 状态消息
	Msg string `json:"msg"`
	// 返回数据
	Data []*IchubResult `json:"data,omitempty"`
	// 请求ID
	RequestId string `json:"request_id,omitempty"`
	Hosturl   string `json:"hosturl,omitempty"`
}

func BatchSuccessResult

func BatchSuccessResult(batchData []any) *IchubResults

func NewIchubResults

func NewIchubResults() *IchubResults

func ParseIchubResults

func ParseIchubResults(body []byte) *IchubResults

func (*IchubResults) CheckCode

func (results *IchubResults) CheckCode(suite suite.Suite, code int)

func (*IchubResults) Fail

func (results *IchubResults) Fail() *IchubResults

func (*IchubResults) FailMessage

func (results *IchubResults) FailMessage(msg string) *IchubResults

func (*IchubResults) FromJson

func (results *IchubResults) FromJson(body []byte) (*IchubResults, error)

func DataOfIndex(1)

func (*IchubResults) GetData

func (results *IchubResults) GetData() []*IchubResult

func (*IchubResults) Log

func (results *IchubResults) Log()

func (*IchubResults) SetData

func (results *IchubResults) SetData(s []*IchubResult)

func (*IchubResults) String

func (results *IchubResults) String() (s string)

func (*IchubResults) Success

func (results *IchubResults) Success() *IchubResults

func (*IchubResults) SuccessData

func (results *IchubResults) SuccessData(data []*IchubResult) *IchubResults

func (*IchubResults) SuccessMessage

func (results *IchubResults) SuccessMessage(msg string, datas []*IchubResult) *IchubResults

func (*IchubResults) ToString

func (results *IchubResults) ToString() string

func (*IchubResults) ValueOf

func (results *IchubResults) ValueOf(index int) *IchubResult

Jump to

Keyboard shortcuts

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