Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
41b2afd718
3 changed files with 73 additions and 33 deletions
|
@ -68,7 +68,11 @@ func getAttributeViewPrimaryKeyValues(c *gin.Context) {
|
|||
pageSize = int(pageSizeArg.(float64))
|
||||
}
|
||||
|
||||
attributeViewName, rows, err := model.GetAttributeViewPrimaryKeyValues(id, page, pageSize)
|
||||
keyword := ""
|
||||
if keywordArg := arg["keyword"]; nil != keywordArg {
|
||||
keyword = keywordArg.(string)
|
||||
}
|
||||
attributeViewName, rows, err := model.GetAttributeViewPrimaryKeyValues(id, keyword, page, pageSize)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
@ -257,12 +257,12 @@ func (value *Value) Compare(other *Value) int {
|
|||
}
|
||||
|
||||
func (value *Value) CompareOperator(filter *ViewFilter, attrView *AttributeView, rowID string) bool {
|
||||
key, _ := attrView.GetKey(value.KeyID)
|
||||
if nil == key {
|
||||
return false
|
||||
}
|
||||
if nil != value.Rollup && KeyTypeRollup == value.Type && nil != filter.Value && KeyTypeRollup == filter.Value.Type {
|
||||
key, _ := attrView.GetKey(value.KeyID)
|
||||
if nil == key {
|
||||
return false
|
||||
}
|
||||
|
||||
if nil != value.Rollup && KeyTypeRollup == key.Type && nil != filter.Value && KeyTypeRollup == filter.Value.Type {
|
||||
relKey, _ := attrView.GetKey(key.Rollup.RelationKeyID)
|
||||
if nil == relKey {
|
||||
return false
|
||||
|
@ -284,24 +284,22 @@ func (value *Value) CompareOperator(filter *ViewFilter, attrView *AttributeView,
|
|||
continue
|
||||
}
|
||||
|
||||
if destVal.compareOperator(filter, key.Type) {
|
||||
if destVal.compareOperator(filter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return value.compareOperator(filter, key.Type)
|
||||
return value.compareOperator(filter)
|
||||
}
|
||||
|
||||
func (value *Value) compareOperator(filter *ViewFilter, keyType KeyType) bool {
|
||||
func (value *Value) compareOperator(filter *ViewFilter) bool {
|
||||
if nil == filter || (nil == filter.Value && nil == filter.RelativeDate) {
|
||||
return true
|
||||
}
|
||||
|
||||
operator := filter.Operator
|
||||
|
||||
switch keyType {
|
||||
switch value.Type {
|
||||
case KeyTypeBlock:
|
||||
if nil != value.Block && nil != filter.Value.Block {
|
||||
switch operator {
|
||||
|
@ -458,21 +456,39 @@ func (value *Value) compareOperator(filter *ViewFilter, keyType KeyType) bool {
|
|||
if nil != value.Created && nil != filter.Value.Created {
|
||||
switch operator {
|
||||
case FilterOperatorIsEqual:
|
||||
return value.Created.Content == filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Created.Content >= start.UnixMilli() && value.Created.Content < end.UnixMilli()
|
||||
case FilterOperatorIsNotEqual:
|
||||
return value.Created.Content != filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Created.Content < start.UnixMilli() || value.Created.Content >= end.UnixMilli()
|
||||
case FilterOperatorIsGreater:
|
||||
return value.Created.Content > filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Created.Content >= end.UnixMilli()
|
||||
case FilterOperatorIsGreaterOrEqual:
|
||||
return value.Created.Content >= filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Created.Content >= start.UnixMilli()
|
||||
case FilterOperatorIsLess:
|
||||
return value.Created.Content < filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Created.Content < start.UnixMilli()
|
||||
case FilterOperatorIsLessOrEqual:
|
||||
return value.Created.Content <= filter.Value.Created.Content
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Created.Content < end.UnixMilli()
|
||||
case FilterOperatorIsBetween:
|
||||
start := value.Created.Content >= filter.Value.Created.Content
|
||||
end := value.Created.Content <= filter.Value.Created.Content2
|
||||
return start && end
|
||||
start := time.UnixMilli(filter.Value.Created.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := time.UnixMilli(filter.Value.Created.Content2)
|
||||
end = time.Date(end.Year(), end.Month(), end.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Created.Content >= start.UnixMilli() && value.Created.Content < end.UnixMilli()
|
||||
case FilterOperatorIsEmpty:
|
||||
return !value.Created.IsNotEmpty
|
||||
case FilterOperatorIsNotEmpty:
|
||||
|
@ -483,21 +499,39 @@ func (value *Value) compareOperator(filter *ViewFilter, keyType KeyType) bool {
|
|||
if nil != value.Updated && nil != filter.Value.Updated {
|
||||
switch operator {
|
||||
case FilterOperatorIsEqual:
|
||||
return value.Updated.Content == filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Updated.Content >= start.UnixMilli() && value.Updated.Content < end.UnixMilli()
|
||||
case FilterOperatorIsNotEqual:
|
||||
return value.Updated.Content != filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Updated.Content < start.UnixMilli() || value.Updated.Content >= end.UnixMilli()
|
||||
case FilterOperatorIsGreater:
|
||||
return value.Updated.Content > filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Updated.Content >= end.UnixMilli()
|
||||
case FilterOperatorIsGreaterOrEqual:
|
||||
return value.Updated.Content >= filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Updated.Content >= start.UnixMilli()
|
||||
case FilterOperatorIsLess:
|
||||
return value.Updated.Content < filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Updated.Content < start.UnixMilli()
|
||||
case FilterOperatorIsLessOrEqual:
|
||||
return value.Updated.Content <= filter.Value.Updated.Content
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
return value.Updated.Content < end.UnixMilli()
|
||||
case FilterOperatorIsBetween:
|
||||
start := value.Updated.Content >= filter.Value.Updated.Content
|
||||
end := value.Updated.Content <= filter.Value.Updated.Content2
|
||||
return start && end
|
||||
start := time.UnixMilli(filter.Value.Updated.Content)
|
||||
start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
||||
end := time.UnixMilli(filter.Value.Updated.Content2)
|
||||
end = time.Date(end.Year(), end.Month(), end.Day(), 0, 0, 0, 0, time.Local)
|
||||
return value.Updated.Content >= start.UnixMilli() && value.Updated.Content < end.UnixMilli()
|
||||
case FilterOperatorIsEmpty:
|
||||
return !value.Updated.IsNotEmpty
|
||||
case FilterOperatorIsNotEmpty:
|
||||
|
|
|
@ -55,7 +55,7 @@ func SetDatabaseBlockView(blockID, viewID string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetAttributeViewPrimaryKeyValues(avID string, page, pageSize int) (attributeViewName string, keyValues *av.KeyValues, err error) {
|
||||
func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int) (attributeViewName string, keyValues *av.KeyValues, err error) {
|
||||
waitForSyncingStorages()
|
||||
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
|
@ -86,11 +86,13 @@ func GetAttributeViewPrimaryKeyValues(avID string, page, pageSize int) (attribut
|
|||
}
|
||||
keyValues.Values = []*av.Value{}
|
||||
for _, v := range tmp {
|
||||
keyValues.Values = append(keyValues.Values, v)
|
||||
if strings.Contains(strings.ToLower(v.String()), strings.ToLower(keyword)) {
|
||||
keyValues.Values = append(keyValues.Values, v)
|
||||
}
|
||||
}
|
||||
|
||||
if 1 > pageSize {
|
||||
pageSize = 50
|
||||
pageSize = 32
|
||||
}
|
||||
start := (page - 1) * pageSize
|
||||
end := start + pageSize
|
||||
|
|
Loading…
Add table
Reference in a new issue