wangfei il y a 6 ans
Parent
révision
23864c7ab7
2 fichiers modifiés avec 23 ajouts et 3 suppressions
  1. 10
    0
      controllers/base.go
  2. 13
    3
      controllers/bodycheck/bodycheck.go

+ 10
- 0
controllers/base.go Voir le fichier

@@ -135,3 +135,13 @@ func (c *BaseController) GetCaseIDs(cases []model.SysUserCase) string {
135 135
 	}
136 136
 	return caseIDs
137 137
 }
138
+
139
+func (c *BaseController) ResponseOtherEndPoint(msg map[string]interface{}) {
140
+	c.destroyContext(true)
141
+	c.Context.Destroy()
142
+
143
+	c.Data["json"] = msg
144
+
145
+	c.ServeJSON()
146
+	c.StopRun()
147
+}

+ 13
- 3
controllers/bodycheck/bodycheck.go Voir le fichier

@@ -40,13 +40,23 @@ func (c *BodyCheckController) PostCheckResult() {
40 40
 	err := json.Unmarshal(con, &formVal)
41 41
 	if err != nil {
42 42
 		utils.LogError("参数错误:", err)
43
-		c.ResponseError(err)
43
+		c.ResponseOtherEndPoint(map[string]interface{}{
44
+			"Status":  false,
45
+			"Message": err.Error(),
46
+		})
44 47
 	}
45 48
 
46 49
 	err = c.serv.PostCheckResult(formVal)
47 50
 	if err != nil {
48 51
 		utils.LogError("操作错误:", err)
49
-		c.ResponseError(err)
52
+		c.ResponseOtherEndPoint(map[string]interface{}{
53
+			"Status":  false,
54
+			"Message": err.Error(),
55
+		})
50 56
 	}
51
-	c.ResponseJSON("")
57
+
58
+	c.ResponseOtherEndPoint(map[string]interface{}{
59
+		"Status":  true,
60
+		"Message": "",
61
+	})
52 62
 }