• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang engine.APItoModelAccountAction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cgrates/cgrates/engine.APItoModelAccountAction函数的典型用法代码示例。如果您正苦于以下问题:Golang APItoModelAccountAction函数的具体用法?Golang APItoModelAccountAction怎么用?Golang APItoModelAccountAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了APItoModelAccountAction函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: LoadAccountActions

// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
func (self *ApierV2) LoadAccountActions(attrs AttrLoadAccountActions, reply *string) error {
	if len(attrs.TPid) == 0 {
		return utils.NewErrMandatoryIeMissing("TPid")
	}
	dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid, self.Config.DefaultTimezone, self.Config.LoadHistorySize)
	tpAa := &utils.TPAccountActions{TPid: attrs.TPid}
	tpAa.SetAccountActionsId(attrs.AccountActionsId)
	aa := engine.APItoModelAccountAction(tpAa)
	if _, err := engine.Guardian.Guard(func() (interface{}, error) {
		if err := dbReader.LoadAccountActionsFiltered(aa); err != nil {
			return 0, err
		}
		return 0, nil
	}, 0, attrs.AccountActionsId); err != nil {
		return utils.NewErrServerError(err)
	}
	// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
	// Need to do it before scheduler otherwise actions to run will be unknown
	if err := self.RatingDb.CacheRatingPrefixes(utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX); err != nil {
		return err
	}
	if self.Sched != nil {
		self.Sched.Reload(true)
	}
	*reply = v1.OK
	return nil
}
开发者ID:bhepp,项目名称:cgrates,代码行数:28,代码来源:apier.go


示例2: GetTPAccountActions

// Queries specific DerivedCharge on tariff plan
func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.TPAccountActions) error {
	if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing
		return utils.NewErrMandatoryIeMissing(missing...)
	}
	tmpAa := &utils.TPAccountActions{TPid: attrs.TPid}
	if err := tmpAa.SetAccountActionsId(attrs.AccountActionsId); err != nil {
		return err
	}
	tmpAaa := engine.APItoModelAccountAction(tmpAa)
	if aas, err := self.StorDb.GetTpAccountActions(tmpAaa); err != nil {
		return utils.NewErrServerError(err)
	} else if len(aas) == 0 {
		return utils.ErrNotFound
	} else {
		tpAaa, err := engine.TpAccountActions(aas).GetAccountActions()
		if err != nil {
			return err
		}
		aa := tpAaa[tmpAa.KeyId()]
		tpdc := utils.TPAccountActions{
			TPid:             attrs.TPid,
			ActionPlanId:     aa.ActionPlanId,
			ActionTriggersId: aa.ActionTriggersId,
		}
		if err := tpdc.SetAccountActionsId(attrs.AccountActionsId); err != nil {
			return err
		}
		*reply = tpdc
	}
	return nil
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:32,代码来源:tpaccountactions.go


示例3: GetTPAccountActionsByLoadId

// Queries specific AccountActions profile on tariff plan
func (self *ApierV1) GetTPAccountActionsByLoadId(attrs utils.TPAccountActions, reply *[]*utils.TPAccountActions) error {
	mndtryFlds := []string{"TPid", "LoadId"}
	if len(attrs.Account) != 0 { // If account provided as filter, make all related fields mandatory
		mndtryFlds = append(mndtryFlds, "Tenant", "Account")
	}
	if missing := utils.MissingStructFields(&attrs, mndtryFlds); len(missing) != 0 { //Params missing
		return utils.NewErrMandatoryIeMissing(missing...)
	}
	aas := engine.APItoModelAccountAction(&attrs)
	if aa, err := self.StorDb.GetTpAccountActions(aas); err != nil {
		return utils.NewErrServerError(err)
	} else if len(aa) == 0 {
		return utils.ErrNotFound
	} else {

		tpAa, err := engine.TpAccountActions(aa).GetAccountActions()
		if err != nil {
			return err
		}
		var acts []*utils.TPAccountActions
		if len(attrs.Account) != 0 {
			acts = []*utils.TPAccountActions{tpAa[attrs.KeyId()]}
		} else {
			for _, actLst := range tpAa {
				acts = append(acts, actLst)
			}
		}
		*reply = acts
	}
	return nil
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:32,代码来源:tpaccountactions.go


示例4: SetTPAccountActions

// Creates a new AccountActions profile within a tariff plan
func (self *ApierV1) SetTPAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if missing := utils.MissingStructFields(&attrs,
		[]string{"TPid", "LoadId", "Tenant", "Account", "ActionPlanId", "ActionTriggersId"}); len(missing) != 0 {
		return utils.NewErrMandatoryIeMissing(missing...)
	}
	aas := engine.APItoModelAccountAction(&attrs)
	if err := self.StorDb.SetTpAccountActions([]engine.TpAccountAction{*aas}); err != nil {
		return utils.NewErrServerError(err)
	}
	*reply = "OK"
	return nil
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:13,代码来源:tpaccountactions.go


示例5: LoadAccountActions

// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if len(attrs.TPid) == 0 {
		return utils.NewErrMandatoryIeMissing("TPid")
	}
	dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid, self.Config.DefaultTimezone)
	if _, err := engine.Guardian.Guard(func() (interface{}, error) {
		aas := engine.APItoModelAccountAction(&attrs)
		if err := dbReader.LoadAccountActionsFiltered(aas); err != nil {
			return 0, err
		}
		return 0, nil
	}, 0, attrs.KeyId()); err != nil {
		return utils.NewErrServerError(err)
	}
	// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
	// Need to do it before scheduler otherwise actions to run will be unknown
	if self.Sched != nil {
		self.Sched.Reload(true)
	}
	*reply = OK
	return nil
}
开发者ID:rinor,项目名称:cgrates,代码行数:23,代码来源:apier.go



注:本文中的github.com/cgrates/cgrates/engine.APItoModelAccountAction函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang engine.APItoModelRatingProfile函数代码示例发布时间:2022-05-23
下一篇:
Golang config.CGRConfig类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap