- Updated error response codes for various validation errors from 400 to 422 to better reflect the nature of the errors. - Changed error messages for empty parameters (e.g., userId, menuId, roleId) to use a consistent error code format. - Improved error handling in the IPerf, Ping, and WS controllers to provide more informative error messages. - Ensured that all controllers return appropriate error messages when binding JSON or query parameters fails.
40 lines
875 B
Go
40 lines
875 B
Go
package services
|
|
|
|
import "be.ems/src/framework/resp"
|
|
|
|
const (
|
|
CODE_FAIL = resp.CODE_ERROR
|
|
CODE_SUCC = resp.CODE_SUCCESS
|
|
)
|
|
|
|
func ErrResp(msg string) map[string]any {
|
|
return map[string]any{"code": CODE_FAIL, "msg": msg}
|
|
}
|
|
|
|
func DataResp(data any) map[string]any {
|
|
return map[string]any{"code": CODE_SUCC, "data": data}
|
|
}
|
|
|
|
func SuccMessageResp() map[string]any {
|
|
return map[string]any{"code": CODE_SUCC, "msg": "success"}
|
|
}
|
|
|
|
func TotalResp(total int64) map[string]any {
|
|
return map[string]any{"code": CODE_SUCC, "total": total}
|
|
}
|
|
|
|
func TotalDataResp(data any, total any) map[string]any {
|
|
return map[string]any{"code": CODE_SUCC, "data": map[string]any{
|
|
"rows": data, "total": total,
|
|
}, "msg": "success"}
|
|
}
|
|
|
|
func SuccResp(va map[string]any) map[string]any {
|
|
resp := make(map[string]any)
|
|
resp["code"] = CODE_SUCC
|
|
for k, v := range va {
|
|
resp[k] = v
|
|
}
|
|
return resp
|
|
}
|