public_sentiment/web/dto/service_result.py
2024-09-18 13:41:28 +08:00

30 lines
710 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
class ServiceResult:
"""
service层返回值对象
"""
def __init__(self):
super().__init__()
def __init__(self, success, code, data, message):
# 只要服务端没报错success都是True
self.success = success
# 根据处理结果不同,返回不同的值
self.code = code
# 返回数据
self.data = data
# 提示信息
self.message = message
@staticmethod
def ok(code, data, message):
return ServiceResult(True, code, data, message)
@staticmethod
def fail(code, data, message):
return ServiceResult(False, code, data, message)