wangkaiyue 5 سال پیش
والد
کامیت
93744d0ce1
1فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
  1. 18 1
      src/qfw/util/mysql/mysql.go

+ 18 - 1
src/qfw/util/mysql/mysql.go

@@ -367,7 +367,24 @@ func (m *Mysql) Count(tableName string, query map[string]interface{}) int64 {
 	fields := []string{}
 	values := []interface{}{}
 	for k, v := range query {
-		if v == "$isNull" {
+		rt := reflect.TypeOf(v)
+		rv := reflect.ValueOf(v)
+		if rt.Kind() == reflect.Map {
+			for _, rv_k := range rv.MapKeys() {
+				if rv_k.String() == "ne" {
+					fields = append(fields, fmt.Sprintf("%s!=?", k))
+					values = append(values, rv.MapIndex(rv_k).Interface())
+				}
+				if rv_k.String() == "notin" {
+					if len(rv.MapIndex(rv_k).Interface().([]interface{})) > 0 {
+						for _, v := range rv.MapIndex(rv_k).Interface().([]interface{}) {
+							fields = append(fields, fmt.Sprintf("%s!=?", k))
+							values = append(values, v)
+						}
+					}
+				}
+			}
+		} else if v == "$isNull" {
 			fields = append(fields, fmt.Sprintf("%s is null", k))
 		} else if v == "$isNotNull" {
 			fields = append(fields, fmt.Sprintf("%s is not null", k))