mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 06:38:45 +05:00
Removing accounts
This commit is contained in:
committed by
Dan Christian Bogos
parent
f4689abdd7
commit
49f8ffc598
@@ -772,29 +772,6 @@ func (sqls *SQLStorage) SetTPActionProfiles(tpAps []*utils.TPActionProfile) erro
|
||||
tx.Commit()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sqls *SQLStorage) SetTPAccountProfiles(tpAps []*utils.TPAccountProfile) error {
|
||||
if len(tpAps) == 0 {
|
||||
return nil
|
||||
}
|
||||
tx := sqls.db.Begin()
|
||||
for _, tpAp := range tpAps {
|
||||
// Remove previous
|
||||
if err := tx.Where(&AccountProfileMdl{Tpid: tpAp.TPid, Tenant: tpAp.Tenant, ID: tpAp.ID}).Delete(AccountProfileMdl{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
for _, mst := range APItoModelTPAccountProfile(tpAp) {
|
||||
if err := tx.Create(&mst).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
tx.Commit()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sqls *SQLStorage) SetSMCost(smc *SMCost) error {
|
||||
if smc.CostDetails == nil {
|
||||
return nil
|
||||
@@ -1657,27 +1634,6 @@ func (sqls *SQLStorage) GetTPActionProfiles(tpid, tenant, id string) ([]*utils.T
|
||||
return arls, nil
|
||||
}
|
||||
|
||||
func (sqls *SQLStorage) GetTPAccountProfiles(tpid, tenant, id string) ([]*utils.TPAccountProfile, error) {
|
||||
var dpps AccountProfileMdls
|
||||
q := sqls.db.Where("tpid = ?", tpid)
|
||||
if len(id) != 0 {
|
||||
q = q.Where("id = ?", id)
|
||||
}
|
||||
if len(tenant) != 0 {
|
||||
q = q.Where("tenant = ?", tenant)
|
||||
}
|
||||
if err := q.Find(&dpps).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
arls, err := dpps.AsTPAccountProfile()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(arls) == 0 {
|
||||
return arls, utils.ErrNotFound
|
||||
}
|
||||
return arls, nil
|
||||
}
|
||||
|
||||
// GetVersions returns slice of all versions or a specific version if tag is specified
|
||||
func (sqls *SQLStorage) GetVersions(itm string) (vrs Versions, err error) {
|
||||
q := sqls.db.Model(&TBLVersion{})
|
||||
|
||||
Reference in New Issue
Block a user