__init__.py 596 Bytes
Newer Older
Wei Shoulin's avatar
Wei Shoulin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# coding: utf-8
class Result(dict):
    def __init__(self):
        super(Result, self).__init__()
        self.code = 0
        self.message = ""
        self.data = None
    
    def success(self):
        return self.code >= 0

    @staticmethod
    def error(code = -1, message = ""):
        r = Result()
        r.code = code
        r.message = message
        return r

    @staticmethod
    def ok_data(data):
        r = Result()
        r.data = data
        return r
        
    @staticmethod
    def ok_msg(message):
        r = Result()
        r.message = message
        return r