|
|
@@ -7,17 +7,25 @@ type JsonResponseGenerator struct { |
|
|
|
} |
|
|
|
|
|
|
|
func (j JsonResponseGenerator) NewJsonByDefaultSuccess(data ...interface{}) JsonInterface { |
|
|
|
return j.NewJson(true, 0, JsonMsgDefaultOk, data...) |
|
|
|
ptr := j.NewJson(true, 0, JsonMsgDefaultOk, data...) |
|
|
|
ptr.SetCode(ptr.GetDefaultSuccessCode()) |
|
|
|
return ptr |
|
|
|
} |
|
|
|
|
|
|
|
func (j JsonResponseGenerator) NewJsonByDefaultFailed(data ...interface{}) JsonInterface { |
|
|
|
return j.NewJson(false, 1, JsonMsgDefaultFailed, data...) |
|
|
|
ptr := j.NewJson(false, 1, JsonMsgDefaultFailed, data...) |
|
|
|
ptr.SetCode(ptr.GetDefaultFailedCode()) |
|
|
|
return ptr |
|
|
|
} |
|
|
|
|
|
|
|
func (j JsonResponseGenerator) NewJonsByFailed(code int, msg string) JsonInterface { |
|
|
|
func (j JsonResponseGenerator) NewJsonByFailed(code int, msg string) JsonInterface { |
|
|
|
return j.NewJson(false, code, msg) |
|
|
|
} |
|
|
|
|
|
|
|
func (j JsonResponseGenerator) NewJsonByFailedWithData(code int, msg string, data interface{}) JsonInterface { |
|
|
|
return j.NewJson(false, code, msg, data) |
|
|
|
} |
|
|
|
|
|
|
|
func (j JsonResponseGenerator) NewJson(status bool, code int, msg string, data ...interface{}) JsonInterface { |
|
|
|
jPtr := reflect.New(reflect.TypeOf(j.Interface).Elem()) |
|
|
|
if b, ok := jPtr.Interface().(JsonInterface); ok { |
|
|
|