2022-03-23 00:56:33 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
type ResultSet struct {
|
2022-03-30 10:55:16 +00:00
|
|
|
TableInfo *TableInfo
|
|
|
|
|
Columns []string
|
|
|
|
|
items []Item
|
|
|
|
|
attributes []ItemAttribute
|
2022-03-23 00:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 10:55:16 +00:00
|
|
|
type ItemAttribute struct {
|
|
|
|
|
Marked bool
|
|
|
|
|
Hidden bool
|
|
|
|
|
}
|
2022-03-24 01:54:32 +00:00
|
|
|
|
2022-03-30 10:55:16 +00:00
|
|
|
func (rs *ResultSet) Items() []Item {
|
|
|
|
|
return rs.items
|
2022-03-24 01:54:32 +00:00
|
|
|
}
|
2022-03-24 21:13:43 +00:00
|
|
|
|
2022-03-30 10:55:16 +00:00
|
|
|
func (rs *ResultSet) SetItems(items []Item) {
|
|
|
|
|
rs.items = items
|
|
|
|
|
rs.attributes = make([]ItemAttribute, len(items))
|
2022-03-24 21:17:52 +00:00
|
|
|
}
|
2022-03-30 10:04:30 +00:00
|
|
|
|
|
|
|
|
func (rs *ResultSet) SetMark(idx int, marked bool) {
|
2022-03-30 10:55:16 +00:00
|
|
|
rs.attributes[idx].Marked = marked
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *ResultSet) SetHidden(idx int, hidden bool) {
|
|
|
|
|
rs.attributes[idx].Hidden = hidden
|
2022-03-30 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *ResultSet) Marked(idx int) bool {
|
2022-03-30 10:55:16 +00:00
|
|
|
return rs.attributes[idx].Marked
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *ResultSet) Hidden(idx int) bool {
|
|
|
|
|
return rs.attributes[idx].Hidden
|
2022-03-30 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *ResultSet) MarkedItems() []Item {
|
|
|
|
|
items := make([]Item, 0)
|
2022-03-30 10:55:16 +00:00
|
|
|
for i, itemAttr := range rs.attributes {
|
|
|
|
|
if itemAttr.Marked && !itemAttr.Hidden {
|
|
|
|
|
items = append(items, rs.items[i])
|
2022-03-30 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return items
|
|
|
|
|
}
|