func greaterThanOrEqual(current interface{}, field interface{}, param interface{}) bool { var fieldValue = reflect.ValueOf(field) switch fieldValue.Kind() { case reflect.String: return fieldValue.String() >= param.(string) case reflect.Slice, reflect.Array, reflect.Map: p := convert.ConvertToInt(param) return fieldValue.Len() >= p case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: p := convert.ConvertToInt64(param) return fieldValue.Int() >= p case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: p := convert.ConvertToUint(param) return fieldValue.Uint() >= p case reflect.Float32, reflect.Float64: p := convert.ConvertToFloat64(param) return fieldValue.Float() >= p case reflect.Struct: if fieldValue.Type() == reflect.TypeOf(time.Time{}) { var t1 = field.(time.Time).Unix() var t2 = convert.ConvertToInt64(param) return t1 >= t2 } return false default: return false } }
func inList(current interface{}, field interface{}, param interface{}) bool { var fieldValue = reflect.ValueOf(field) switch fieldValue.Kind() { case reflect.Struct: case reflect.Slice, reflect.Array, reflect.Map: return false default: if list, ok := param.([]interface{}); ok { for _, item := range list { switch fieldValue.Kind() { case reflect.String: if item.(string) == fieldValue.String() { return true } case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: if convert.ConvertToInt64(item) == fieldValue.Int() { return true } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: if convert.ConvertToUint(item) == fieldValue.Uint() { return true } case reflect.Float32, reflect.Float64: if convert.ConvertToFloat64(item) == fieldValue.Float() { return true } } } } return false } return false }
func length(current interface{}, field interface{}, param interface{}) bool { var fieldValue = reflect.ValueOf(field) switch fieldValue.Kind() { case reflect.String: l := convert.ConvertToInt(param) return utf8.RuneCountInString(fieldValue.String()) == l case reflect.Slice, reflect.Array, reflect.Map: l := convert.ConvertToInt(param) return fieldValue.Len() == l case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: l := convert.ConvertToInt64(param) return fieldValue.Int() == l case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: l := convert.ConvertToUint(param) return fieldValue.Uint() == l case reflect.Float32, reflect.Float64: l := convert.ConvertToFloat64(param) return fieldValue.Float() == l default: return false } }
func (this *Context) GetInt64(key string, defaultValue int64) int64 { var value = this.GetValue(key, defaultValue) return convert.ConvertToInt64(value) }
func (this *Context) GetInt64WithContext(contextName, key string, defaultValue int64) int64 { var value, _ = this.GetValueWithContext(contextName, key, defaultValue) return convert.ConvertToInt64(value) }