chore: add id to resp of create storage

This commit is contained in:
Noah Hsu
2022-11-13 20:17:10 +08:00
parent 6e3df9f847
commit 3b6d8987db
6 changed files with 34 additions and 13 deletions

View File

@ -21,6 +21,23 @@ func hidePrivacy(msg string) string {
// ErrorResp is used to return error response
// @param l: if true, log error
func ErrorResp(c *gin.Context, err error, code int, l ...bool) {
ErrorWithDataResp(c, err, code, nil, l...)
//if len(l) > 0 && l[0] {
// if flags.Debug || flags.Dev {
// log.Errorf("%+v", err)
// } else {
// log.Errorf("%v", err)
// }
//}
//c.JSON(200, Resp[interface{}]{
// Code: code,
// Message: hidePrivacy(err.Error()),
// Data: nil,
//})
//c.Abort()
}
func ErrorWithDataResp(c *gin.Context, err error, code int, data interface{}, l ...bool) {
if len(l) > 0 && l[0] {
if flags.Debug || flags.Dev {
log.Errorf("%+v", err)
@ -31,7 +48,7 @@ func ErrorResp(c *gin.Context, err error, code int, l ...bool) {
c.JSON(200, Resp[interface{}]{
Code: code,
Message: hidePrivacy(err.Error()),
Data: nil,
Data: data,
})
c.Abort()
}