Skip to content

Commit

Permalink
🎨 Support database date field relative to today's filtering #10451
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 1, 2024
1 parent 10e0061 commit 066d180
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 164 deletions.
54 changes: 35 additions & 19 deletions kernel/av/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,46 @@ type Filterable interface {
}

type ViewFilter struct {
Column string `json:"column"`
Operator FilterOperator `json:"operator"`
Value *Value `json:"value"`
Column string `json:"column"`
Operator FilterOperator `json:"operator"`
Value *Value `json:"value"`
RelativeDate *RelativeDate `json:"relativeDate"`
RelativeDate2 *RelativeDate `json:"relativeDate2"`
}

type RelativeDateUnit int

const (
RelativeDateUnitDay = iota
RelativeDateUnitWeek
RelativeDateUnitMonth
RelativeDateUnitYear
)

type RelativeDate struct {
Count int // 数量
Unit RelativeDateUnit // 单位:天、周、月、年
Direction int // 方向:前、现在、后
}

type FilterOperator string

const (
FilterOperatorIsEqual FilterOperator = "="
FilterOperatorIsNotEqual FilterOperator = "!="
FilterOperatorIsGreater FilterOperator = ">"
FilterOperatorIsGreaterOrEqual FilterOperator = ">="
FilterOperatorIsLess FilterOperator = "<"
FilterOperatorIsLessOrEqual FilterOperator = "<="
FilterOperatorContains FilterOperator = "Contains"
FilterOperatorDoesNotContain FilterOperator = "Does not contains"
FilterOperatorIsEmpty FilterOperator = "Is empty"
FilterOperatorIsNotEmpty FilterOperator = "Is not empty"
FilterOperatorStartsWith FilterOperator = "Starts with"
FilterOperatorEndsWith FilterOperator = "Ends with"
FilterOperatorIsBetween FilterOperator = "Is between"
FilterOperatorIsRelativeToToday FilterOperator = "Is relative to today"
FilterOperatorIsTrue FilterOperator = "Is true"
FilterOperatorIsFalse FilterOperator = "Is false"
FilterOperatorIsEqual FilterOperator = "="
FilterOperatorIsNotEqual FilterOperator = "!="
FilterOperatorIsGreater FilterOperator = ">"
FilterOperatorIsGreaterOrEqual FilterOperator = ">="
FilterOperatorIsLess FilterOperator = "<"
FilterOperatorIsLessOrEqual FilterOperator = "<="
FilterOperatorContains FilterOperator = "Contains"
FilterOperatorDoesNotContain FilterOperator = "Does not contains"
FilterOperatorIsEmpty FilterOperator = "Is empty"
FilterOperatorIsNotEmpty FilterOperator = "Is not empty"
FilterOperatorStartsWith FilterOperator = "Starts with"
FilterOperatorEndsWith FilterOperator = "Ends with"
FilterOperatorIsBetween FilterOperator = "Is between"
FilterOperatorIsTrue FilterOperator = "Is true"
FilterOperatorIsFalse FilterOperator = "Is false"
)

func (filter *ViewFilter) GetAffectValue(key *Key) (ret *Value) {
Expand Down
Loading

0 comments on commit 066d180

Please sign in to comment.