|
@@ -90,6 +90,10 @@ func (person *Person) PrepareFormulars() *Person {
|
|
|
return person
|
|
|
}
|
|
|
|
|
|
+func (person Person) IsFormularsReady() bool {
|
|
|
+ return person.formularsReady
|
|
|
+}
|
|
|
+
|
|
|
func (person Person) GetFormulars() Formulars {
|
|
|
if !person.formularsReady {
|
|
|
panic("person is not ready for method GetFormulars: it's required to call PrepareFormulars method, first")
|
|
@@ -101,3 +105,25 @@ func (person Person) GetFormularsPtr() *Formulars {
|
|
|
return &person.formulars
|
|
|
}
|
|
|
|
|
|
+func (people People) PrepareFormulars() People {
|
|
|
+ ids := people.GetEmpGUIDs()
|
|
|
+
|
|
|
+ formulars, err := FormularSQL.Select("EmpGUID IN (?)", ids)
|
|
|
+ if err != nil && err != sql.ErrNoRows {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ personMap := People(people).ToMap()
|
|
|
+
|
|
|
+ for _, formular := range formulars {
|
|
|
+ (*personMap[formular.EmpGUID]).formulars = append((*personMap[formular.EmpGUID]).formulars, formular)
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx, _ := range people {
|
|
|
+ people[idx].formularsReady = true
|
|
|
+ }
|
|
|
+
|
|
|
+ return people
|
|
|
+}
|
|
|
+
|
|
|
+
|