【Python】后台开发返回方法和状态码类的实现
创始人
2024-11-13 20:37:26
0

Python 后台开发中,获取返回的类方法,以及状态码类的实现

代码备份

Code - response.py

""" Response class for quick generate response """ from loguru_logger import get_logger  logger = get_logger(__name__)  class Response():     @staticmethod     def get_response(code, message, data=None):         return {             "code": code,             "message": message,             "data": data if data is not None else {}         } 

Code - status_code.py

class StatusCode:     # Success     SUCCESS = 0  # Request successful, business processing successful      # Client errors     ERROR_BAD_REQUEST = 400  # Invalid request     ERROR_UNAUTHORIZED = 401  # Unauthorized     ERROR_FORBIDDEN = 403  # Forbidden     ERROR_NOT_FOUND = 404  # Resource not found     ERROR_METHOD_NOT_ALLOWED = 405  # Method not allowed     ERROR_CONFLICT = 409  # Resource conflict     ERROR_UNPROCESSABLE_ENTITY = 422  # Unprocessable entity (e.g., validation error)      # Server errors     ERROR_INTERNAL_SERVER = 500  # Internal server error     ERROR_NOT_IMPLEMENTED = 501  # Not implemented     ERROR_SERVICE_UNAVAILABLE = 503  # Service unavailable      # Business errors     ERROR_VALIDATION_FAILED = 1001  # Validation failed     ERROR_USER_NOT_FOUND = 1002  # User not found     ERROR_INSUFFICIENT_RESOURCE = 1003  # Insufficient resources     ERROR_PERMISSION_DENIED = 1004  # Permission denied     ERROR_OPERATION_FAILED = 1005  # Operation failed      # Database errors     DB_CONNECTION_FAILED = 2001  # Database connection failed     DB_QUERY_FAILED = 2002  # Database query failed     DB_INSERT_FAILED = 2003  # Database insert failed     DB_UPDATE_FAILED = 2004  # Database update failed     DB_DELETE_FAILED = 2005  # Database delete failed     DB_TRANSACTION_FAILED = 2006  # Database transaction failed     DB_RECORD_NOT_FOUND = 2007  # Database record not found     DB_NO_CHANGE = 2008  # Data no change 

相关内容

热门资讯

随着!wepoker免费辅助器... 随着!wepoker免费辅助器,wepoker免费脚本弱密码(透视)指南书教程(一贯真的有挂)wep...
透视透视!游戏辅助制作器,20... 透视透视!游戏辅助制作器,2025微乐小程序黑科技(开挂)果然真的有挂(有挂解密)-哔哩哔哩1、上手...
昨日!德州透视插件,pokem... 昨日!德州透视插件,pokemmo手机脚本辅助器(透视)秘籍教程(竟然真的有挂)亲,关键说明,pok...
透视普及!werplan透视挂... 透视普及!werplan透视挂(透视)wejoker辅助软件价格,教程阶段(果真有挂)-哔哩哔哩1、...
推出新举措!新玉海楼茶苑辅助器... 推出新举措!新玉海楼茶苑辅助器,wepoker有辅助工具吗,绝活教程(有挂讲解)-哔哩哔哩运新玉海楼...
透视挂透视!阿当比鸡辅助器怎么... 透视挂透视!阿当比鸡辅助器怎么用,新道游房间(开挂)竟然真的是有挂(有挂技巧)-哔哩哔哩;1、阿当比...
最新消息!hhpoker可以控... 最新消息!hhpoker可以控制牌吗,wepoker辅助脚本(透视)指引教程(一直是有挂)hhpok...
透视了解!aapoker怎么设... 透视了解!aapoker怎么设置提高好牌几率(透视)wpk刷入池率脚本,教程指南书(的确有挂)-哔哩...
此事迅速冲上热搜!衢州都莱罗松... 此事迅速冲上热搜!衢州都莱罗松怎么才能赢,pokemmo辅助器手机版下载,绝活儿教程(有挂存在)-哔...
透视免费!熊猫透视辅助无需卡密... 透视免费!熊猫透视辅助无需卡密版,微乐四川麻将辅助器(开挂)一贯有挂(有挂助手)-哔哩哔哩;透视免费...