30 lines
710 B
Python
30 lines
710 B
Python
#!/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)
|