|
@@ -129,7 +129,7 @@ func (units Units) ToMap() map[int]*Unit {
|
|
|
func (units Units) calculateTree(strict bool) {
|
|
|
unitMap := units.ToMap()
|
|
|
|
|
|
- for idx, _ := range units {
|
|
|
+ for idx := range units {
|
|
|
unit := &units[idx]
|
|
|
|
|
|
if unit.ParentId == nil {
|
|
@@ -148,7 +148,7 @@ func (units Units) calculateTree(strict bool) {
|
|
|
parent.children = append(parent.children, unit)
|
|
|
}
|
|
|
|
|
|
- for idx, _ := range units {
|
|
|
+ for idx := range units {
|
|
|
units[idx].childrenReady = true
|
|
|
}
|
|
|
}
|
|
@@ -193,7 +193,7 @@ func (u *Unit) PrepareFormulars() *Unit {
|
|
|
u.formulars, err = FormularSQL.Select(Formular{UnitId: u.Id})
|
|
|
} else {
|
|
|
u.formulars, err = FormularSQL.Select(Formular{PersNumber: u.PersNumber})
|
|
|
- for idx, _ := range u.formulars {
|
|
|
+ for idx := range u.formulars {
|
|
|
u.formulars[idx].UnitId = u.Id
|
|
|
}
|
|
|
}
|
|
@@ -220,7 +220,7 @@ func (u Unit) GetFormulars() Formulars {
|
|
|
return u.formulars
|
|
|
}
|
|
|
|
|
|
-func (units Units) PrepareFormulars(activeOnly bool) Units {
|
|
|
+func (units Units) PrepareFormulars(activeOnly bool, additionalCondition ...interface{}) Units {
|
|
|
if len(units) == 0 {
|
|
|
return units
|
|
|
}
|
|
@@ -239,9 +239,13 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
|
|
|
}
|
|
|
|
|
|
if len(nums) > 0 {
|
|
|
- scope = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
|
|
|
+ scope = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
|
|
|
} else {
|
|
|
- scope = scope.Where("OrgDiv IN (?)", ids)
|
|
|
+ scope = scope.Where("OrgDiv IN (?)", ids)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(additionalCondition) > 0 {
|
|
|
+ scope = scope.Where(additionalCondition[0].(string), additionalCondition[1:]...)
|
|
|
}
|
|
|
|
|
|
formulars, err := scope.Select()
|
|
@@ -262,7 +266,7 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
|
|
|
(*unitPtr).formulars = append((*unitPtr).formulars, formular)
|
|
|
}
|
|
|
|
|
|
- for idx, _ := range units {
|
|
|
+ for idx := range units {
|
|
|
units[idx].formularsReady = true
|
|
|
}
|
|
|
|
|
@@ -319,7 +323,7 @@ func (u *Unit) prepareChildrenTree(recursive bool) *Unit {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
- for idx, _ := range children {
|
|
|
+ for idx := range children {
|
|
|
child := &children[idx]
|
|
|
if recursive {
|
|
|
child.PrepareChildrenTree()
|
|
@@ -340,14 +344,14 @@ func (u *Unit) PrepareChildren() *Unit {
|
|
|
}
|
|
|
|
|
|
func (units Units) PrepareChildrenTree() Units {
|
|
|
- for idx, _ := range units {
|
|
|
+ for idx := range units {
|
|
|
units[idx].PrepareChildrenTree()
|
|
|
}
|
|
|
|
|
|
return units
|
|
|
}
|
|
|
func (units Units) PrepareChildren() Units {
|
|
|
- for idx, _ := range units {
|
|
|
+ for idx := range units {
|
|
|
units[idx].PrepareChildren()
|
|
|
}
|
|
|
|