Order订单待测试

This commit is contained in:
eson
2023-06-20 19:36:28 +08:00
parent d4d11db732
commit e50dac6b1c
18 changed files with 116 additions and 43 deletions

View File

@@ -68,8 +68,17 @@ func (resp *Response) SetStatus(sr *StatusResponse, data ...interface{}) *Respon
} else {
newResp.Data = data[0]
}
} else if len(data) > 1 {
newResp.Data = data
} else if len(data) == 2 {
var dataIndex = 0
if err, ok := data[dataIndex].(error); ok {
newResp.Message = err.Error()
dataIndex++
} else {
panic("data只接收1或2个 data 或 error.Error() 和 data ")
}
newResp.Data = data[1]
} else {
panic("data只接收1或2个 data, error.Error() 和 data ")
}
return newResp
@@ -83,6 +92,21 @@ func (resp *Response) SetStatusWithMessage(sr *StatusResponse, msg string, data
}
if len(data) == 1 {
newResp.Data = data[0]
} else {
panic("data只接收一个 data")
}
return newResp
}
func (resp *Response) SetStatusAddMessage(sr *StatusResponse, msg string, data ...interface{}) *Response {
newResp := &Response{
Code: sr.Code,
Message: sr.Message + ":" + msg,
}
if len(data) == 1 {
newResp.Data = data[0]
} else {
panic("data只接收一个")
}
return newResp
}