|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
...
|
...
|
@@ -21,7 +22,10 @@ type BaseController struct { |
|
|
}
|
|
|
|
|
|
func (controller BaseController) BindJsonData(v interface{}) error {
|
|
|
return json.Unmarshal(controller.Ctx.Input.RequestBody, v)
|
|
|
newDecoder := json.NewDecoder(bytes.NewReader(controller.Ctx.Input.RequestBody))
|
|
|
newDecoder.UseNumber()
|
|
|
err := newDecoder.Decode(v)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
func (controller BaseController) ResponseError(err error) {
|
...
|
...
|
@@ -38,7 +42,6 @@ func (controller BaseController) ResponseError(err error) { |
|
|
} else {
|
|
|
logs.Error(e.Prefix, e.Message)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
controller.Data["json"] = protocol.ResponseData{
|
|
|
Code: -1,
|
...
|
...
|
|