# -*- coding: utf_8 -*-

############################
#   Response
#   响应
############################

class ResponseCode(object):
    OK = (200, 'ok')
    NO_DATA = (204, 'no data')
    NOT_FOUND = (404, 'not found')
    NOTHING_CHANGE = (304, 'nothing change')
    REQUEST_ERROR = (400, 'request error')
    AUTHORIZATION_ERROR = (401, 'authentication error')
    INVAILD_REQUEST = (403, 'invaild request')
    PARAMETER_ERROR = (4001, 'parameter error')
    PARAMETER_NULL = (4002, 'parameter is null')
    PASSWORD_ERROR = (4003, 'password error')
    EXISTS_ERROR = (4004, 'record exists')
    INVAILD_ROLE_ERROR = (4005, 'invaild role error')
    ACCOUNT_DISABLED = (4006, 'account is disabled')
    SERVER_ERROR = (500, 'server error')
    DB_ERROR = (5001, 'database error')
    UNKNOWN_ERROR = (5003, 'unknown error')

def response_result(code, msg=None, data=None, **kwargs):
    if msg is None:
        msg = code[1]
    result = { 'code': code[0], 'msg': msg, 'data': data }
    result.update(kwargs)
    return result