mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
✨ Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
04f81c4dee
commit
d71db85051
1 changed files with 57 additions and 0 deletions
57
kernel/av/group.go
Normal file
57
kernel/av/group.go
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// SiYuan - Refactor your thinking
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package av
|
||||
|
||||
// Groupable 定义了可分组的视图类型。
|
||||
type Groupable interface {
|
||||
|
||||
// Group 根据视图中设置的分组规则进行分组。
|
||||
Group(attrView *AttributeView)
|
||||
}
|
||||
|
||||
type ViewGroup struct {
|
||||
Field string `json:"field"` // 分组字段 ID
|
||||
Method GroupMethod `json:"method"` // 分组方式
|
||||
Range *GroupRange `json:"range,omitempty"` // 分组范围
|
||||
Order GroupOrder `json:"order"` // 分组顺序
|
||||
}
|
||||
|
||||
type GroupMethod int
|
||||
|
||||
const (
|
||||
GroupMethodValue GroupMethod = iota // 按值分组
|
||||
GroupMethodRangeNum // 按数字范围分组
|
||||
GroupMethodDateRelative // 按相对日期日期分组
|
||||
GroupMethodDateDay // 按天日期分组
|
||||
GroupMethodDateWeek // 按周日期分组
|
||||
GroupMethodDateMonth // 按月日期分组
|
||||
GroupMethodDateYear // 按年日期分组
|
||||
)
|
||||
|
||||
// GroupRange 定义了分组范围的结构。
|
||||
type GroupRange struct {
|
||||
NumStart float64 `json:"numStart"` // 数字范围起始值
|
||||
NumEnd float64 `json:"numEnd"` // 数字范围结束值
|
||||
NumStep float64 `json:"numStep"` // 数字范围步长
|
||||
}
|
||||
|
||||
type GroupOrder string
|
||||
|
||||
const (
|
||||
GroupOrderAsc GroupOrder = "ASC"
|
||||
GroupOrderDesc GroupOrder = "DESC"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue