Browse Source

condition tags

0x4a52466c696e74 4 months ago
parent
commit
5cb03f95ba
3 changed files with 15 additions and 5 deletions
  1. 1 1
      application/z_test.go
  2. 4 4
      conditions.go
  3. 10 0
      z_test.go

+ 1 - 1
application/z_test.go

@@ -25,7 +25,7 @@ func (s *Hello) Execute(req rest.IRequestIn) rest.IRequestOut {
 	response := HelloResponse{
 		Message: "Hello, " + s.Name,
 	}
-	return rest.OutFileds(req, &response, nil)
+	return rest.OutFields(req, &response, nil)
 }
 
 type HelloResponse struct {

+ 4 - 4
conditions.go

@@ -51,10 +51,10 @@ func (s ConditionLogic) IsValid() bool {
 //////////////////////////////////////////////////////////////////////////////
 
 type Condition struct {
-	Field    string
-	Logic    ConditionLogic
-	Operator ConditionOperator
-	Value    any
+	Field    string            `json:"Field"`
+	Logic    ConditionLogic    `json:"Logic"`
+	Operator ConditionOperator `json:"Operator"`
+	Value    any               `json:"Value"`
 }
 
 func (s *Condition) IsValid() bool {

+ 10 - 0
z_test.go

@@ -312,9 +312,15 @@ func TestFieldNames(t *testing.T) {
 	t.Log(fields)
 }
 
+type User struct {
+	ID   int
+	Name string
+}
+
 type AuthEmail struct {
 	Email     string `rest:"required" example:"mail@mail.ml"`
 	ThemeName string `rest:"required"`
+	UUser     *User
 }
 
 func (s *AuthEmail) Validate(req IRequestIn) IRequestOut {
@@ -342,6 +348,10 @@ func TestSerializeEmail(t *testing.T) {
 	m := json.Map{
 		"email":     "flint@77i.su",
 		"themeName": "th-name",
+		"UUser": json.Map{
+			"ID":   100,
+			"Name": "User 100",
+		},
 	}
 
 	r := &AuthEmail{}