50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package data
|
|
|
|
import (
|
|
"github.com/oylshe1314/framework/errors"
|
|
"sort"
|
|
)
|
|
|
|
func (this *TaskTable) check() error {
|
|
for _, d := range this.l {
|
|
if len(d.ItemNumList) != len(d.ItemIdList) {
|
|
return errors.Error("incorrect 'Task' table, error: len(d.ItemNumList) != len(d.ItemIdList), id: ", d.id())
|
|
}
|
|
if len(d.Section3) != len(d.Section1) {
|
|
return errors.Error("incorrect 'Task' table, error: len(d.Section3) != len(d.Section1), id: ", d.id())
|
|
}
|
|
if len(d.Section2) > 0 && len(d.Section2) != len(d.Section1) {
|
|
return errors.Error("incorrect 'Task' table, error: len(d.Section2) > 0 && len(d.Section2) != len(d.Section1), id: ", d.id())
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type TaskTableExtend struct {
|
|
*TaskTable
|
|
|
|
extMap map[int][]*Task
|
|
}
|
|
|
|
func (this *TaskTableExtend) init() error {
|
|
if this.TaskTable == nil {
|
|
return nil
|
|
}
|
|
|
|
this.extMap = map[int][]*Task{}
|
|
for _, d := range this.l {
|
|
this.extMap[d.TaskType] = append(this.extMap[d.TaskType], d)
|
|
}
|
|
|
|
for _, ds := range this.extMap {
|
|
sort.Slice(ds, func(i, j int) bool {
|
|
return ds[i].Id < ds[j].Id
|
|
})
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (this *TaskTableExtend) Get(taskType int) []*Task {
|
|
return this.extMap[taskType]
|
|
}
|