change layout
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"lone-services/pkg/utils"
|
||||
"net/http"
|
||||
|
||||
"pkg.local/utils"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
type BaseController struct{}
|
||||
@@ -27,12 +27,12 @@ func (b *BaseController) Out(w http.ResponseWriter, data any, cm Error) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = json.NewEncoder(w).Encode(out)
|
||||
_ = jsoniter.NewEncoder(w).Encode(out)
|
||||
}
|
||||
|
||||
func (b *BaseController) OutPut(w http.ResponseWriter, code int32, data any, msg string) {
|
||||
if code == utils.Ok.Code && !utils.GetConfigBool("encrypt.debug") {
|
||||
jsonData, err := json.Marshal(data)
|
||||
jsonData, err := jsoniter.Marshal(data)
|
||||
if err != nil {
|
||||
fmt.Printf("response encrypt: json.Marshal failed: %v\n", err)
|
||||
msg = utils.ErrorEncryptAesError.Msg
|
||||
@@ -56,5 +56,5 @@ func (b *BaseController) OutPut(w http.ResponseWriter, code int32, data any, msg
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = json.NewEncoder(w).Encode(out)
|
||||
_ = jsoniter.NewEncoder(w).Encode(out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user