Przeglądaj źródła

修改操作逻辑

fancl 2 lat temu
rodzic
commit
95b72140fb
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      rest.go

+ 4 - 4
rest.go

@@ -181,13 +181,13 @@ func (r *Restful) prepareConditions(ctx context.Context, requestCtx *http.Contex
 		}
 		}
 		formValue = requestCtx.FormValue(schema.Column)
 		formValue = requestCtx.FormValue(schema.Column)
 		switch schema.Format {
 		switch schema.Format {
-		case "string", "text", "textarea":
+		case FormatString, FormatText:
 			if schema.Attribute.Match == MatchExactly {
 			if schema.Attribute.Match == MatchExactly {
 				query.AndFilterWhere(NewCond(schema.Column, formValue))
 				query.AndFilterWhere(NewCond(schema.Column, formValue))
 			} else {
 			} else {
 				query.AndFilterWhere(NewCond(schema.Column, formValue).WithExpr("LIKE"))
 				query.AndFilterWhere(NewCond(schema.Column, formValue).WithExpr("LIKE"))
 			}
 			}
-		case "date", "time", "datetime":
+		case FormatTime, FormatDate, FormatDatetime, FormatTimestamp:
 			var sep string
 			var sep string
 			seps := []byte{',', '/'}
 			seps := []byte{',', '/'}
 			for _, s := range seps {
 			for _, s := range seps {
@@ -203,10 +203,10 @@ func (r *Restful) prepareConditions(ctx context.Context, requestCtx *http.Contex
 			} else {
 			} else {
 				query.AndFilterWhere(NewCond(schema.Column, formValue))
 				query.AndFilterWhere(NewCond(schema.Column, formValue))
 			}
 			}
-		case "duration", "number", "integer", "decimal":
+		case FormatInteger, FormatFloat:
 			query.AndFilterWhere(NewCond(schema.Column, formValue))
 			query.AndFilterWhere(NewCond(schema.Column, formValue))
 		default:
 		default:
-			if schema.Type == "string" {
+			if schema.Type == TypeString {
 				if schema.Attribute.Match == MatchExactly {
 				if schema.Attribute.Match == MatchExactly {
 					query.AndFilterWhere(NewCond(schema.Column, formValue))
 					query.AndFilterWhere(NewCond(schema.Column, formValue))
 				} else {
 				} else {